Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔
Not your keys, not your coins.

Steven Black StevenBlack

🤔
Not your keys, not your coins.
View GitHub Profile
@StevenBlack
StevenBlack / better-nodejs-require-paths.md
Created Sep 23, 2016 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js
View better-nodejs-require-paths.md

Better local require() paths for Node.js

Problem

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

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
StevenBlack / pr.md
Created Nov 7, 2015 — forked from piscisaureus/pr.md
Checkout github pull requests locally
View pr.md

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 = git@github.com:joyent/node.git

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
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
else
@hook.sethook( arg )
end
View resetDropbox.sh
#!/bin/sh
# Source: https://www.dropbox.com/en/help/72
# 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
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
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
*==========================
FUNCTION Init()
*==========================
SET CENTURY TO 20 ROLLOVER 50
SET CENTURY ON
View keybase.md

Keybase proof

I hereby claim:

  • I am StevenBlack on github.
  • I am stevenblack (https://keybase.io/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
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 + "google-analytics.com/ga.js", function(){
// tell Analytics about the current page load using standard _trackPageview method
try {
var pageTracker = _gat._getTracker( $.mcm.apiKeys.analytics );
// the standard page tracking code
pageTracker._trackPageview();
You can’t perform that action at this time.