Monday, November 21, 2005

this blog has moved

I got tired of blogger being so slow altow it now seams faster. Anyway is final,
this blog has moved to my website http://www.emilas.com/ where even if spead is only as fast as my DSL at least I have greater flexibility.

Sunday, April 03, 2005

No lambda


class fn:
def __init__(gen):
self.gen = gen
def __call__(*args):
fn.args = args
return self.gen.next()

f = fn(a+b+c for a,b,c in fn.args)
f(2,3,4)

f = lambda a,b,c: a+b+c
f(2,3,4)

Friday, February 25, 2005

SQL Server express

This post is about this link

Free sql server from microsoft

Saturday, January 29, 2005

free pictures web site

This post is about this link

http://www.sxc.hu/index.phtml

Friday, January 21, 2005

def __typecheck__: pass

__typecheck__: documentation, support for IDE, catch typo errors


I'm tired and sick, your finger is sticking into my eye. My
head is resting onto my fist. My ears are leaking connections
and the world is laying flat. Already the clocks are ticking
destructive demand and opposing is Homeric at best. The literature
has never been written, yet the breath is full of critical smoke.
A war is smiling at us.
It's dark and I'm ready to sleep.


- allow a human reader of code to understand better what happens in that code, since programmes can't really right documentation and they must be forced somehow to document their intentions
- this isn't going to be done unless declarations are enforced otherwise is going to remain a mechanism of not writing metadata. Maybe if we are driven into some special mood?
- if we enforce we are OK and flexibility is saved by ignoring any action possibly suggested by declarations
-rules are broken => documentation is less useful maybe is van maybe even more dangerous when trust is going to disappear
- what kind of help is this supposed to give to IDE programmers. Generic genuine help? what does it mean? Is this support the end of IDE request, will programmers ever want more tool support? maybe something that is not possible even with the most strict declarations of types and interfaces?
- function signature lookup? (IDE does import, run, dir?)
- type of current variable (use AST and type inference, or run code?)
- are we afraid to build slow solutions? are we afraid to build resource hungry solutions?
- solution first?, optimization later?, hardware support - embrace distance between script and system ?
- gather some IDE developers and discuss how to make it work, even if code will need be run, probably there are ways to get this without declaring intent
- maybe Python must grow an IDE out of it's core as a standard
- maybe Python needs library enhancement more stringently, maybe it needs to reshape old abstractions ?
- maybe building better abstractions is more useful? (are there any? Erlang, distribution, concurrence, network, Mozart)
- are more abstractions just sugar growing into diabetes ?
- gather people from PyChecker those that built type inferencers, those that built just in time compilers, those that built different semantics with similar syntax as python
- discuss implementation possibilities or design choices?
- 666 ?
- more easily said when you can hire people, harder when you can't?

- is python good as is, what does it need, why. Why doesn't python have types declarations already, is it demand? is it implementation difficulties, is it design? - Is there a philosophy? What is it? what is it for?

- are this declarations to help programmers? What are the trade offs? how much will it help? how much will it introduce confusion? what are the ramifications? what else will it impact?

- who will this make happy? who can use this efficiently? how many? what do the masses need most?
- how does the hardware market look like? where is it moving? are there any trends? is python aware?
- how is the corporate world? where is it moving towards? what does it seek?
- how is the python world? where is it moving towards? what does it seek?
- are there connections? are there too few? too many?

Wednesday, November 17, 2004

Boa's _custom_classes

Shame on me, if I bodered to read the help I could have long ago start subclasing wx controls "inside Boa GUI builder".


class wxFrame1(wxFrame):
_custom_classes = {'wxTreeCtrl': ['MyTreeCtrl', 'MyOtherTreeCtrl']}
def _init_utils(self):
pass

python static typing should be protocol adaptation

This post is about this link



Glad to hear that. As for me, I'd love it if function arguments, only,
could bear an 'as' clause (making 'as' a keyword is long overdue):

def x(y as foo, z as bar):
body of x

translating into:

def x(y, z):
y = adapt(y, foo)
z = adapt(z, bar):
body of x

where builtin 'adapt' does protocol adaptation. On the other hand, if
the semantics of those 'as' clauses were something like:

def x(y, z):
if type(y) is not foo: raise TypeError, 'y must be foo'
if type(z) is not bar: raise TypeError, 'z must be bar'
body of x

