Skip to content

Instantly share code, notes, and snippets.


Steven Black StevenBlack

View GitHub Profile
StevenBlack /
Created Sep 23, 2016 — forked from branneman/
Better local require() paths for Node.js

Better local require() paths for Node.js


When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

StevenBlack / crosstab.sql
Created May 12, 2016 — forked from romansklenar/crosstab.sql
PostgreSQL "pivot table" example using tablefunc extension
View crosstab.sql
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);
StevenBlack /
Last active Dec 7, 2015
Suggestion for Github's Issues UI.

I have a suggestion for the Github UI in Issues.

Currently in Issues: one types Issue #17 or just #17 and this resolves to a link of the Issue. This is great!

Cool suggestion: Use of the existing Issue mini icon so the link rendering looks like this, where the current state of the issue is displayed.

Bonus Points: Hovering on the Issue link displays the Issue title in a tooltip.

StevenBlack /
Created Nov 7, 2015 — forked from piscisaureus/
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

StevenBlack / hooks.rb
Last active Aug 29, 2015
Basic hooks and anchors in Ruby.
View hooks.rb
class AbstractHook
@oHook = nil
def sethook( *args )
args.each { |arg|
if @hook.nil?
@hook = arg
@hook.sethook( arg )
# Source:
# Terminate Dropbox, then...
sudo chflags -R nouchg ~/Dropbox ~/.dropbox ~/.dropbox-master
sudo chown "$USER" "$HOME"
sudo chown -R "$USER" ~/Dropbox ~/.dropbox ~/.dropbox-master
sudo chmod -RN ~/.dropbox ~/Dropbox ~/.dropbox-master
StevenBlack / gist:f5501b42dce78b047824
Last active Aug 29, 2015 — forked from Greyvy/gist:8872903
Arbitrary data passed to Jekyll partials
View gist:f5501b42dce78b047824
<!-- partial.html -->
<div class="Tile">
{% if include.title %}
<h1>{{ include.title }}</h1>
{% else %}
<h1>no content!</h1>
{% endif %}
</div><!-- .Tile -->
<!-- in any template, partial, layout or content file -->
StevenBlack / sessionfactory.prg
Last active Jun 22, 2016
SessionFactory creates objects that are wrapped in a private data session. Note that the factory can die but its private datasession lives until all its products are out of scope.
View sessionfactory.prg
DEFINE CLASS SessionFactory AS Session
DataSession = 2 && private

Keybase proof

I hereby claim:

  • I am StevenBlack on github.
  • I am stevenblack ( on keybase.
  • I have a public key whose fingerprint is 1C52 CB4A 3BD9 EC28 E1BC DF99 8BC4 854E C83F 6EC6

To claim this, I am signing this object:

StevenBlack / GA-Events.js
Last active Sep 27, 2019
Google Analytics Events Example
View GA-Events.js
// Upon document ready, have jQuery do the following
$( function(){
var gaJsHost = ( ( "https:" === document.location.protocol ) ? "https://ssl." : "http://www." );
// use jQuery to call the Google Analytics JavaScript
$.getScript( gaJsHost + "", function(){
// tell Analytics about the current page load using standard _trackPageview method
try {
var pageTracker = _gat._getTracker( $ );
// the standard page tracking code