Skip to content

Instantly share code, notes, and snippets.

require 'rspec/expectations'
class Pain
def tear_inducing?
true
end
end
class Fear
def tear_inducing?
@jennifersmith
jennifersmith / aws.bash
Last active August 29, 2015 14:06
Too much aws and JSON make jen go something something http://bit.ly/1m8OONb
function which-aws {
echo "You are on an AWS account with alias(es)" `aws iam list-account-aliases | jq '.AccountAliases | join(",")' -r` | cowsay
}
function cfn-describe {
aws cloudformation describe-stacks --stack-name "$1"
}
@jennifersmith
jennifersmith / go.sh
Last active August 29, 2015 14:10
Convert requires into a graph - this is pretty dreadful please can someone do better?
egrep -e "require\s\"([a-z]|_|/)+\"" -o -r lib | ./sniffrequires.rb | dot -Tsvg > /tmp/foo.svg; open /tmp/foo.svg
@jennifersmith
jennifersmith / fixDates.rb
Created December 30, 2014 21:56
This is a bit of a rubbish script that spiders thru json and decides whether something is a timestamp or not on some assy heuristics - basically if you have a bunch of numbers and you think some of them are dates then it will convert them
#!/usr/bin/env ruby
require 'json'
require 'pry'
require 'date'
# basically if the number results in a ts that is less than 10 years ago it's probably a timestamp :D
YEARS_TO_BE_CONSIDERED_TIMESTAMP = 10
def fix_potential_timestamp potential_timestamp
# binding.pry
@jennifersmith
jennifersmith / codepages.rb
Created February 3, 2015 07:07
This seemed wonderfully important to me about 10 minutes ago.
(33..255).map {|x| windoze = x.chr(Encoding::CP1250); [x, windoze , begin windoze.encode(Encoding::UTF_8) rescue 'ass' end]}.select{|x| x[1] != x[2]}
require 'rest_client'
require 'json'
class HomeController < ApplicationController
def initialize
@queries = {:lines =>
"SELECT *
WHERE
@jennifersmith
jennifersmith / gist:1034716
Created June 19, 2011 20:36
Create mysql user
CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> WITH GRANT OPTION;
@jennifersmith
jennifersmith / gist:1035439
Created June 20, 2011 10:57
Setting max print length clojure repl
(set! *print-length* 200)
@jennifersmith
jennifersmith / gist:1050765
Created June 28, 2011 08:54
Comparison of long string generation
require 'benchmark'
lengths = [10, 100 , 1000, 10000, 100000, 1000000]
Benchmark.bm do |x|
lengths.each do |length|
x.report("Length = #{length}\t\t\t") {(0...length.to_i).map{ ('a'..'z').to_a[rand(26)] }}
x.report("Same without rand = #{length}\t\t\t") {(0...length.to_i).map{ ('a'..'z').to_a[1] }}
x.report("Fixed characters Length = #{length}\t\t\t") {"x" * length}
end
end
(doseq [i [1 2 3 4]] (print i))