Skip to content

Instantly share code, notes, and snippets.

View pkarman's full-sized avatar

Peter Karman pkarman

View GitHub Profile
b2f4e4e8 Squashes migrations prior to 2017 [Fri Mar 3 14:00:54 2017 -0800] [amos]
43224039 [Issue #1519] Disables caching for all site content, except static [Sun Mar 5 11:31:59 2017 -0800] [amos]
b88632cd Special :ascii attribute triggers transliteration (#1183) [Tue Mar 7 16:17:52 2017 -0600] [Peter Karman]
d6249773 Update env var setting in `travis.yml` (#1186) [Tue Mar 7 18:36:54 2017 -0800] [Jessie A. Young]
13656647 Fixes accessibility issues with accordion (#1176) [Wed Mar 8 10:25:46 2017 -0500] [Adam B]
59e34df0 Add Locust.io load testing script (#1188) [Thu Mar 9 10:24:03 2017 -0500] [Moncef Belyamani]
5c13ee5f Update aws-sdk-core from 2.7.3 to 2.8.3 [Thu Mar 9 10:18:58 2017 -0800] [Jessie A. Young]
ab5612c7 Update browserify-rails from 3.4.0 to 4.1.0 [Thu Mar 9 10:19:11 2017 -0800] [Jessie A. Young]
0dcaa9b7 Update bullet from 5.5.0 to 5.5.1 [Thu Mar 9 10:19:23 2017 -0800] [Jessie A. Young]
b0e62361 Update capistrano from 3.7.1 to 3.7.2 [Thu Mar 9 10:19:35 2017 -0800] [Jessie A. Young]
4acce823 (HEAD -> pek-rc-2017-04-19, origin/pek-rc-2017-04-19) Optimize capistrano post-deploy tasks Fri Apr 7 14:20:07 2017 -0500 [Peter Karman]
7ede49f9 (origin/stages/rc-2017-04-19, origin/master, origin/HEAD, stages/rc-2017-04-19, master) Set SameSite setting back to Strict Thu Apr 6 11:27:06 2017 -0400 [Moncef Belyamani]
d3bf0363 Wait until password entry to set SP session data Wed Apr 5 17:40:45 2017 -0400 [Moncef Belyamani]
d82a312b Remove unused DELIVERY_METHOD_MAP option (#1332) Fri Apr 7 08:22:31 2017 -0700 [Jessie A. Young]
cbe1511b Remove unused `helper_method` ref in `IdvStepConcern` (#1333) Fri Apr 7 08:22:16 2017 -0700 [Jessie A. Young]
5e97c81c Move `confirmation_for_phone_change` into presenter (#1334) Fri Apr 7 08:22:01 2017 -0700 [Jessie A. Young]
0ecffbca Ensure the cancel account creation form receives a `delete` method when user is signing up (#1325) Thu Apr 6 19:02:02 2017 -0400 [Adam B]
e510e20d Script to tag releases (#1331) Thu Apr 6 17:13:00 2017 -0500 [Peter Karman]
a0fe8e19 Re-org
Add this line to your main nginx.conf file, inside the main "server" block.
include rewrite-rules;
Then create a file called "rewrite-rules" in the same directory as nginx.conf.
Example:
rewrite /hello/friend http://example.com/friend break;
rewrite ^/hello$ http://example.com/world permanent;
@pkarman
pkarman / rander.rb
Last active December 19, 2016 22:39
ruby random phrase generator
#!/usr/bin/env ruby
num_words = (ARGV[0] || 16).to_i
file = '/usr/share/dict/words'
total_words = `wc -l #{file}`
random_line_nums = Array.new(num_words * 5) { rand(1...total_words.to_i) }
words = []
File.open(file) do |fh|
fh.each_with_index do |line, line_num|
@pkarman
pkarman / diff.rb
Created November 17, 2016 23:34
fix recovery code validation
diff --git a/app/forms/reactivate_profile_form.rb b/app/forms/reactivate_profile_form.rb
index 9d10f30..dfb1b4e 100644
--- a/app/forms/reactivate_profile_form.rb
+++ b/app/forms/reactivate_profile_form.rb
@@ -27,8 +27,7 @@ class ReactivateProfileForm
protected
def reencrypt_pii!
- profile = user.password_reset_profile
- pii = profile.recover_pii(recovery_code)
diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb
index 9ac362b..b2cfe93 100644
--- a/app/controllers/users/passwords_controller.rb
+++ b/app/controllers/users/passwords_controller.rb
@@ -46,11 +46,15 @@ module Users
protected
def token_user(params)
- @_token_user ||= User.with_reset_password_token(params[:reset_password_token])
+ @_token_user ||= find_user_with_token(params[:reset_password_token])

Keybase proof

I hereby claim:

  • I am pkarman on github.
  • I am peterkarman (https://keybase.io/peterkarman) on keybase.
  • I have a public key whose fingerprint is E4A4 4AA4 F670 54CF D4ED C37A F145 8382 312E F1E5

To claim this, I am signing this object:

@pkarman
pkarman / stretch-bench.rb
Created October 5, 2016 18:14
password hashing comparisons
require 'benchmark/ips'
require 'bcrypt'
require 'openssl'
require 'securerandom'
def sha512_digest(*tokens)
Digest::SHA512.hexdigest('--' << tokens.flatten.join('--') << '--')
end
Benchmark.ips do |x|
@pkarman
pkarman / build-ssn-db.rb
Created September 30, 2016 20:51
build ssn rainbow table with dbm
require 'digest'
require 'openssl'
require 'base64'
require 'dbm'
# usage: ruby build-ssn-db.rb dbname path/to/key keypassphrase [range_start] [range_end]
# range_start and _end should be 1 .. 999
#
# example: ruby build-ssn-db.rb ssn-01-10 path/to/key pw 1 10
* note existing DATABASE_URL for historical notes
* comment out the *-db service in manifest.yml (it does not yet exist)
* create the new db service: e.g.
cf create-service rds shared-psql c2-staging-db
OR
cf create-service rds medium-psql c2-prod-db
* dump the existing db to a file