Skip to content

Instantly share code, notes, and snippets.

@rob-murray
rob-murray / email_regex
Created May 17, 2016 11:28
Email validation regex
[a-zA-Z0-9_]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?!([a-zA-Z0-9]*\.[a-zA-Z0-9]*\.[a-zA-Z0-9]*\.))(?:[A-Za-z0-9](?:[a-zA-Z0-9-]*[A-Za-z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?
@rob-murray
rob-murray / list_aws_users.sh
Created May 17, 2016 11:07
List AWS IAM user accounts - assuming you have AWS Command Line Interface installed
# usage: list_aws_users.sh > list_aws_users.txt
# requirements: AWS Command Line Interface
# output: ACCESSKEYMETADATA ACCESS_KEY_ID last_used_at Active|Inactive access_key_name
#
for user in $(aws iam list-users --output text | awk '{print $NF}'); do
aws iam list-access-keys --user $user --output text
done
@rob-murray
rob-murray / better_errors.txt
Created April 21, 2016 12:17
not so better
Allocated String Report
-----------------------------------
17486 "/Users/rmurray/.rvm/gems/ruby-2.2.1/gems/better_errors-2.1.1/lib/better_errors/exception_extension.rb"
17486 /Users/rmurray/.rvm/gems/ruby-2.2.1/gems/better_errors-2.1.1/lib/better_errors/exception_extension.rb:6
@rob-murray
rob-murray / suspenders.cmd
Created March 29, 2016 20:55
suspenders setup
suspenders project_name --skip-bundle true --heroku false --skip-turbolinks false --edge false
@rob-murray
rob-murray / speedtest_bot.sh
Last active February 16, 2016 21:55 — forked from aallan/speedtest-ifttt.sh
Modified version of Henrik Bengtsson's speedtest-cli code which will dispatch the test results to the IFTTT Maker Channel.
#!/usr/bin/env bash
###########################################################################
# Originally written by: Henrik Bengtsson, 2014
# https://github.com/HenrikBengtsson/speedtest-cli-extras
# Modified to use IFTTT by: Alasdair Allan, 2015
# License: GPL (>= 2.1) [http://www.gnu.org/licenses/gpl.html]
# Usage:
# $ speedtest-ifttt.sh --{option}
# options:
# --header Write headers as first CSV row
@rob-murray
rob-murray / open_last_migration.sh
Created January 29, 2016 16:04
Open last migration in SublimeText
# ~/.bashrc
open_last_migration(){
subl db/migrate/$(ls db/migrate/ | sort | tail -1)
}
local all postgres trust
host all postgres 10.200.17.0/24 trust
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 md5
@rob-murray
rob-murray / ruby_string_perf.rb
Created December 24, 2015 10:10
Ruby string formatting performance
require "benchmark/ips"
def with_interpolation(a = "a", b = "b")
"#{a}--#{b}"
end
def with_cryptic_percentage(a = "a", b = "b")
"%s--%s" % [a,b]
end
@rob-murray
rob-murray / stubber.rb
Created November 10, 2015 16:11
wisper gem stubber
class StubWorkerService
def initialize(method_to_call, *args)
@method_to_call = method_to_call
@args = args
end
def subscribe(worker, *_)
@worker = worker
self
end
@rob-murray
rob-murray / quick_bench.rb
Created November 8, 2015 09:54
Ruby quick benchmark
def m(&block)
Benchmark.ms do
100.times { yield }
end
end