Skip to content

Instantly share code, notes, and snippets.


Stephen Benner SteveBenner

View GitHub Profile
pketh /
Last active Nov 21, 2020
Promises in Coffeescript
# Create a promise:
myCoolPromise = new Promise (resolve, reject) ->
# do a thing
success = true
if success
resolve 'stuff worked'
reject Error 'it broke'
robd / bundle_gem_libs.rb
Last active Oct 27, 2017
Rubymine bundle dependencies
View bundle_gem_libs.rb
# This script is to work round the problem of broken RubyMine dependencies for bundle files.
# It uses an undocumented feature for RubyMine (but available in Intellij Idea) to create a
# gems library xml file and update the iml file.
# See Rubymine issues:
# Usage:
ttscoff / cdt.bash
Created Jun 12, 2014
cdt function to change directory based on a tag filing system
View cdt.bash
# In my tag-filing system where top-level "context" folders are tagged with
# "=Context" tags and subfolders are tagged with "@project" tags, this function
# lets me quickly cd to any tagged folder in my filing system. The first
# argument is a context folder, the rest are a chain of subfolders. The
# subfolders don't need to be contiguous, and the matching is fuzzy.
cdt() {
local fuzzy
local root
local sub
local list
SteveBenner / unbrew.rb
Last active Dec 4, 2020
Homebrew uninstall script
View unbrew.rb
#!/usr/bin/env ruby
# CLI tool for locating and removing a Homebrew installation
# Copyright (C) 2014 Stephen C. Benner
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
View gist:9919357

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by
  • pry -r ./config/environment.rb - load your rails into a pry session


brandonb927 / gist:9587436
Created Mar 16, 2014
Simple JSON database with Node.JS
View gist:9587436


I've written numerous tiny databases. They don't have much features, but they don't need much features. Usually I'm looking for fast simple key/value stores and Node never disappoints. The point here is, why abstract key value store when JS gives us one for free, as it's most basic component: object.

Will it meet every need? No. But it will meet ALOT of scenarios.

In memory JS object lookups, were talking hundreds of thousands of lookups (you'll easily flood http before the db), and save hundreds of thousands of records in a JSON file written to disk. Not a 200ms r/t to some hosted Redis. Hey, that's fine if that's your thing.

Here's the requirements:

DanHerbert /
Last active Dec 27, 2020
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

READ THIS Very Important Update

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

tracend / common.loading.css
Last active Dec 29, 2018
CSS3 Loading Overlay
View common.loading.css
body.loading:after {
/* with no content, nothing is rendered */
content: "";
position: fixed;
/* element stretched to cover during rotation an aspect ratio up to 1/10 */
top: -500%;
left: -500%;
right: -500%;
bottom: -500%;
z-index: 9999;
ttscoff / Marker.js
Created Dec 22, 2013
Bookmarklet for Markdownifying webpage selections
View Marker.js
// Marker, a bookmarklet for Markdownifying webpage selections
// javascript:(function(){var p=document.createElement("p");p.innerHTML="<strong>Loading&hellip;</strong>";"loadingp";"20px";"#fff";"20px";;"fixed";"9999999";".85";document.body.appendChild(p);document.body.appendChild(document.createElement("script")).src=""+(Math.random());})();
(function () {
function callback() {
(function ($) {
var raw, userSelection;
if (window.getSelection) {
// W3C Ranges
userSelection = window.getSelection ();
// Get the range:
yyx990803 / starcounter.js
Last active Dec 16, 2020
Count your total stars!
View starcounter.js
var https = require('https'),
user = process.argv[2],
opts = parseOpts(process.argv.slice(3))
request('/users/' + user, function (res) {
if (!res.public_repos) {
var pages = Math.ceil(res.public_repos / 100),
You can’t perform that action at this time.