Skip to content

Instantly share code, notes, and snippets.

View dvonlehman's full-sized avatar

David Von Lehman dvonlehman

  • Seattle, WA
View GitHub Profile
@dvonlehman
dvonlehman / git-shell-aliases.sh
Last active July 6, 2020 18:58
Some handy custom git shell commands
# Add these functions to your shell profile, i.e. ~/.bash_profile or ~/.zshrc
# Delete local branches that no longer exist in the remote
function git-branch-cleanup {
git fetch -p && for branch in `git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'`; do git branch -D $branch; done
}
# Display the branches in the order you last worked on them
# https://stackoverflow.com/a/2514279/446542
function git-branch-history {
{
"name": "my-react-project",
"version": "1.0.0",
"scripts": {
"build": "node_modules/.bin/awesome-build build react es2015 sass ./dist",
"watch": "node_modules/.bin/awesome-build watch react es2015 sass"
},
"devDependencies": {
"awesome-build": "^x.x.x"
},
@dvonlehman
dvonlehman / AddContact.jsx
Last active April 22, 2016 07:10
React without flux or redux complexity
import React from 'react';
import request from 'superagent';
// This import syntax requires the babel transform-export-extensions plugin
import dispatcher, {actions} from '../lib/dispatcher';
export default class AddContact extends React.Component {
submitHandler(event) {
request.post('/api/contacts')
.send({
firstName: this.refs.firstName.value,
@dvonlehman
dvonlehman / gulpfile.js
Last active January 19, 2016 00:17
lambda deploy gulpfile
var gulp = require('gulp');
var zip = require('gulp-zip');
var del = require('del');
var install = require('gulp-install');
var runSequence = require('run-sequence');
var awsLambda = require("node-aws-lambda");
gulp.task('clean', function(cb) {
del(['./dist', './dist.zip'], cb);
});
@dvonlehman
dvonlehman / 0_reuse_code.js
Last active October 16, 2015 17:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dvonlehman
dvonlehman / node class export template
Last active December 28, 2015 19:09
Template for exporting a class in a node module based on Crockford: http://javascript.crockford.com/private.html
var util = require("util"),
BaseThing = require("./base_thing");
// Constructor function
var Thing = module.exports = function(attrs){
this.attrs = attrs;
// Priveleged method can be invoked by public methods
this.privelegedMethod = function() {
}
from PIL import Image
import math
import glob
width, height = [165, 254]
files = glob.glob('./photos/*.jpg')
num_columns = 5
canvas_width = num_columns * width
canvas_height = int(math.ceil(len(files) / float(num_columns))) * height