then that's the day I move to Ruby, or any other language that remained
halfway sensible (if any).


Of course adaptation is posible already using decorator functions, or if using PyProtocols someone can also go having all kinds of contracts, the simplest would be function dispatch conditions, like:

@foo.when(x>10)
def foo(x):
...
@foo.when(x<5)
def foo(x):
...

but anyways I beleave some syntax in the language for stuff like that will make people actualy use them more often.
I beleave there are lots of people in python coming from C, VB, Java like languages, who have a harder time using them, while others coming from Lisp who had them all since forever will say finaly, oh God what took you so long.
Designing with different conceps it's never going to be easy. To put this in paradoxical terms, nobody never love anything unless they already do.

Thursday, November 11, 2004

Creepy Polar Express - Uncanny Valley

This post is about this link

Uncanny Valley

Monday, November 08, 2004

Lori

This post is about this link

Loredana Groza on photo.net?

abstractions save time working, but not learning

This post is about this link

Today I read this great article again and somehow I can't take this out of my mind:

So the abstractions save us time working, but they don't save us time learning

And all this means that paradoxically, even as we have higher and higher level programming tools with better and better abstractions, becoming a proficient programmer is getting harder and harder.

Computers are useless. They can only give answers

Evan Jones: http://evanjones.ca/
"Computers are useless. They can only give answers" - Pablo Picasso

Nice motto, however I guess they can make humans raise questions too. But the topic of what makes humans raise questions seams insanely hard to reason about. And what is a valid new question and what is a reformulation is another one.

It's just me being bored and having nothing better to do.
But is it ever different in such topics ever, anywhere?

Sunday, November 07, 2004

Bloom Filters

This post is about this link

The first think for me would be to implement a quick exists(txt) in a given huge collection of texts. rom there I can start searching.
Maybe the vector could be a "hash table" with indexes in the collection as values and provided that the hash functions, between themselves have very low collision ratio, the bits in the vector are now pointing to index in the collection instead of seen/not-seen and we could have a very fast search.
Also would make a nice implementation of "e-mail and beyond" black-list/white-list.
The only question is how do you come up with k different hashing mechanisms yet in a limited space like (1..m) and what is the best k,m to use for a given lenght of your collection?. I guess the answer is God bless the mathematicians.

UpdateNow that I think a little more about, this is all blabla (hash table), since m would probably need to be as big as the collection length, or somewhere near to allow for overlaping not to happend, and so cannot be fixed from the start, wich I beleve was the hole point of this, (where there are k different hashes to minimize the impact of a given relatively small m).

Wednesday, November 03, 2004

http pull / push

This post is about this link

For push:
server sends Content-type: multipart/x-mixed-replace and then sends each part whenever it wants.
The browser will keep waiting for parts and present each part as a different page.
-in ASP do response.flush for each part and "sleep" until next part?
-is CGI ok since they will stay alive for so long?
-how is the server to cope with many of this such request, what is better separate processes (CGI, out of process ASP) or in-server-process scripts (pooled ASP)
-what about apache, is CGI or mod-python better
-what about third parties like webware?

How does someone do incremental updates of only one part of the page?
Maybe via JavaScript window.XMLHttpRequest and document.write or element.innerHTML ?
Maybe the MIME part is some javascript in a hidden (1 pixel) frame that updates the rest of the page (frames)?

It kind of starts to smell already, but I should give it a try and eventualy look for more info, for now i think I'll stay with pull via javascript XMLHttpRequest or HTML <meta refresh>.

Saturday, October 30, 2004

XML-RPC - Multiple calls over same connection

This post is about this link

