Skip to content

Instantly share code, notes, and snippets.

import urllib
import requests
API_URL = 'http://is.gd/api.php?longurl='
def shorten(uri):
resp = requests.get(API_URL + urllib.quote(uri), timeout=30)
if resp:
return resp.text
starenka@kosmik1:~$ rhino -e 'print(1+.99)'
1.99
starenka@kosmik1:~$ rhino -e 'print(7+.99)'
7.99
starenka@kosmik1:~$ rhino -e 'print(7+5.99)'
12.99
starenka@kosmik1:~$ rhino -e 'print(7+15.99)'
22.990000000000002
starenka@kosmik1:~$ rhino -e 'print(7+25.99)'
32.989999999999995
#!/usr/bin/env python
import string, re
import requests
URL_LIST = 'http://www.bestoldgames.net/abc/%s.php'
URL_DL = 'http://www.bestoldgames.net/download/bgames/%s.zip'
RE_HREF = re.compile(r'<a href="/stare-hry/(.*?).php">')
urls = []
#!/usr/bin/env python
import time
from pyquery import PyQuery as pq
def do():
doc = pq('http://www.volby.cz/pls/prez2013/pe2?xjazyk=CZ')
perc = map(lambda x: float(x.text.replace(',','.')), doc.find('table.left2 td.cislo[headers="s2a6 s2b5"]'))
names = map(lambda x: x.text, doc.find('table.left2 td[headers="s2a1 s2b2"]'))
@starenka
starenka / volby2.py
Last active December 11, 2015 18:29
#!/usr/bin/env python
import time
from pyquery import PyQuery as pq
while True:
def to_float(text):
return float(text.text.replace(',', '.'))
doc = pq(url='http://www.volby.cz/pls/prez2013/pe2?xjazyk=CZ')
starenka /opt/awesome-3.5 % DISPLAY=:1.0 /opt/awesome-3.5/awesome -c ~/.config/awesomedbg/rc.lua [73% 04:44:03]
/home/starenka/.config/awesomedbg/rc.lua:2: module 'awful' not found:
no field package.preload['awful']
no file './awful.lua'
no file '/usr/local/share/lua/5.1/awful.lua'
no file '/usr/local/share/lua/5.1/awful/init.lua'
no file '/usr/local/lib/lua/5.1/awful.lua'
no file '/usr/local/lib/lua/5.1/awful/init.lua'
no file '/usr/share/lua/5.1/awful.lua'
no file '/usr/share/lua/5.1/awful/init.lua'
#!/bin/bash
cat links | xargs -P 10 -r -n 1 wget --user=mujlogin --password=mojehslicko --auth-no-challenge --header="User-Agent: UFM 1.6" -nv -v
find -name "*\-avi" | while read line; do new=`echo "$line" | sed -e 's/\-avi/\.avi/g'`; mv $line $new; done
find -name "*\-mkv" | while read line; do new=`echo "$line" | sed -e 's/\-mkv/\.mkv/g'`; mv $line $new; done
find -name "*\-mp4" | while read line; do new=`echo "$line" | sed -e 's/\-mp4/\.mp4/g'`; mv $line $new; done
find -name "*\-rar" | while read line; do new=`echo "$line" | sed -e 's/\-rar/\.rar/g'`; mv $line $new; done
>>> one = {}
>>> type(one)
<type 'dict'>
>>> two = {
...
...
...
... }
>>> type(two)
<type 'dict'>
'''
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
...
1 bottle of beer on the wall, 1 bottle of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
'''
@starenka
starenka / historje
Created October 5, 2013 11:27
fetches all images from http://historje.tumblr.com and makes a pdf from them
#!/usr/bin/env python
from pyquery import PyQuery as pq
import requests
bigs = []
for y in (2012,2013):
for m in range(1,13):
try:
doc = pq(requests.get('http://historje.tumblr.com/archive/%d/%d' % (y,m)).content)