Skip to content

Instantly share code, notes, and snippets.

<% const flattenPublicJSON = (obj = {}, res = [], extraKey = '/') => {
for(key in obj){
if(Array.isArray(obj[key])){
flattenPublicJSON(obj[key], res, `${extraKey}`);
}else if(key === '_contents'){
res.push(`${extraKey}/${obj[key]}`);
} else if(key === '_data'){
//ignore
} else if(typeof obj[key] !== 'object'){
res.push(`${extraKey}${obj[key]}`);
@handerson
handerson / rom_name_fix.rb
Created August 27, 2016 03:14
Fixes NDS rom names for use with R4 cards
#!/usr/bin/env ruby
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.on('-d n', '--directory=n', 'Set Directory') do |d|
options[:directory] = d
end
opts.on('-h', '--help', 'Displays Help') do
@handerson
handerson / codeclimate_averages.rb
Last active September 4, 2015 03:02
Calculates an organization's average test coverage & gpa from codeclimate
require 'net/http'
require 'json'
token = ''
uri = URI('https://codeclimate.com/api/repos?api_token=' + token)
response = Net::HTTP.get(uri)
repos = JSON.parse(response)
test_coverage = []
var HighResolutionTimer = window.HighResolutionTimer = window.HighResolutionTimer || (function() {
var HighResolutionTimer = function(options) {
this.timer = false;
this.total_ticks = 0;
this.start_time = undefined;
this.current_time = undefined;
@handerson
handerson / combox.js
Last active August 29, 2015 14:03
Basic Select/Input Combo box
// Add a class of "combox" to a select element to activate
function clonePosition(elementToMove, elementToClone){
var $elementToClone = $(elementToClone);
var position = $elementToClone.position();
var top = position.top;
var left = position.left;
var width = $elementToClone.width() - 40;
$(elementToMove).css({"position": "absolute", "top": top, "left": left, "width": width});

Keybase proof

I hereby claim:

  • I am handerson on github.
  • I am heathanderson (https://keybase.io/heathanderson) on keybase.
  • I have a public key whose fingerprint is 69FE B984 7C01 0847 BB07 5CE5 36F7 C6C8 8A01 EA2C

To claim this, I am signing this object:

require 'gollum/frontend/app'
require 'digest/sha1'
class App < Precious::App
User = Struct.new(:name, :email, :password_hash)
before { authenticate! }
helpers do
def authenticate!
@handerson
handerson / LICENSE
Created May 15, 2012 16:19
a very basic Pubmed search API in ruby
Copyright (c) 2012 Heath Anderson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O
@handerson
handerson / mysqlfix.sh
Created March 27, 2012 16:52 — forked from davejlong/mysql client
How to setup the MySQL client and MySQLDump client on Mac OS x from MySQL Workbench
#MySQL Client
ln -s /Applications/MySQLWorkbench.app/Contents/Resources/mysql /usr/bin/mysql
#MySQL Dump
ln -s /Applications/MySQLWorkbench.app/Contents/Resources/mysqldump /usr/bin/mysqldump
#How to fix the "Library not loaded: libmysqlclient.18.dylib (LoadError)" error
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
@handerson
handerson / sqlite_backup_to_cloudfiles.rb
Created February 17, 2012 00:39
Creates a backup SQLite DB and backs it up to Rackspace Cloudfiles and maintains 14 days worth of backups
require 'rubygems'
require 'cloudfiles'
require 'sqlite3'
cf = CloudFiles::Connection.new(:username => "", :api_key => "")
original = = SQLite3::Database.new('/var/www/project/current/db/original.db')
backup = SQLite3::Database.new('/home/deploy/backup.sqlite3')
backup_process = SQLite3::Backup.new(backup, 'main', original, 'main')