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 __future__ import division | |
from operator import mul | |
def Q(n): | |
""" | |
Let Q(n) be the probability that | |
no two people have a common birthday. | |
""" |
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
(function() { | |
// This is a new closure. If things that happen here don't have side-effects on outside scope, | |
// then whatever happens here will not be visible outside of it. | |
(function() { | |
// You can make closures inside of closure (inside of closures). Wee. | |
})(); | |
})(); | |
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/osascript | |
# vim: set syntax=applescript | |
(* | |
Launch multiple commands in iTerm2 split views | |
inspired by github.com/xgdlm/iterm2-cssh. | |
Usage: |
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
# | |
# Opbeat is looking for the best CLI syntax for the `opbeat' | |
# command that sends deployment info to the Opbeat API. | |
# | |
# Users should be able to specify repositories that the app being deployed | |
# consists of and their attributes. | |
# | |
# The attributes are "name", "version", "vcs", "rev", "branch", "remote_url". | |
# | |
# We are considering these syntaxes: |
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/sh | |
# | |
# Delete Python's compiled *.pyc and __pycache__ files like a pro | |
# https://gist.github.com/jakubroztocil/7892597 | |
# | |
# Usage: | |
# Delele *.pyc and __pycache__ files recursively in the current directory: | |
# $ pyc | |
# | |
# The same, but under /path: |
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 httpie | |
$ echo 'fake partial download' > /tmp/test | |
$ http --verbose --download --continue --output=/tmp/test https://dl.dropboxusercontent.com/s/prxxcgndysv13t1/httpie.png | |
GET /s/prxxcgndysv13t1/httpie.png HTTP/1.1 | |
Accept: */* | |
Host: dl.dropboxusercontent.com | |
Range: bytes=22- | |
User-Agent: HTTPie/0.8.0 |
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
VERSION="3.4.1" | |
yum -y install gcc openssl-devel | |
rm -rf Python-${VERSION}* | |
wget https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tgz | |
tar -xvzf Python-${VERSION}.tgz | |
cd Python-${VERSION} | |
./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" | |
echo "/usr/local/lib" > /etc/ld.so.conf.d/custom-python.conf | |
make && make altinstall |
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
# models.py | |
from django.core.exceptions import ValidationError | |
from django.core.validators import EmailValidator | |
from django.db.models.signals import pre_save | |
from django.contrib.auth.models import User | |
def _user_clean(user): | |
""" | |
Require the value of `username` to be an email. The `email` field |
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
- name: Verify GitHub SSH login | |
tags: | |
- debug | |
- deploy | |
shell: | | |
ssh_output=$(ssh -T [email protected] &>/dev/stdout) | |
echo | |
echo Should not be empty: | |
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" |
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
The regex patterns in this gist are intended only to match web URLs -- http, | |
https, and naked domains like "example.com". For a pattern that attempts to | |
match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502 | |
# Single-line version: | |
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|s |
OlderNewer