Login once and then succesive calls must assume those credentials.
The following is nice but "login profiled behaviour" is still a question, (or not? can we configure SSH env. such that it will proxy to different rpc servers based on auth. profile? and if yes, isn't multiple rpc servers a complication?)

The default implementation uses HTTP as a transport, but that is
not a requirement. You just have to be able to serialise the request
and response parameters into an XML stream. The xmlrplic loads and
dumps functions will do that for you.

In one of my projects I actually use XML-RPC over SSH and deal with
the authentication etc at the SSH level. (I use the excellent pure
Python paramiko library for the SSH protocol part).



Sunday, October 24, 2004

A draft ?

This post is about this link

How to not enjoy a draft if Bush is re-elected.
www.enjoythedraft.com

Is there some how to enjoy taxes a la Europe more then rumor web presence?. Don't balance taxes at end of year, pay taxes included in the prices of things.
How would this be implemented? What would there be in this for small businesses, and what for big wolfs?

Thursday, October 21, 2004

Links to remember

http://www.williamgibsonbooks.com/
read something from there (SF ?)
awarded + "Neuromancer" I heard but never went anywhere with it yet

http://compsoc.dur.ac.uk/whitespace/
how to code some language keywords as white space
=> bored people build boring stuff

http://www.worldwidewords.org/
good ???? for an english illiterate like myself

Metaclass to autoupdate existing instances of a class to newly modified and reloaded classes

This post is about this link


Pretty simple yet so powerfull:
ideas:
-name the class __metaclass__ so all we need is import
-keep track of the instances in a new key (A) of the class attributes dictionary
(use instance __init__ to add the new instances to A in the class)
-at module reload, check sys.modules for the old class and copy A from old class
to new class dictionary
-for each instance (a) in A replace a.__class__ from old class to new class


#----- autoupdate.py
'''metaclass for auto-update classes'''
class __metaclass__(type):
# automatically keeps tracks of instances
def __new__(cls, class_name, bases, class_dict):
import inspect
module_name = class_dict['__module__']
#we will update bellow the class_dict with a new key:
#instance_dict_name and value a list of instances

instance_dict_name = '_%s__instances' % class_name
# see if there is already an older class
import sys
old_instance_dict = None
if sys.modules.has_key(module_name):
module = sys.modules[module_name]
if hasattr(module, class_name):
old_instance_dict = getattr(getattr(module, class_name),
instance_dict_name)
# add instance list
import weakref
class_dict[instance_dict_name] = weakref.WeakValueDictionary()
# override the __init__
if class_dict.has_key('__init__'):
def new_init(self, *args, **kw):
instance_dict_name = '_%s__instances' % (
self.__class__.__name__)
getattr(self.__class__,
instance_dict_name)[id(self)] = self
self.__original_init__(*args, **kw)
class_dict['__original_init__'] = class_dict['__init__']
class_dict['__init__'] = new_init
else:
def new_init(self, *args, **kw):
instance_dict_name = '_%s__instances' % (
self.__class__.__name__)
getattr(self.__class__,
instance_dict_name)[id(self)] = self
class_dict['__init__'] = new_init
# build the class, with instance_dict
new_class = type.__new__(cls, class_name, bases, class_dict)
# copy over the instance dictionary, and update __class__
if old_instance_dict is not None:
for instance_id, instance in (
old_instance_dict.iteritems()):
getattr(new_class,
instance_dict_name)[instance_id] = instance
instance.__class__ = new_class
# return new class
return new_class

#----- Spam.py
from autoupdate import __metaclass__
class Egg:
'''Put here your class code'''
# def print(self):
# print 'Hello World!'

#----- from your Python console
import Spam
x = Spam.Egg()
# ... edit your Spam.py file and change code for Spam.Egg class,
# e.g.: add a print() method to Spam.Egg by uncommenting
# the corresponding lines. Save the file.
reload(Spam)
x.print() # prints 'Hello World!'

Wednesday, October 20, 2004

color SynthAxis

This post is about this link

The "bester" coloring tool: color SynthAxis.
It actualy allows anti-designers pretend to be "ok" designers as far as "color schemes" go.

Test Driven Development

One aspect I cannot understand in TDD is how someone can assume that code is good if it's tested.Code that tests something is still code isn't it?
How do you know if you tested for everything that may go wrong?
If you can get the test correct then you can also get the main code correct.

The only help I see from TDD is that it may allow to see how fixing something here breaks something there. But that means the code is coupled and then how do you test for all this coupling?

-Your code should not be coupled.
-But how do I write GUI code that is uncoupled?
-Don't couple beforehand, instead use runtime registration of event handling.
-How is that uncoupling? How do you test for this chain of events and how do you know how are they going to happen?
-Test everything behind the GUI and leave GUI tests for later.
-What's the point?
-You should not write GUI code and start do some tests.
-Ha?

Python Interfaces

Ned Batchelder had problems mimicking Java's interfaces in Python and then he also had problems departing from that too.

The problem is that the implementer actually implements all the methods in the interfaces (via inheritance) regardless of whether it overwrites the behavior or not.

If there were real interfaces in Python's language, then this would not be a problem since it would only be implemented if it actually implements it.

He also explains how one does this in Java, which IMO is because Java forces you to implement all the methods in the implementer, so you must start creating hierarchies of interfaces to allow the implementer implement only one method, namely the child interfaces's method.

In python, thanks to the fact that everything is an object and dynamic nature of things you can declare that something does something other ways:
methodName.notYetImplemented = True even if there is code in the body of the method and then rely on this attribute of the method's object rather then on the fact that there is code in the body of the method or not like in Java.


def makeAbstract(f):
f.abstract=True
return f

class NotImplemented(Exception): pass

class Executable:
@makeAbstract
def oneWay(self):
raise NotImplemented
@makeAbstract
def secondWay(self):
raise NotImplemented
or for py2.3
oneWay = makeAbstract(oneWay)
secondWay = makeAbstract(secondWay)

class Statement(Executable):
def oneWay(self):
print "one way executed"

s = Statement()

if not hasattr(getattr(s, 'oneWay'), "abstract"):
s.oneWay()
else:
s.secondWay()

Of course someone can argue how much more readeble an interface inheritace dispach mechanism is vs a switch dispache mechanism such like the one above, and I agree that often that is true, however there are many instances when "simple is simpler and therefore better". However this discution dosen't interests me and I let the purists take onto that.
Now if you would like to let the dispach mechanism be taken care of by someone else, not you, then better use something like "runtime object providing a protocol"PyProtocols wich is now also arguable as clean or cleaner then a "compile time object following interface specifications" such as Java's.

Tuesday, October 19, 2004

Are we becoming robots?

We can't really see what technology does because:
an exponential curve approximates a straight line when viewed for a brief duration (Ray Kurzweil)
So predictions are always in linear way (see below) because they are ideas applied to ideas.

The problem with "non-technological" fields of knowledge is that there is no reliable apparatus to effectively remembering and so to being able to quickly applying knowledge, rather a cycle of re-inventions and epiphanies (lousy memory triggers) represent the engine of evolution.

So really what technology does, it allows us to remember?.

Technology way, the exponential way (the anti-struggling way?)
Ideas build concrete objects. A
A and ideas build concrete objects. B
B and ideas build concrete objects. C
...

Gnoseology way, the linear way (the struggling way?)
Ideas build ideas. A
A builds ideas. A
A builds ideas. A
...

The equation to spin around Bill Joy:
linear + exponential = exponential
gnoseology + technology = technology
epistemology = gnoseology + technology
ontology = epistemology
ontology = technology

versus the old way
epistemology = gnoseology
ontology = epistemology

Thank you syllogism for being a friend again and probably still let me be with the ontology maped the old way.

OS religion

Install XP in 5 hours or less
Install X-Chat in 5 hours or more

Sometimes you may find yourself taken over by the flow of things, when your brain is more in a "sensory like" state.
=> You may find this funny

Sometimes you may find yourself taken over by the critical you, when your brain is more in a "why, when, how" state.
=> You may find this sad

Again IMO is always about "my world" rather the "the world".

Subjectivism

Via Ian Bicking

I realized I dislike Kerry because he isn't who I want him to be. But that's unfair -- he is who he is. He was selected for who he was.



IMO this is most often what the problem is:

The world does not exist, what exists is "my world" where the world is in the ways I got where I am know, with my frustrations, my happy moments, my knowledge and from there the inferred inevitable subjective opinions etc.


I strongly believe that even mathematics to a prety large degree is subjective, then what to talk about the less a priori wings of the world.



html image inlining

I didn't know about this
Nice

I've been inlining in emails, but for web I was always using a separate script to
give out images for which links should not be known like:
<img src="getImage?id=bla">
<img src="getImage?id=bla2">
where getImage only works if a user is signed in or something.
Now I can turn more round trips into one if images are not big using something like

<img
src="data:image/gif;base64,
R0lGODlhAwEgAPcAAP///87OzqWlpYSEhHNzc2tra1paWiEYGQv+E
AP/OGP/OAM7Oxr29xjEA/2MA/5wA/+8A/+dK79573ta8AGAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAIpHuDBABsMANrb8JqF0gFxG+XAAHeqe2S+
Rh//hEFwEiA8ENJPN8K6NawcWA50CCLMnw7kUa/p
Rdrpco7uOexAMKBLYPpNlxAZ6DAnJlm7WlavA4FANR0Kg9CEAC
BAQAOw==
" >