Skip to content

Instantly share code, notes, and snippets.

@mikelikesbikes
mikelikesbikes / gist:6585607
Created September 16, 2013 19:47
Unicornify Create a bookmark, make the following the URL.
javascript:(function(){var d=document,j=d.getElementById('__cornify_nodes'),k=null;var file='https://gist.github.com/mikelikesbikes/4766d1815476568f4212/raw/990e81435eba381592b3396db38b5b068b444117/gistfile1.txt';if(j){cornify_add();}else{k=d.createElement('div');k.id='__cornify_nodes';d.getElementsByTagName('body')[0].appendChild(k);j=d.createElement('script');k.appendChild(j);j.onload=function(){console.log("woo");cornify_add();};j.src=file;}})();
@mikelikesbikes
mikelikesbikes / path.sh
Last active December 21, 2015 05:39
File counts for directories in your path
arr=`echo $PATH | tr ':' '\n'`;
for path in ${arr[*]}; do
printf "%5s %s\n" `ls $path | wc -l` $path
done
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
@mikelikesbikes
mikelikesbikes / input.txt
Last active December 12, 2015 08:29
My solution to XKCD #287 http://xkcd.com/287/
$15.05
mixed fruit,$2.15
french fries,$2.75
side salad,$3.35
hot wings,$3.55
mozzarella sticks,$4.20
sampler plate,$5.80
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;
@mikelikesbikes
mikelikesbikes / argv.rb
Created November 13, 2012 15:52
ARGV/OptionParser destruction
require 'optparse'
require 'ostruct'
options = OpenStruct.new
parser = OptionParser.new do |opts|
opts.on("-f", "--force", "Force something to happen") do |force|
options.force = force
end
end
@mikelikesbikes
mikelikesbikes / sf_id_converter.rb
Created October 29, 2012 22:18
Converts 15 character Salesforce IDs to 18 character Salesforce IDs (adds checksum)
CHECKSUM_CHARS = ((?A..?Z).to_a + (0..5).to_a).join
# String -> String
def id_with_checksum(sfid)
# protection from bad people who misuse things
return sfid if sfid.length == 18
raise ArgumentError.new("sfid must be 15 characters") unless sfid.length == 15
# The meat.
suffix = sfid.chars \ # String -> [String]
@mikelikesbikes
mikelikesbikes / dynamic.clj
Created October 17, 2012 18:32 — forked from bjeanes/dynamic.clj
Change Maker in clojure
(ns katas.change-maker)
(defn num-pairs
"Returns all combinations of [x y] and (<= x y) where (= cents (+ x y))"
[cents]
(for [x (reverse (range 1 (inc (quot cents 2)))) ;; use the range from midpoint to 1 so that we walk the
;; shortest side of the tree first
:let [y (- cents x)]]
[x y]))
require 'benchmark'
require 'hamster'
require 'deps/clojure-1.4.0.jar'
Benchmark.bm do |bm|
def fill(hash)
(0..10000).reduce(hash) do |h, i|
if h.class == Java::ClojureLang::PersistentHashMap
h.assoc(i, 1)
elsif h.respond_to?(:put)
brew tap homebrew/dupes
brew install apple-gcc42