Σάββατο, 8 Οκτωβρίου 2011

Sooperlooper loses connection to engine

If it happens that sooperlooper shows you this dialog:

Lost connection to SooperLooper engine.
See the Preferences->Connections tab to start a new one




on newer distributions (I tried it with Fedora 16 beta 1), add your
. (substitude with your host and with your domain) to your `/etc/hosts' file on the line for 127.0.0.1 and try again.

For example, my hostname is `mmxgn' and domain is `emergencia' so my hosts file was:

127.0.0.1 localhost.localdomain localhost


and I added mmxgn.emergencia next to localhost.

127.0.0.1 localhost.localdomain localhost mmxgn.emergencia


Now when I run `slgui' I can use sooperlooper without the engine dying.






Τρίτη, 7 Ιουνίου 2011

Guitar Pro 6 on Fedora 15

I had some problems installing Guitar Pro 6 for Linux on Fedora 15.
The problem was that, after extracting the .deb file on the cd, on /opt/ the updater would fail when I ran it as a user because of wrong permissions, and if I chmodded 777 the Guitar Pro directory, or ran with sudo, It would not run at all.

So, what I did:

1. I ran ./GPUpdater as the regular user, with the original directory permissions
2. While running, I chmodded 777 /opt/GuitarPro6
3. Updated

And finally (I'm at the third step right now) changing to the original 755 permissions.

Παρασκευή, 30 Ιουλίου 2010

Mozart/Oz and Gedit

Mozart/Oz is a very powerful language, which I recently started using.

Unfortunately, the most efficient way to use it, is from within emacs and the OPI.

I tried to find a way to use it with other editors, even for simple functionality like syntax highlighting but with no success.

Today, I tried to make a syntax `.lang' file for gedit, for Mozart/Oz so I took a .lang file
I found in `/usr/share/gtksourceview-2.0/language-specs/' (`scheme.lang'), modified it
and there I have a far-from-complete-yet-working `.lang' file for Mozart/Oz and gedit, as well some `tools' for the `external-tools' plugin (compile & compile-run with and respectively).

If you want to use it, access my github at:http://github.com/mmxgn/mozart-stuff/tree/master/mozart-gedit/

Download mozart-gedit.tar.gz, untar-gzip it and read `INSTALL'.


Here's a screenshot:



Πέμπτη, 4 Φεβρουαρίου 2010

Calculating conditional pmf matrices in python (numpy)

Here is the thing that has tormented me for some time now.

I have a conjunctive probability table, with shape, for example (1,2,3,4,5,6) .
And I want to calculate the probability table, conditional to a value for some of the dimensions, for decision-making purposes. We define the values we want

The code I came up with at the moment is the following (the input is the dictionary "vdict" of the form {'variable_1': value_1, 'variable_2': value_2 ... } )


for i in vdict:
dim = self.invardict.index(i) # The index of the dimension that our Variable resides in
val = self.valdict[i][vdict[i]] # The value we want it to be
d = d.swapaxes(0, dim)
d = array([d[val]])
d = d.swapaxes(0, dim)
...


So, what I currently do is:

1. I translate the variables to the corresponding dimension in the cpt.
2. I swap the zero-th axis with the axis I found before.
3. I replace whole 0-axis with just the desired value.

I put the dimension back to its original axis.

Now, the problem is, in order to do step 2, I have (a.) to calculate a submatrix
and (b.) to put it in a list and translate it again to array so I'll have my new array.

Thing is, stuff in bold means that I create new objects, instead of using just the references to the old ones and this, if d is very large (which happens to me) and methods that use d are called many times (which, again, happens to me) the whole result is very slow.

So, has anyone come up with an idea that will subtitude this little piece of code and will run a lot faster? Maybe something that will allow me to calculate the conditionals in place.

Edit: I replaced the command in bold, with the code below:

d = conditionalize(d, dim, val)
where:

def conditionalize(arr, dim, val):
arr = arr.swapaxes(dim, 0)
shape = arr.shape[1:] # shape of the sub-array when we omit the desired
count = array(shape).prod() # count of elements omitted the desired dimension.
arr = arr.reshape(array(arr.shape).prod()) # flatten the array in-place.
arr = arr[val*count:(val+1)*count] # take the needed elements
arr = arr.reshape((1,)+shape) # the desired sub-array shape.
arr = arr. swapaxes(0, dim) # fix dimensions
return arr
Now, what before took 15 minutes to complete, now takes only about 6 seconds!

Τρίτη, 22 Δεκεμβρίου 2009

cast from 'void*' to 'int' loses precision

Irritating message, it happens because:

int a = sizeof(b)

is bad, where:

size_t a = sizeof(b)

is better.

So if you happen to try to compile something and it gives you this message, try to figure out what tries to make it an int and change it to a size_t.


Τετάρτη, 13 Αυγούστου 2008

Cross platform?

Ok, I know I have some days to write into this blog and I am going to ressurect it a little big.
This summer I finally started to get my hands dirty with python (since it's a so nice language). I tried to do some stuff with sockets, threads, gtk and wx since I had in mind the cross platform nature of python.

What I have as a result in my mind is that, I don't find it so "cross-platform" (at least not as much as java is - which I haven't got my hands dirty on, yet - ) . I mean, surely what I write, runs on both linux and windows (haven't tried it on my G5 mac tho, I should try) but with what cost? While it seems to run flawlessly on linux with gtk, threads and all, I had to remove thread support on windows in order to make it work (I didn't need threads anyway in the first place, just for educational purposes ) which has something to do with gtk I guess (wx didn't complain). Oh that and the nearly 50% CPU usage of pythonw.exe (you don't want a background app to take that much, do you?) and/or the executable I made with py2exe.

Also another story is py2exe. I tried to make a distributable package for python-unaware systems. It took me some time because of missing modules and stuff, made an, about 16mb dist package (about 7mb compressed) so I was happy to give it to two friends to test it.

First hit under the belt. While I had corrected the box-letters on my system (runned pango-querymodules.exe on a file under my dist directory) my buddies had the same problem, so I sent the pango and freetype dlls which it seems it worked to one of the systems (the other still had the box-letters )

Second hit under the belt. The app is supposed to be a cute and minimalistic IM client, lighter than the heavyweight Live Messenger (educational purposes only, I may release it under gpl
if its fully working tho). In a way, it succeeds, but only on linux. On windows, it made my friend's computer...fry (mine too). 50% CPU usage for a small and light app is not ok (tho I seem to have made something wrong. Emesene is on python and It runs with almost no CPU usage, on Windows)

To not get misunderstood. I love python, it just provides everything I would need so I would design and go (also scipy is awesome), but I think the current CPython is not really what I would turn to if I wanted cross platform support (web applications is another story where I want to see how it works)

But I see light on the horizon. It shines, it's pretty, and it is Java. It's jython and I think I will fell in love with it.

But anyway, next stop: undestanding how to write efficient windows apps in python, and also having a look at PARLEY