Skip to content

Instantly share code, notes, and snippets.

View thephw's full-sized avatar
❤️
Building software with love

Patrick Howard Wiseman thephw

❤️
Building software with love
View GitHub Profile
$ brew update
$ brew boxen-install gnupg
$ gpg --gen-key # Use the same email address as github, local gitconfig, and SSH key
$ gpg --list-secret-keys --keyid-format LONG # Take everything after the / in pub to use in the following command
$ git config --global user.signingkey <YOUR KEY HASH HERE i.e. 0A123456>
$ git config --global commit.gpgsign true
$ gpg --armor --export <YOUR_EMAIL_ADDRESS_HERE> | pbcopy
$ open https://github.com/settings/keys # Paste the key into GPG keys here
@thephw
thephw / example.md
Last active February 4, 2016 17:36
Automaton girl - leveraging factory girl for QA data

Set your vars

email = "patrick.wiseman@salesloft.com"
user = User.find_by(email: email)
account = user.account
team = account.team
@thephw
thephw / merge_tool_basics.sh
Created January 18, 2016 19:58
Please use your merge tool
# Setup your merge tool
$ git config --global merge.tool opendiff
# Use your merge tool when you have conflicts
$ git mergetool
# Cleanup after your merge (delete .orig files)
$ find . -name "*.orig" -delete
rubocop_happy = $(rubocop -a)
if [ "$rubocop_happy" != "true" ]
then
cat <<\EOF
Error: Rubocop detected style conflicts, commit cancelled, please review.
EOF
exit 1
fi
@thephw
thephw / schema_change.sh
Last active November 9, 2015 18:04 — forked from hwhelchel/schema_change.sh
Undesired Rails Schema Changed (Column moved etc.)
pg_dump --create --column-inserts melody_development > melody_development_dump.sql # or whatever your database is called
# edit dump.sql and change the column order
# stop webserver
be rake db:drop
be rake db:create
psql -f melody_development_dump.sql melody_development
be rake db:migrate
be rake db:test:prepare
require 'octokit'
ACCESS_TOKEN = "" # Create at https://github.com/settings/tokens
ORGANIZATION_NAME = "SalesLoft"
USER_NAME = "thephw"
PULL_REQUEST_OPTIONS = {state: :all, head: USER_NAME, sort: :created, direction: :desc}
FILTER_AFTER = Time.parse('2015-05-18 00:00:00 UTC')
client = Octokit::Client.new(access_token: ACCESS_TOKEN)
repositories = client.repositories.map(&:full_name).select{|repo| repo.start_with?(ORGANIZATION_NAME)}
@thephw
thephw / crontab
Last active August 29, 2015 14:24
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
ul{
list-style-type:none;
counter-reset: section;
}
li:before {
counter-increment: section;
content: counter(section);
}
li:nth-child(3n):before, li:nth-child(5n):before{
content: "";
@thephw
thephw / get_length.rb
Created April 29, 2015 21:16
Get length of linked list
class IntList
attr_accessor :value, :next
end
def get_length(l)
return 0 if l.nil?
len = 1 + get_length(l.next)
end
@thephw
thephw / min_abs_slice_sum.rb
Created April 29, 2015 21:06
Minimum absolute slice sum
def min_abs_slice_sum(a)
a.each_index.to_a.combination(2).map{|i,j| a[(i..j)].inject(&:+).abs}.min
end
def run_benchmark
require 'benchmark'
n = 3
Benchmark.bm(17) do |x|
(0..n).each do |i|