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
# ~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
#!/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
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
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
import unittest | |
class myTest(unittest.TestCase): | |
def testTest(self): | |
self.assertTrue(True) | |
self.assertFalse(False) | |
self.assertEquals(1,1) | |
tests = unittest.TestSuite() | |
tests.addTest(unittest.makeSuite(myTest)) |
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
import os | |
#Nii funkab ka | |
def get_filename(value): | |
if isinstance(value, basestring): | |
i = max(value.rfind('/'), value.rfind('\\')) | |
if i > 0: | |
value = value[i+1:] | |
return value |
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
limit_arguments = { | |
'peer-limit': int(config.get('peer-limit', 30)), | |
'uploadLimit': int(config.get('uploadLimit', 25)), | |
'uploadLimited': [False,True][int(config.get('uploadLimit', 25)) > 0], | |
'seedRatioLimit':float(config.get('seedRatioLimit', 1.5)), | |
'seedRatioMode':[0,1][float(config.get('seedRatioLimit', 1.5)) > 0], | |
'seedRatioLimited':[False,True][float(config.get('seedRatioLimit', 1.5)) > 0], | |
'ids':[] | |
} | |
... |
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
a = """ | |
tekst | |
%s | |
tekst | |
%s | |
""" % (1,2) | |
#or | |
a = """ |
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
Number.prototype.formatMoney = function(c, d, t){ | |
var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; | |
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); | |
}; | |
document.write((123456.78).formatMoney(2, ',', ' ')) //123 456,78 |