Want to create a Gist from your editor, the command line, or the Services menu? Here's how.
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
ּ_בּ | |
בּ_בּ | |
טּ_טּ | |
כּ‗כּ | |
לּ_לּ | |
מּ_מּ | |
סּ_סּ | |
תּ_תּ | |
٩(×̯×)۶ | |
٩(̾●̮̮̃̾•̃̾)۶ |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
/* How to select a range of children | |
* (Here, 3rd-7th children, inclusive): | |
*/ | |
ul li:nth-child(n+3):nth-child(-n+7) { | |
outline: 1px solid #0f0; | |
} |
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
// compare relative performance of tolower_ctype, tolower_openbsd, tolower_oraz functions | |
// result: 30.80, 30.51, 38.09 | |
// $ gcc -std=c99 -O3 -g -Wall -pedantic test_tolower.c -o test_tolower; | |
// $ valgrind --tool=callgrind ./test_tolower 1000000 | |
#include <assert.h> | |
#include <ctype.h> | |
#include <inttypes.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> |
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 sys | |
import time | |
def progressbar(it, prefix = "", size = 60): | |
count = len(it) | |
def _show(_i): | |
x = int(size*_i/count) | |
sys.stdout.write("%s[%s>%s] %i/%i\r" % (prefix, "="*x, "-"*(size-x), _i, count)) | |
sys.stdout.flush() |
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
""" media.py -- Stores any files in python code for binding | |
By Kenneth Reitz - MIT License | |
Example Usage: | |
# initialize mediapool | |
media.init() | |
#save a file to mediapool | |
media.save('test_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 | |
# -*- coding: utf-8 -*- | |
from decorator import decorator #http://pypi.python.org/pypi/decorator | |
@decorator | |
def trace(f, *args, **kwargs): | |
"""Print scope, call, and argument information.""" | |
_scope = inspect.getmodule(f).__name__ |
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 httplib | |
import urllib | |
import re | |
import os.path | |
def gist_write(name, content, ext=None, login=None, token=None): | |
if ext is None: | |
ext = os.path.splitext(name)[1] |
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 | |
# -*- coding: utf-8 -*- | |
"""Kenneth Reitz's GitHub Syncer | |
This script uses the GitHub API to get a list of all forked, mirrored, public, and | |
private repos in your GitHub account. If the repo already exists locally, it will | |
update it via git-pull. Otherwise, it will properly clone the repo. | |
It will organize your repos into the following directory structure: |
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 time | |
class Retry(object): | |
default_exceptions = (Exception) | |
def __init__(self, tries, exceptions=None, delay=0): | |
""" | |
Decorator for retrying function if exception occurs | |
tries -- num tries | |
exceptions -- exceptions to catch |
OlderNewer