This attempts to be a useful "cheat sheet" for git. I'm just writing git recipes down here as I find and use them.
Clone a repository (GitHub)
git clone git@github.com:username/repository.git
| class FibonacciIterator(object): | |
| def __init__(self): | |
| self.data = [0, 1] | |
| def next(self): | |
| self.data.append(sum(self.data)) | |
| return self.data.pop(0) | |
| class Fibonacci(object): | |
| def __iter__(self): | |
| return FibonacciIterator() |
I wrote a Python script to fetch these URLs using the GitHub API.
| #define NORTH 0 | |
| #define SOUTH 1 | |
| #define EAST 2 | |
| #define WEST 3 | |
| typedef struct { | |
| int width; // width of the 2-D tape | |
| int height; // height of the 2-D tape | |
| int states; // number of states | |
| int symbols; // number of symbols |
| def distinct(iterable, keyfunc=None): | |
| seen = set() | |
| for item in iterable: | |
| key = item if keyfunc is None else keyfunc(item) | |
| if key not in seen: | |
| seen.add(key) | |
| yield item | |
| if __name__ == '__main__': | |
| x = [0, 0, 1, 0, 1, 2, 2, 1, 0] |
| from itertools import izip, product | |
| import wx | |
| BITS = 6 | |
| SIZE = int(((2 ** BITS) ** 3) ** 0.5) | |
| STEP = 2 ** (8 - BITS) | |
| def color_func(color): | |
| r, g, b = color | |
| r, g, b = 0.30 * r, 0.59 * g, 0.11 * b |
| import wx | |
| class View(wx.Panel): | |
| def __init__(self, parent): | |
| super(View, self).__init__(parent) | |
| self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) | |
| self.Bind(wx.EVT_SIZE, self.on_size) | |
| self.Bind(wx.EVT_PAINT, self.on_paint) | |
| self.Bind(wx.EVT_CHAR_HOOK, self.on_char) | |
| self.bitmap = None |
| import random | |
| import wx | |
| SIZE = 4096 | |
| LOOKUP = [ | |
| [0, 1, 4, 5, 2, 3, 6, 7], | |
| [1, 0, 5, 4, 3, 2, 7, 6], | |
| [2, 3, 6, 7, 0, 1, 4, 5], | |
| [3, 2, 7, 6, 1, 0, 5, 4], |
| from math import sin, cos, radians | |
| import cairo | |
| import random | |
| import re | |
| class System(object): | |
| def __init__(self, rules): | |
| self.rules = rules | |
| self.pattern = re.compile('|'.join('(%s)' % x for x in rules)) | |
| def step(self, value): |