Skip to content

Instantly share code, notes, and snippets.

View StevenBlack's full-sized avatar
🇨🇦

Steven Black StevenBlack

🇨🇦
View GitHub Profile
@StevenBlack
StevenBlack / crosstab.sql
Created May 12, 2016 02:39 — forked from romansklenar/crosstab.sql
PostgreSQL "pivot table" example using tablefunc extension
CREATE EXTENSION tablefunc;
CREATE TABLE sales(year int, month int, qty int);
INSERT INTO sales VALUES(2007, 1, 1000);
INSERT INTO sales VALUES(2007, 2, 1500);
INSERT INTO sales VALUES(2007, 7, 500);
INSERT INTO sales VALUES(2007, 11, 1500);
INSERT INTO sales VALUES(2007, 12, 2000);
INSERT INTO sales VALUES(2008, 1, 1000);
INSERT INTO sales VALUES(2009, 5, 2500);

Discussion on reddit.

Each of these commands will run an ad hoc http static file server in your current (or specified) directory. Use this power wisely.

Python 2.x

$ python -m SimpleHTTPServer 8000
@StevenBlack
StevenBlack / git.rb
Created June 2, 2013 22:20 — forked from alx/git.rb
Jekyll plugin to add Git activity inside a list
require 'git'
module Jekyll
class GitActivityTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
end
def render(context)
@StevenBlack
StevenBlack / vfpStackLister.prg
Created May 6, 2013 02:11
Visual FoxPro stack lister
LOCAL lnLvl, lcStack
lnLvl= PROGRAM( -1 )
lcStack = ""
FOR k= 1 TO lnLvl
lcStack = lcStack + PROGRAM( k )+ CHR( 13 )
ENDFOR
WAIT WINDOW lcStack
RETURN
@StevenBlack
StevenBlack / gist:5183757
Created March 17, 2013 21:35
ygktraffic twitter filter
ygktraffic -rt -from:ygktraffic -deevideo -thank -thanks -follow -nailaj -keeliesmama
@StevenBlack
StevenBlack / gist:5096982
Last active December 14, 2015 13:58
#YGKC twitter filter
#ygkc -rt -vieiraflytrap -wizfrenzy_03 -whiglive -989thedrive -983flyfm -instantfollowback -nailaj -ckws* -brenda_slomka -matt_bisson -robert_kiley -ottotrader -"Not tweeting or streaming" -InstantFollowBack -from:YGKRTs -nalaj
@StevenBlack
StevenBlack / Sites_Using_Jekyll.md
Last active December 11, 2015 01:08
Salvaged from the Jekyll repo as it seems maintainers there are apt to nix this.

Sites using Jekyll

It’s interesting to see what designs and features others have come up with. Link to Jekyll-powered blogs and other sites here.

@StevenBlack
StevenBlack / gist:4459239
Last active December 10, 2015 16:09
Bash script for the #YGK twitter hashtag. Uses the 't' command line client (a Ruby gem). This script uses Gist #4297661 to filter #ygk hashtag spam. https://gist.github.com/4297661
#!/bin/bash
# First install 't', the Twitter command line client: https://github.com/sferik/t#readme
# This is a Ruby gem and if you are on Mac OS X or any flavour of *nix you're probably got Ruby.
# Next ensure you have 'curl' installed (on Mac OS X you probably do)
# Given these two prerequisites then...
# Step 1: Grab the latest #ygk fluff filter from Gist #4297661 in raw form
@StevenBlack
StevenBlack / defaultsOptionsSettings.js
Created December 15, 2012 18:37
Shows the semantic difference between the terms "defaults", "options", and "settings". * A setting is what your program runs-with in this particular instance. * A default is what your program runs-with in the absence of a provided option. * An option is a user-provided value that overrides a default.
// assuming jQuery for its extend method.
// Calling program does this, and passes-in the options
var options = { validate: true, name: "bar" };
function myThing ( options ) {
// Internally your program does this
var empty = {}
var defaults = { validate: false, limit: 5, name: "foo" };
@StevenBlack
StevenBlack / preProcessPost.js
Created December 15, 2012 18:23
Generative function to create a method and corresponding Pre- and Post- hook methods,
c={}
e="someMethod";
preProcessPost =function(c,e) {
var e1=e+"Pre",e2=e+"Process",e3=e+"Post";
c[e]=function(o){
if (this[e1](o)) {
this[e2](o);
this[e3](o);
}
};