Skip to content

Instantly share code, notes, and snippets.

View schinken's full-sized avatar

Christopher Schirner schinken

View GitHub Profile
myproject
- directoryX
- beautifulClass.py
- directoryY
- scriptThatNeedsBeautifulClass.py
import sys
(s,c,m,w,k,z,b)=("Easterhegg",0,int(sys.argv[1]),sys.stdout.write,0,lambda p:s[p%len(s)],[])
for v in [g for g in list(bin(0x471000)[2:].zfill(30)) for _ in range(m*2)]:
if not k%(5*m*2):b+=["\n"];w(''.join(b*m));b=[]
if int(v):b+=[" "]
else:b+=[z(c)];c+=1
k+=1
@schinken
schinken / gist:2351687
Created April 10, 2012 14:16
python modules
.
\_ server.py
\_ track
\_ __init__.py
\_ history.py (class history)
\_ downloader.py (class downloader)
server.py:
@schinken
schinken / gist:2439945
Created April 21, 2012 22:18
pil wrong colors
try:
im = Image.open( infile )
except IOError:
print "Cant load", infile
sys.exit(1)
curW, curH = size = im.size
def mapRange( val, min1, max1, min2, max2 ):
return (val-min1)/(max1-min1) * (max2-min2) + min2
def toGrayscale( rgb, steps = 3.0 ):
r, g, b = rgb
value = float( r + g + b ) / 3.0
value = mapRange( value, 0.0, 255.0, 0.0, steps )
Mode
The mode of an image defines the type and depth of a pixel in the image. The current
release supports the following standard modes:
1 (1-bit pixels, black and white, stored as 8-bit pixels)
L (8-bit pixels, black and white)
P (8-bit pixels, mapped to any other mode using a colour palette)
RGB (3x8-bit pixels, true colour)
works:
{'background': 255, 'extension': ('NETSCAPE2.0', 795), 'version': 'GIF89a', 'transparency': 255, 'duration': 70, 'loop': 0}
{'background': 0, 'extension': ('NETSCAPE2.0', 75), 'version': 'GIF89a', 'transparency': 14, 'duration': 70, 'loop': 0}
doesnt work:
{'background': 0, 'extension': ('NETSCAPE2.0', 123), 'version': 'GIF89a', 'transparency': 31, 'duration': 1500, 'loop': 0}
awesome.log:
------------
g_dbus_connection_real_closed: Remote peer vanished with error: Underlying GIOStream returned 0 bytes on an async read (g-io-error-quark, 0). Exiting.
awesome.err:
------------
rxvt: perl extension 'clipboard' not found in perl library search path
rxvt: perl extension 'clipboard' not found in perl library search path
import requests
url = 'https://webrelais.bckspc.de/relais/3'
if requests.get(url).json()['response']:
requests.delete(url)
else:
requests.post(url)
import requests
from flask import Flask
app = Flask(__name__)
@app.route("/")
def toggle():
url = 'https://webrelais.bckspc.de/relais/3'
if requests.get(url).json()['response']:
requests.delete(url)
else: