This file contains hidden or 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
| from feedparser import parse | |
| def refresh_every(number_of_connections, url): | |
| """ | |
| This is an iterator that caches the result of the feed for | |
| self.number_of_connections number of calls, before refreshing url. | |
| """ | |
| count = 0 | |
| data = parse(url).entries | |
| while True: |
This file contains hidden or 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 memoize(obj): | |
| """ | |
| Usage: | |
| @memoize | |
| def my_func(): | |
| ... | |
| """ | |
| cache = obj.cache = {} | |
| @functools.wraps(obj) |
This file contains hidden or 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 | |
| import urllib2 | |
| import string | |
| def clean_path(p): | |
| cleaned = p[1:-1].split(".html")[0].split("index")[0] | |
| return cleaned if cleaned[-1] == "/" else "%s/" % cleaned | |
This file contains hidden or 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 pyb | |
| def set_state(): | |
| n = int(pyb.rng() / 2**30 * 6) + 1 | |
| [pyb.LED(l).off() for l in range(1,4)] | |
| byte_list = list(str(bin(n))[2:]) | |
| byte_list.reverse() | |
| for led, byte in enumerate(byte_list): | |
| if int(byte): | |
| pyb.LED(int(led) + 1).on() |
This file contains hidden or 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
| commit () { | |
| bzr pull && bzr commit -m "$1" && bzr push | |
| } |
This file contains hidden or 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 org.gnome.desktop.wm.keybindings switch-to-workspace-1 "['<alt>1']" | |
| gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-2 "['<alt>2']" | |
| gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-3 "['<alt>3']" | |
| gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-4 "['<alt>4']" | |
| gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-1 "['<alt><shift>1']" | |
| gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-2 "['<alt><shift>2']" | |
| gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-3 "['<alt><shift>3']" | |
| gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-4 "['<alt><shift>4']" |
This file contains hidden or 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
| function chpwd() { │ | |
| emulate -L zsh │ | |
| tree --dirsfirst -L 1 `pwd` > ~/.current_tree │ | |
| } |
This file contains hidden or 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
| LOGGING = { | |
| 'version': 1, | |
| 'disable_existing_loggers': False, | |
| 'handlers': { | |
| 'error_file': { | |
| 'level': 'WARNING', | |
| 'filename': os.path.join(BASE_DIR, 'django-error.log'), | |
| 'class':'logging.handlers.RotatingFileHandler', | |
| 'maxBytes': 1 * 1024 * 1024, | |
| 'backupCount': 2 |
This file contains hidden or 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
| { | |
| "metadata": { | |
| "name": "", | |
| "signature": "sha256:fccf17e183ef75a5b0b1c58e43cf8dec8aeeb1ee0fb3f6745ba8111fd173b7ea" | |
| }, | |
| "nbformat": 3, | |
| "nbformat_minor": 0, | |
| "worksheets": [ | |
| { | |
| "cells": [ |
This file contains hidden or 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 locally-hosted web page listing all open http servers. | |
| Requirements: | |
| nmap (apt-get install nmap) | |
| sh, werkzeug (pip install sh, werkzeug) | |
| """ | |
| from werkzeug.wrappers import Request, Response | |
| from sh import nmap | |
| print " * Running nmap..." |