Schurger.org

17 avril 2009

another ruby ‘unexplicite’ error

Classé dans : Non classé — Jean Schurger @ 16:34

During a classic rake db:migrate

(in /var/tracks)
rake aborted!
no such file to load -- spec/rake/spectask
/var/tracks/Rakefile:10
(See full trace by running task with --trace)

The resolution is: gem install rspec

Let’s jam ! (or vkeybd for the fun)

Classé dans : Non classé — Jean Schurger @ 4:21

One apon a time, i've designed a three octaves kayboard layout for the vkeybd program, but for an french keyboard.

This evening, some of my collegues decided to jam with nice instruments, so i thought it was the good time to take a look one more time to fluidsyth, bristol, and vkeybd. But as i now live in Canada, i use an english keybord. Xev helping, i've made a new three octaves layout for the english keyboard.

Available here: vkeybdmap-en

and it looks like:

Keymap

9 avril 2009

My own keyboard layout

Classé dans : Non classé — Jean Schurger @ 5:37

After having tested the Colemak layout, the French, the US and the Canadian one, my conclusion, is ... simply a new layout : mine :)

  • It have the advantages of the US one for the <> ./ [] {} characters locations
  • The Backspace at the Caps lock location (stolen from Colemak)
  • The Delete key near the between the Alt Gr and the Right control
  • The ability to type a lot of accentued characters, directly or with dead keys. The idea is stolen from Colemak too,  but i've changes some accents orientation to fit better to the french words.

Here is the result: JSK

To use it, just drop the file to /usr/share/X11/xkb/symbols and invoke setxkbmap jsk

Here is the layout:

JSK Layout

4 avril 2009

A new desktop theme

Classé dans : Non classé — Jean Schurger @ 3:52

I finally decided to publish my dark Black and Red desktop theme.
Here is a screenshot:

JS Black and Red theme screenshot

Available here: JS-Black-and-Red.tar.bz2

3 avril 2009

Quick Howto: Write/Install/Use a plugin in python with entry points

Classé dans : Code, Python — Jean Schurger @ 19:52

Write a plugin

in a 'super_plugin' directory dedicaced to the plugin, create two files:

__init__.py with your plugin 'content' eg:

class Foo:
    def __init__(self):
        print "Foo plugin loaded !"

    def super_function(self):
        print "Bar !"

setup.py with your plugin description eg:

from setuptools import setup, find_packages

setup (
    name='SuperPlugin',
    version="1.0",
    description="A Super plugin for the 'Baz' project",
    author="Jean Schurger",
    packages=find_packages(),
    include_package_data=True,
    entry_points="""
        [Baz.plugin]
        Foooo=super_plugin:Foo
    "
"",
)

Install your plugin

sudo python setup.py install

Use your plugin

Let's try with ipython

In [1]: from pkg_resources import load_entry_point

In [2]: load_entry_point('SuperPlugin', 'Baz.plugin', 'Foooo')
Out[2]:

In [3]: object = _()
Foo plugin loaded !

In [4]: hasattr(object, "super_function")
Out[4]: True

In [5]: # that's very cool !

In [6]: object.super_function()
Bar !

Just a word about groups and how to discover plugins


In a more complex application, you may have more plugins ! and you may want to
discover them and maybe load them too !
Let's try (with ipython)

In [1]: from pkg_resources import iter_entry_points

In [2]: for object in iter_entry_points(group='Baz.plugin'):
...:     print object
...:
...:
Foooo = super_plugin:Foo

In [3]: object.load()
Out[3]:

In [4]: _().super_function()
Foo plugin loaded !
Bar!

2 avril 2009

ruby & mkmf

Classé dans : Code, ruby — Jean Schurger @ 23:02

Just a remember for people like me who never remember what to do with this thing:

extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1

Just do:

apt-get install ruby-dev

18 mars 2009

New subdomains !!!

Classé dans : Code — Jean Schurger @ 21:29

I have the pleasure to annonce the launch of 3 new Schurger.org subdomains :

Projects

I progressively move my projects to this site. It runs Redmine (powered by Ruby On Rails).

Currently, it works with apache mod_proxy, but i plan to run it by passenger (mod_rails)

Sources

Which contains public Mercurial Repositories of my projects, everybody can "clone" projects from here.

It runs the Mercurial web service throug apache and mod_wsgi :)

Packages

Here are apt-get enabled repositories for my custom packages.

1 août 2008

Copy X selection to Tomboy

Classé dans : Non classé — Jean Schurger @ 19:58

Put that code into a script, set a keybinding desktop wide, and tomboy notes will be created, containing your current X selection, simple, easy, and terribly  usefull ! (needs xsel)

#!/usr/bin/env python

import sys, dbus, dbus.glib
from datetime import datetime
from subprocess import Popen, PIPE

bus = dbus.SessionBus()
obj = bus.get_object("org.gnome.Tomboy", "/org/gnome/Tomboy/RemoteControl")
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")
p = Popen(args=["/usr/bin/xsel"], shell=False, stdout=PIPE)
p.wait()
sel = p.stdout.read()
if sel:
    now = datetime.now().ctime()
    new_note = tomboy.CreateNote()
    tomboy.SetNoteContents(new_note, "X %s\n\n%s" % (now, sel))
    tomboy.AddTagToNote(new_note, "X")

10 juillet 2008

Colemak

Classé dans : Non classé — Jean Schurger @ 4:09

"Apf jyl pfaij ragurtufs bj jylp clppfkg efjbyaps iajylg ^ ug maj bf ar y;gumuzfs ar jyl ghuke !"

This is the sort of thing you may write starting to use the Colemak layout.Why not trying it, here is its
description pasted from the original website : http://colemak.com :

"The QWERTY layout was designed in the 19th century to allow typewriter salesmen to easily type the word "typewriter" and to prevent typebars from sticking. We've been stuck with QWERTY ever since.
Colemak is a modern alternative to the QWERTY and Dvorak layouts. It is designed for efficient and ergonomic touch typing in English.
Learning Colemak is a one-time investment that will allow you to enjoy faster and pain-free typing for the rest of your life. Colemak is now the 3rd most popular keyboard layout for touch typing in English, after QWERTY and Dvorak."

And here is the complete layout build from the Gnome keyboard setting tool (available in hi resolution to print it and stick somewhere not far from you screen):

Colmak layout

12 juin 2008

HOWTO know if your laptop screen is closed or open ? the desktop way (in python)

Classé dans : Code, Python — Jean Schurger @ 3:08
#!/usr/bin/python

import dbus
import dbus.glib
import sys

class LidSwitch(object):
    def __init__(self):

        bus = dbus.SystemBus ()
        hal_obj = bus.get_object ('org.freedesktop.Hal',
                                  '/org/freedesktop/Hal/Manager')
        hal = dbus.Interface (hal_obj, 'org.freedesktop.Hal.Manager')
        udis = hal.FindDeviceByCapability ('input.switch')

        for udi in udis:
            dev_obj = bus.get_object ('org.freedesktop.Hal', udi)
            dev = dbus.Interface (dev_obj, 'org.freedesktop.Hal.Device')
            if dev.GetProperty ('button.type') == "lid":
                self._lid_dev = dev

    def _is_closed(self):
        if hasattr(self, "_lid_dev"):
            return self._lid_dev.GetProperty ('button.state.value')
        else:
            raise ValueError("no lid switch found")

    is_closed = property(_is_closed)

if __name__ == "__main__":
    ls = LidSwitch()
    print "Lid switch is %s" % (ls.is_closed and "closed" or "open")

Powered by WordPress