Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View leigh-johnson's full-sized avatar
💜

Leigh Johnson leigh-johnson

💜
View GitHub Profile
@leigh-johnson
leigh-johnson / rakefile.rb
Last active August 29, 2015 14:05
Add HPSTR fields to rake new_post()
desc "Begin a new post in #{source_dir}/#{posts_dir}"
task :new_post, :title do |t, args|
if args.title
title = args.title
else
title = get_stdin("Enter a title for your post: ")
end
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
mkdir_p "#{source_dir}/#{posts_dir}"
filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
@leigh-johnson
leigh-johnson / phaser-game-resize
Created January 6, 2015 00:33
OnEvent resize + handler to dynamically resize WebGL & Canvas element in Phaser.js
//add to game init
$(window).resize(function() { window.resizeGame(); } );
//add this function to main.js
function resizeGame() {
var height = $(window).height();
var width = $(window).width();
@leigh-johnson
leigh-johnson / main.py
Created February 5, 2015 16:08
Wellness Security leads data
import os
import csv
import itertools
import re
_PATH = ''
export_headers = (
'Home Phone',
'Street Address',
@leigh-johnson
leigh-johnson / gist:036431a26738c071020e
Last active August 29, 2015 14:26
photoshop-toggle-blendmode.js
// store current layer of active document
var activeLayer = app.activeDocument.activeLayer;
function toggleAll(layer) {
// determine state
split = (layer.name).split(' ');
if ('*working*' in split){
// recover the mode from *working* layer name
layer.blendMode = BlendMode[split[-1]];
def returnOddIntsEvenIndex(a):
for i in range(a):
if x % 2 > 0:
# index is odd, test type, return if odd
if isinstance(a[i], int):
yield a[i]
else:
# index is even, return always
yield a[i]
_
/~_) /'
~-/'-~ /'
/' ____ O ____ /'__
/' /' ) /' /' ) /' )
/~\,' _ /(___,/' /' /' /' /' /'
(,/'`\____)(________(__(___,/(__/' /(__
/'

Keybase proof

I hereby claim:

  • I am leigh-johnson on github.
  • I am grepleigh (https://keybase.io/grepleigh) on keybase.
  • I have a public key ASDihIe0IMy0QLJutA7tM_MJL3NNUiN8XUpZl-bk1QZZ9Qo

To claim this, I am signing this object:

@leigh-johnson
leigh-johnson / patch-tools.js
Last active July 31, 2016 22:32
Functional monkey patching in javascript
// Remember: With great power comes great responsibility
/* Runtime Hooks */
// Run patcher fn before the original function invocation
// aArgs - array / node list of arguments
function before(fn){
return function(original){
fn.apply(this, aArgs)
return original.apply(this, aArgs)
@leigh-johnson
leigh-johnson / destructuring.js
Created September 17, 2016 05:55 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
const https = require('https');
const url = require('url');
const slack_url = 'your_slash_url';
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {
'Content-Type': 'application/json'
};
exports.handler = function(event, context) {