Skip to content

Instantly share code, notes, and snippets.

View jrunning's full-sized avatar

Jordan Running jrunning

View GitHub Profile
@jrunning
jrunning / get-your-shit-together-protip-2014.md
Last active January 2, 2016 12:29
My Very Best Get-Your-Shit-Together Protip For 2014

My Very Best Get-Your-Shit-Together Protip For 2014

TL;DR

Take pictures of your important documents (driver's license, passport, birth certificate, etc.) and store them securely with an app that will sync to your computers and mobile devices.

Do this now

@jrunning
jrunning / amazon-to-icpl.js
Created December 12, 2013 16:05
Some very rough code to automatically submit an item from Amazon to Iowa City Public Library's "Suggestions For Our Collection" page: http://www.icpl.org/catalog/suggestions.php
var formAction = "http://www.icpl.org/catalog/suggestions.php",
formTmpl;
formTmpl =
'<form method="post" action="' + formAction + '" id="icplInjectForm" target="_blank">' +
'<input name="author" id="icpl-author"/>' +
'<input name="title" id="icpl-title"/>' +
'<input name="publisher" id="icpl-publisher"/>' +
'<input name="copyright" id="icpl-copyright"/>' +
'<input name="cost" id="icpl-cost"/>' +
@jrunning
jrunning / _.md
Created October 13, 2013 20:36
test
#!/usr/bin/env ruby
module Spreadsheet
module ColumnNotation
Alphabet = Hash[ (?A..?Z).each_with_index.map {|chr,idx| [ idx + 1, chr ] } ]
def self.position_to_column_notation(num)
quotient, remainder = num.divmod(Alphabet.size)
if remainder == 0
# Show ratings and reasons (e.g. "crude humor and language") along with the number of times they occur, e.g.:
#
# 270 R violence and language
# 61 R strong sexual content
# 58 PG-13 brief strong language
# ... ... ...
cat mpaa-ratings-reasons.list |
sed --quiet --regexp-extended '
var seenLinks = {}
function removeNewsItemParent(el) {
return $(el).closest('.news > .alert').remove()
}
function getGist(gistId) {
return $.get('https://api.github.com/gists/' + gistId);
}
@jrunning
jrunning / a_poor_devs_cat.rb
Last active December 15, 2015 13:09
Ever want to combine two or more Enumerables (or anything that responds to `#to_enum`) into a single one, without reading them first? Ruby 1.9+'s Enumerator is pretty badass. Behold!
def poor_devs_cat *args
args = args.to_enum
Enumerator.new do |yielder|
enum = args.next.to_enum
loop do
begin
yielder << enum.next
rescue StopIteration
class GetterSetterTest
constructor: (@_obj = null) ->
# nada
# 'obj' is defined via the prototype, the definition proxied through to
# 'Object.defineProperty'. Remember, the value of '@' is GetterSetterTest
# itself when used in the body of its class definition.
Object.defineProperty @prototype, 'obj'
get: -> @_obj
set: (value)-> @_obj = value * 2
puts "yay!" if http_response.is_a? HTTPSuccess
case http_response
when HTTPSuccess
puts "here!"
when HTTPFound, HTTPMovedPermanently
puts "over there!"
else
puts "go away!"
end
class InheritsFromStruct < Struct.new(:foo)
end
insty = InheritsFromStruct.new 100
puts insty[:foo]
# => 100
class InheritsFromStruct
def double_foo