This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton: | |
__single = None | |
def __init__( self ): | |
if Singleton.__single: | |
raise Singleton.__single | |
Singleton.__single = self | |
def Handle(x = Singleton): | |
try: | |
single = x() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tanel@mave:~$ lspci | grep VGA | |
00:02.0 VGA compatible controller: Intel Corporation 82G33/G31 Express Integrated Graphics Controller (rev 0a) | |
tanel@mave:~$ sudo lshw -C video | |
[sudo] password for tanel: | |
*-display:0 | |
description: VGA compatible controller | |
product: 82G33/G31 Express Integrated Graphics Controller | |
vendor: Intel Corporation | |
physical id: 2 | |
bus info: pci@0000:00:02.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
'Downloads tumblr images from dashboard' | |
import urllib | |
import os | |
from time import sleep | |
import simplejson as json | |
from threading import Thread | |
from Queue import Queue | |
MY_QUEUE = Queue() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~n === -(n+1) | |
#~-1 === 0 | |
def in_string(text, search): | |
return not ( not ( ~text.find(search) )) | |
assert in_string('abcde', 'e') | |
assert in_string('abcde', 'cde') | |
assert not in_string('abcde', 'x') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.response.headers['Content-Type'] = 'application/zip' | |
self.response.headers['Content-Disposition'] = 'attachment; filename="example.zip"' | |
self.response.headers['Content-Length'] = len(text) | |
self.response.headers['Content-Transfer-Encoding'] = 'binary' | |
self.response.out.write(text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render(view, data = None): | |
current_dir = os.path.dirname(__file__) | |
path = os.path.abspath( | |
os.path.join(current_dir, '..', 'views', '%s.html' % view) | |
) | |
if not os.path.exists(path): | |
return '404 - view not found!' | |
if data is None: | |
data = {} | |
return template.render(path, data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def has_falsy(lst): | |
def is_falsy(val): | |
return not val | |
return not not len(filter(is_falsy, lst)) | |
assert not has_falsy([]) | |
assert not has_falsy([1,2,3]) | |
assert not has_falsy(['0']) | |
assert not has_falsy(['None']) | |
assert has_falsy([None]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gsettings set com.canonical.Unity.Panel systray-whitelist "['all']" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import os | |
if len(sys.argv) < 2: | |
print os.path.basename(sys.argv[0]), 'path' | |
sys.exit() | |
def handle_file(directory, file): | |
fullpath = os.path.join(directory, file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# github.com/kasun/YapDi.git | |
import yapdi | |
from BaseHTTPServer import BaseHTTPRequestHandler | |
from BaseHTTPServer import HTTPServer | |
import ssl | |
import sys | |
import os |