Skip to content

Instantly share code, notes, and snippets.

Ben Simpson bsimpson

Block or report user

Report or block bsimpson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
bsimpson / circleci.rb
Created Nov 15, 2019
CircleCI Artifact Retrieval via the API
View circleci.rb
# Finds a CircleCI job of a given name, and retrieves an artifact from a given CircleCI project build
# Usage:
# $ API_TOKEN=xxx GITHUB_USERNAME=bsimpson GITHUB_PROJECT=some-project TARGET_JOB=lighthouse ARTIFACT=averages_pageload ruby ./circleci.rb
require "net/http"
require "json"
LIMIT = 100
bsimpson / Vuex
Last active Sep 27, 2019
Proposal for Vuex Store Best Practices
View Vuex


  • Consistency - Standardize state/getter/mutation naming
  • Easier to read - less boilerplate by accessing literal properties without constants, reducing unnecessary getters
  • Organization - Any helper functions go inside getter/mutation/action context - not at top level


In Store

  • Create a property name on the state object with a default value
View Detecting a duplicate element in array
const array = [1,2,3,4,4];
function findDuplicate(inArr) {
inArr.reduce((sum, entity, idx) => {
sum[entity] = true;
if (Object.keys(sum).length != idx+1) {
throw `Duplicate found at index ${idx} in value ${entity}`;
return sum;
}, {});
bsimpson / gist:4088286
Created Nov 16, 2012
Rails and Javascript UTC timestamps
View gist:4088286


ActiveSupport.use_standard_json_time_format #=> true "Returns a JSON string representing the datetime. If ActiveSupport.use_standard_json_time_format is set to true, the ISO 8601 format is used." "If the time is in UTC, add a Z directly after the time without a space. Z is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "0930Z". "14:45:15 UTC" would be "14:45:15Z" or "144515Z"."

View gist:8360479
"name": "angularjs-seed",
"description": "A starter project for AngularJS",
"repository": "",
"devDependencies": {
"phantomjs": "~1.9",
"karma": "~0.10.4",
"karma-junit-reporter": "~0.1",
"karma-jasmine": "~0.1.3",
"karma-ng-scenario": "~0.1",
bsimpson / gist:8085774
Last active Jan 1, 2016
Helium filled HDD Cost Savings
View gist:8085774
Cost per kWh:
GA $12.17
MA $15.86
Kilowatt = 1000 Watts
Watt = The unit, defined as one joule per second, measures the rate of energy conversion or transfer.
Press release on energy savings:
bsimpson / gist:6768393
Created Sep 30, 2013
run, do, perform method rename to call
View gist:6768393
class Foo
def self.perform(foo)
puts foo
Foo.perform('foo') # => 'foo'
class Foo
bsimpson / gist:5915421
Created Jul 3, 2013
Salt and Pepper Tofu Recipe
View gist:5915421


Salt and Pepper Tofu on Spinach Fettuccini bed Feeds 2 Prep time 5 minutes Cook time 10 minutes


Boil 4-5 spinach fettuccini nests in boiling water with salt (to taste) and olive oil (to keep from sticking)

bsimpson / gist:5826663
Created Jun 20, 2013
Xor custom validation
View gist:5826663
validate :foo
def foo
errors[:base] << 'Nope' unless true ^ true
bsimpson / gist:5207880
Last active Dec 15, 2015
Git - See a file even after a hard reset
View gist:5207880


I make changes to a file, and then subsequently reset my branch using git reset --hard to origin. I want to recover the contents of that file, even after a hard reset

Finding the revision before the reset

git reflog | grep <branch name>

Look for an entry like b65de9d HEAD@{75}: reset: moving to origin/<branch name>. This is the point at which you reset your branch to origin. You want to use the point before that revision (e.g. increment the number by one to go back in history just before). In this case, it would be HEAD@{76}.

You can’t perform that action at this time.