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 scrapeMeta import scrapeMeta | |
import os | |
import json | |
from bs4 import BeautifulSoup | |
import urllib | |
def getHTML(url): | |
html = urllib.urlopen(url).read() | |
return BeautifulSoup(html) |
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 requests | |
import datetime | |
import sys | |
# Pass your OAuth token | |
token = sys.argv[1] | |
# Fetch all private repos (lazy - assumes only two pages) | |
headers = {'Authorization': 'token %s' % token} | |
response = requests.get( |
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 with_statement | |
from fabric.api import env, run, settings, hide | |
from fabric.decorators import hosts, runs_once | |
venv = "/home/websites/.virtualenvs/twtv3/" | |
env.user = 'webdev' | |
env.hosts = [ | |
'192.168.1.10', | |
'192.168.1.11', |
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
alias gs='git status' | |
alias gai='git add --interactive' | |
alias gsvn='git svn' | |
alias gsup='gsvn fetch && gsvn rebase' | |
alias gsp='gsup && gsvn dcommit' | |
alias gf='git fetch' | |
alias gr='git rebase' | |
alias gp='gup && git push' | |
alias gff='git flow feature' | |
alias gfr='git flow release' |
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
def curry(f, *args, **kwargs): | |
def curried(*more_args, **more_kwargs): | |
return f(*(args+more_args), **dict(kwargs, **more_kwargs)) | |
return curried | |
class Person(object): | |
def __init__(self, name, gender): | |
self.name = name | |
self.gender = gender |
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
;[program:andrewingram-gunicorn] | |
;command=/var/www/andrewingram.net/bin/gunicorn_django /var/www/andrewingram.net/src/andrewingram/andrewingram/settings.py | |
;directory=/var/www/andrewingram.net | |
;logfile=/var/www/andrewingram.net/log/supervisor.log | |
;user=deployer | |
;autostart=true | |
;autorestart=true | |
;redirect_stderr=True | |
[program:andrewingram-uwsgi] |
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
defmodule Gravatar do | |
@base_url "https://secure.gravatar.com/avatar/" | |
@doc """ | |
Will get the corresponding gravatar url for a given email address. Options | |
can be passed in using a keyword list or a map. | |
iex> Gravatar.url("martin@gausby.dk", size: 200) | |
https://secure.gravatar.com/avatar/0e6a9f19e77fa18bf6f185258f2507d6?size=200 |
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.forms.models import model_to_dict | |
class ModelDiffMixin(object): | |
""" | |
A model mixin that tracks model fields' values and provide some useful api | |
to know what fields have been changed. | |
""" | |
def __init__(self, *args, **kwargs): |
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
# -*- c-basic-offset: 2; indent-tabs-mode: nil -*- | |
defmodule Score.ContactTest do | |
use Score.TestCase | |
@joe %{name: "joe", email: "joe@vipaar.com", sign_in_count: 0} | |
@joe_changeset User.changeset(%User{}, :create, @joe) | |
@bob %{name: "bob", email: "bob@vipaar.com", sign_in_count: 0} | |
@bob_changeset User.changeset(%User{}, :create, @bob) | |
setup do |
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
""" | |
Utilities for working with bulk data and batches. | |
""" | |
import itertools | |
def batches(items, batch_size=500): | |
""" | |
Given an iterable of items and a batch size, yield individual lists | |
of items of maximum length `batch_size`. |
OlderNewer