Skip to content

Instantly share code, notes, and snippets.

@jywsn
jywsn / git-submodules.md
Last active November 6, 2016 20:47
About git submodules

Summarized from https://git-scm.com/book/en/v2/Git-Tools-Submodules

Adding a submodule

Add an existing Git repository as a submodule of the repository:

$ git submodule add <subproject-repo-url>

The default is to add the subproject into a directory named the same as the repository. Also creates a new .gitmodules file, which is a configuration file that stores the mapping between the project’s URL and the local subdirectory you’ve pulled it into:

@jywsn
jywsn / install-pil-macos
Last active February 4, 2016 18:13
Installing PIL on Mac OS
Sure, you should use Pillow. But sometimes you want PIL. Directions tested on Mac OS 10.11.3 with Xcode 7.2.1.
Install Xcode command line tools, if needed:
$ xcode-select --install
Download the PIL source distribution (Imaging 1.1.7) from http://effbot.org/downloads#imaging. Do an in-place build, and run the self test before installing:
@jywsn
jywsn / fabfile.py
Last active August 29, 2015 14:10
Demonstration of fabric's hosts and roles when using execute()
"""
About fabric's hosts, roles, and execute()
See http://docs.fabfile.org/en/1.10/usage/execution.html
Per-task, command line roles will override role decorators:
fab setup testa:roles="a"
@jywsn
jywsn / twitter-auth-birdy.py
Created December 2, 2014 19:51
Twitter authorization using Birdy
import traceback
from flask import Flask, request, session, redirect, url_for
from birdy.twitter import UserClient
app = Flask(__name__)
TWITTER_CONSUMER_KEY = '...'
TWITTER_CONSUMER_SECRET = '...'
@app.route('/twitter/auth/')
@jywsn
jywsn / screenshots-python-capturejs-phantomjs.py
Last active August 29, 2015 14:10
screenshots - python, capturejs, phantomjs
"""
Install nodejs:
http:http://nodejs.org
On Ubuntu 12.x, you may need to do this:
sudo apt-get update
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:chris-lea/node.js
@jywsn
jywsn / d3-layout-stack-stream.js
Last active August 29, 2015 14:02
d3-layout-stack-stream
// Generate data. This needs to be an aray of arrays, where each array represents
// the data for one category. Within each category array, you need an object for
// each data value, which must contain x and y values.
var dataset = [];
var n = 5; // number of categories
var m = 100; // number of samples per category
for(var i = 0; i < n; i++) {
var category = [];
for(var x = 0; x < m; x++) {
@jywsn
jywsn / d3-layout-stack.js
Last active August 29, 2015 14:02
d3-layout-stack
// Data needs to be an aray of arrays, where each array represents the data for one category.
// Within each category array, you need an object for each data value, which must contain an x and a y value.
var dataset = [
[ // category 1
{ x: 0, y: 5 },
{ x: 1, y: 4 },
{ x: 2, y: 2 },
{ x: 3, y: 7 },
{ x: 4, y: 23 }
],