Schurger.org

10 mars 2010

Je vais à Confoo

Classé dans : Non classé — Jean Schurger @ 2:01

confoo.ca Web Techno Conference

Classé dans : Code, Gnome, Python — Jean Schurger @ 1:59

Tired of typing your #freenode password when ERC is connecting ? You don't want to write you passwords as clear text in your .emacs files ?

Lets see how to store, passwords in the Gnome Keyring, and access it from Emacs. It only needs Pymacs and gnome-keyring python bindings.

  • Write a little module to read and write passwords. This module will be loaded my pymacs and its functions will be available from emacs-lisp. You may name your module 'gnome-keyring.py' and store it somewhere like '~/.emacs.d/pymacs/'
def get_password(name):
    import gnomekeyring as gk
    try:
        items = gk.find_items_sync(gk.ITEM_GENERIC_SECRET,
                                   dict(variable_name=name))
    except gk.NoMatchError:
        return None
    return items[0].secret
get_password.interaction = ""

def set_password(name, password):
    import gnomekeyring as gk
    gk.item_create_sync(gk.get_default_keyring_sync(),
                        gk.ITEM_GENERIC_SECRET,
                        "Emacs password", dict(variable_name=name),
                        password, True),
set_password.interaction = ""

  • Load the module using pymacs
(require 'pymacs)
(add-to-list '
pymacs-load-path "~/.emacs.d/pymacs/")
(pymacs-load "gnome-keyring" "gnome-keyring-")

  • Trying from the interactive emacs lisp mode (M-x ielm)
ELISP> (gnome-keyring-set-password "my-password" "p4$$w0rD")
nil
ELISP> (gnome-keyring-get-password "my-password")
"p4$$w0rD"

  • And now, an example for ERC
(setq erc-password (gnome-keyring-get-password "my-password"))
(setq erc-prompt-for-password nil)

Too easy ! :D

9 décembre 2009

Unit tests with Pylons and its XMLRPCController

Classé dans : Python — Jean Schurger @ 1:37

Now that you have implemented a nice XMLRPCController in your pylons application, it's time to write unit tests covering it. The problem is that the xmlrpclib will try to make a real http connection to an address, but the TestApp used in your TestController is not a real server, and don't listen to any address.

Here is a quick way to enable the coverage of your XMLRPCController. Inspired by Kumar McMillan on this thread.

from StringIO import StringIO
import xmlrpclib
from xmlrpclib import ServerProxy
from mygreatapp.tests import TestController

# a fake httplib.HTTP using 'app' (see TestController.__init__())
class WSGILikeHTTP():
        def __init__(self, host, app):
                self.app = app
                self.headers = {}
                self.content = StringIO()
       
        def putrequest(self, method, handler):
                self.method = method
                self.handler = handler
       
        def putheader(self, key, value):
                self.headers[key] = value
       
        def endheaders(self):
                pass
       
        def send(self, body):
                self.body = body
       
        def getfile(self):
                return self.content

        def getreply(self):
                if self.method == "POST":
                        r = self.app.post(self.handler,
                                      headers=self.headers,
                                      params=self.body)
                        self.content = StringIO(r.response)
                return (200, None, None)

class WSGIAppTransport(xmlrpclib.Transport):
        # Only here to pass the 'app'
        def __init__(self, app):
                xmlrpclib.Transport.__init__(self)
                self.app = app

        # return the fake httplib.HTTP(host)
        def make_connection(self, host):
                host, extra_headers, x509 = self.get_host_info(host)
                return WSGILikeHTTP(host, self.app)

class TestApiController(TestController):
        def test_super_function(self):
                # URL _MUST_ starts with 'http' or 'https' (see xmlrpclib.py)
                server = ServerProxy('http://dummy/api',
                                     transport=WSGIAppTransport(self.app))
                server.super_function("Foo", "Bla", 42)

7 décembre 2009

Apologies and gpr400

Classé dans : Non classé — Jean Schurger @ 23:59

It seems that i have forgotten to mention the authors of the different gpr400 driver implementations or patches when i began to work on it.

Thanks to:

- Pierrick Hascoet

- Henry Plötz

- Jaiger

18 novembre 2009

My keyboard layout have its own web page

Classé dans : Non classé — Jean Schurger @ 23:06

Everybody knows that my keyboard layout (humbly named JSK) is awesome. humm in fact, not quite everybody... The truth is that i need to promote my layout to hope its inclusion in the 'exotic' sections of 'xkeyboard-config', so, here is where to look to begin to love this keyboard layout (and pass the word).

http://projects.schurger.org/projects/jsk/wiki

3 octobre 2009

Ubuntu global jam

Classé dans : Non classé — Jean Schurger @ 17:38

Dimanche

  • École de technologie supérieure (http://www.etsmtl.ca/)

  • 1100 rue Notre-Dame Ouest
  • Salles/Rooms A-1300 et A-1238

3 septembre 2009

New gpr400_cs driver release

Classé dans : Non classé — Jean Schurger @ 15:46

I've released a new version of the gpr400_cs driver including Jose Antonio Sánchez Vázquez fixes, and adding dkms.

This version runs fine with recents kernels and is tested with Ubuntu's 2.6.30 one.

The package for Ubuntu Karmic is available here:

http://projects.schurger.org/embedded/packages/index.html

(The karmic package should be installable on a jaunty as it contains
only sources and scripts)

The sources are available through mercurial here:

http://sources.schurger.org/gpr400_cs/

1 septembre 2009

Je peux réécouter mes vinyls !

Classé dans : Audio — Jean Schurger @ 17:39

Enfin aprécier à nouveau l'album de Zappa Sleep Dirt version vinyl, et toutes ses nuances par rapport à la version CD officielle. Vinylrecord s'est occupé de faire la numérisation de mon album moyenant une modique somme, et le résultat est surprenant: je m'attendais à entendre un peu de souffle ou de craquement, mais ils sont quasiment innexistants ! en plus, la qualité de l'impression de la jaquette et du CD est à la hauteur de l'enregistrement.

26 août 2009

The FSF’s « Windows 7 Sins » campaign is started !

Classé dans : Non classé — Jean Schurger @ 11:20

Windows 7 Sins

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

Powered by WordPress