Skip to content

Instantly share code, notes, and snippets.

View rcackermanCC's full-sized avatar

Rebecca Ackerman rcackermanCC

  • Case Commons
  • United States
View GitHub Profile
@rcackermanCC
rcackermanCC / sub_messy_names.py
Created June 22, 2016 20:13
Clean weekday names
def clean_words(text):
weekdays = {'sunday': {'pattern': r'\b(su.*?(n|y))(\W|\s|\b)',
'replacement': r'sunday\3'},
'monday': {'pattern': r'((mo.*?(n|y)(?:s)*)|m)(\W|\s|\b)',
'replacement': r'monday\4'},
'tuesday': {'pattern': r'\b(t(u|y).*?(e|s|y)(?:s)*|t)(\W|\s|\b)',
'replacement': r'tuesday\4'},
'wednesday': {'pattern': r'\b(w|w.*?d(.*?|s|y|t)(?:s)*)(\W|\s|\b)',
'replacement': r'wednesday\3'},
'thursday': {'pattern': r'\b(th|th[a-z]*?(r|s|y|t)(?:s)*)(\W|\s|\b)',
@rcackermanCC
rcackermanCC / combining.md
Last active September 12, 2016 18:57
Combining pieces of other repos

Assuming NewA and OldB:

Prep NewA

cd NewA
mkdir NewA
mv *.* NewA/
gc -m "Prep for new repo"
cd ..
@rcackermanCC
rcackermanCC / request_builder.md
Last active January 31, 2020 18:24
S3 request

To know what you want in a secure way, S3 requires a signature. The signature is created by:

  1. assembling a canonical requst
  2. putting together some parts of the request together with a hashed version of the full request - this is the string to sign
  3. creating a signing key
  4. using the signing key to create a signature from the string to sign

Step 1

@rcackermanCC
rcackermanCC / dictionary.sql
Last active August 29, 2015 14:21
Roll your own data dictionary
SELECT
table_name,
column_name,
data_type,
col_description(concat('public.',table_name)::regclass, ordinal_position)
FROM information_schema.columns where table_name like '<stuff>';
@rcackermanCC
rcackermanCC / overlaps.sql
Last active March 4, 2016 19:15
Collapsing overlapping dates
-- base table has id, start_date, end_date
select * from (
with
recursive timeline (id, start_date, end_date) as (
select
id,
start_date,
end_date
from base_table
@rcackermanCC
rcackermanCC / directions.md
Last active August 29, 2015 14:15
Create a new Heroku instance of an existing app
heroku apps:create <new instance name>
git remote add <remote name> <new url>
git push <remote name>
heroku addons:add heroku-postgresql:hobby-dev --app <new instance name>
heroku addons:add pgbackups --app <new instance name>
heroku run rake db:setup --app <new instance name>
heroku pgbackups:capture --app <original instance name>
heroku pgbackups:restore <new instance postgres url> `heroku pgbackups:url <backup id> --app <old instance>` --app <new instance>

Get database info for new and old instances: