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
#!/bin/bash | |
for dir | |
do | |
pushd $dir | |
STASHED=false | |
BRANCH=false | |
if [[ -n $(git status --porcelain) ]] | |
then | |
git stash |
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
// morse.go | |
// usage: | |
// go run morse.go "SOS" > sos.au | |
package main | |
import ( | |
"encoding/binary" | |
"fmt" | |
"io" |
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
# -*- coding: utf-8 -*- | |
print '₂₀₁₄' |
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 | |
import os | |
import logging | |
from threading import Thread | |
from django.core.management.base import BaseCommand, CommandError | |
from django.conf import settings |
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
# vim: ft=sh | |
unbind C-b | |
set -g prefix ` | |
bind-key ` send-prefix | |
bind j select-pane -t :.+ | |
bind k select-pane -t :.- | |
set -sg escape-time 1 | |
set -g default-terminal "rxvt-unicode" | |
setw -g mode-mouse on |
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
from hashlib import sha256 | |
def mine_block(message, target, prev_block=''): | |
""" | |
use the message and previous block to generate a new block | |
""" | |
nonce = 0 | |
if prev_block: | |
message = '%s\n%s' % (message, prev_block) |
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
>>> from django.contrib.auth.forms import UserCreationForm | |
>>> form = UserCreationForm({'username': 'admin123', 'password1': 's3cr3t', 'password2': 's3cr3t'}) | |
>>> form.is_valid() | |
True | |
>>> form.data['username'] = '' | |
>>> form.is_valid() | |
True | |
>>> form._errors = None | |
>>> form.is_valid() | |
False |
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
class ImportFieldForm(LazyModelForm): | |
label = forms.ChoiceField(choices=(), required=False) | |
header = forms.ChoiceField(choices=(), required=False, error_messages={'valid': 'Please choose a star rating'}) | |
class Meta: | |
model = ImportField | |
def __init__(self, *args, **kwargs): | |
self.labels = kwargs.pop('labels') | |
self.headers = kwargs.pop('headers') | |
self.helper = FormHelper() |
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
>pip install kivy | |
Downloading/unpacking kivy | |
Running setup.py egg_info for package kivy | |
[INFO ] Kivy v1.4.1 | |
Found GLES 2.0 headers at /usr/include/GLES2/gl2.h | |
Installing collected packages: kivy | |
Running setup.py install for kivy | |
[INFO ] Kivy v1.4.1 | |
Found GLES 2.0 headers at /usr/include/GLES2/gl2.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
package main | |
import "fmt" | |
import "tour/tree" | |
// Walk walks the tree t sending all values | |
// from the tree to the channel ch. | |
func Walk(t *tree.Tree, ch chan int) { | |
_Walk(t, ch) | |
close(ch) |