Skip to content

Instantly share code, notes, and snippets.

@cjbarnes18
cjbarnes18 / sqltoxls.py
Created February 8, 2012 18:52
convert sql to an xls file
#!/bin/env python2
"""Tools to output sql data to xls files."""
from xlwt import Workbook, easyxf
def build_worksheet(cursor , book, sheet_name='new_sheet'):
"""Save results from an sql select query into a worksheet.
cursor -- a database cursor where a select has been executed.
book -- the workbook to attach the sheet to.
@cjbarnes18
cjbarnes18 / config.py
Created February 11, 2012 10:30
qtile config
from libqtile.manager import Key, Screen, Group, Drag, Click
from libqtile.command import lazy
from libqtile import layout, bar, widget, hook
follow_mouse_focus = False
mod = "mod4"
keys = [
Key([mod], "w", lazy.window.kill()),
@cjbarnes18
cjbarnes18 / demo_import.py
Created February 25, 2012 21:41
Demo data import tool for Tryton.
#!/usr/bin/env python2
import csv
from proteus import config, Model, Wizard
from xmlrpclib import Fault
from datetime import date
def init_database(module_name):
Module = Model.get('ir.module.module')
(school_module,) = Module.find([('name', '=', module_name)])
@cjbarnes18
cjbarnes18 / __init__.py
Created March 15, 2012 21:57 — forked from zodman/__init__.py
tryton admin jsonrpc
from jsonrpclib import Server as ServerProxy
import base64
import jsonrpclib
import json
class AdminTrytonException(Exception):
def __init__(self, result):
self.result = result
@cjbarnes18
cjbarnes18 / url.py
Created March 21, 2012 21:17
open a url remotely using Pyramid
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
import webbrowser
def open_url(request):
if request.POST:
webbrowser.open(request.POST['url'])
form = '''
@cjbarnes18
cjbarnes18 / config.py
Created March 27, 2012 21:24
Help key
def get_help(q):
import webbrowser
webbrowser.register('firefox-auror', webbrowser.Mozilla)
webbrowser.open('www.qtile.org')
keys = [
Key([alt], 'F1', lazy.function(get_help)),
]
@cjbarnes18
cjbarnes18 / core.css
Created March 27, 2012 21:50
HTML sample template
html {
background-color: lightblue;
padding: 0;
margin: 0;
height: 100%;
}
body {
padding: 0;
height: 100%;
background-color: white;
create file /etc/apt/sources.list.d/tycho.list with the following.
deb http://ppa.launchpad.net/tycho-s/ppa/ubuntu precise main
deb-src http://ppa.launchpad.net/tycho-s/ppa/ubuntu precise main
curl "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x8516D5EEF453E809" > tyco.key
apt-key add tyco.key
aptitude update
aptitude install qtile
To get up and running copy the default config.
mkdir -p ~/.config/qtile
@cjbarnes18
cjbarnes18 / gist:4056413
Created November 11, 2012 22:02
Qtile release
It gives me great pleasure to announce the release of Qtile 0.5.
This release includes
- New website
- Migration of the test suite to nose
- Documentation is now written in sphinx
- 2 new layouts
- Many new widgets
Please see the change log for more details.
@cjbarnes18
cjbarnes18 / .bash_profile or your equivalent
Created November 15, 2012 13:38
Settings for Java in Qtile
export _JAVA_AWT_WM_NONREPARENTING=1
export AWT_TOOLKIT=MToolkit