Skip to content

Instantly share code, notes, and snippets.

View scottrobertson's full-sized avatar

Scott Robertson scottrobertson

View GitHub Profile
@jcasimir
jcasimir / friendly_urls.markdown
Created September 11, 2011 15:48
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 27, 2024 16:50
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@scottrobertson
scottrobertson / dev.sh
Last active December 16, 2015 09:18
Route all "*.dev" domains to 127.0.0.1
#!/bin/sh
brew install dnsmasq
mkdir -pv $(brew --prefix)/etc/
echo 'address=/.dev/127.0.0.1' > $(brew --prefix)/etc/dnsmasq.conf
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
# sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'
@scottrobertson
scottrobertson / post-receive
Created July 13, 2013 08:51
Simple post-receive hook for git deployment, with composer update.
#!/bin/sh
WORKING_DIR=/var/www/site;
GIT_WORK_TREE=$WORKING_DIR git checkout -f;
cd $WORKING_DIR && composer update -o;
@awd
awd / circle.yml
Created April 11, 2014 18:59
Circle CI database override
## Customize database setup
database:
override:
- echo "no database setup"
@odacremolbap
odacremolbap / Deis on Stackpoint
Created February 12, 2017 11:20
Deis on Stackpoint
Login
$ deis login http://deis.52.41.72.169.nip.io:31100/
username: pablo
password:
Logged in as pablo
Add your keys to Deis git
$ deis keys:add ~/.ssh/id_rsa.pub
@billinghamj
billinghamj / card-offline-outbound.json
Last active September 10, 2021 10:15
Monzo transaction types
{
"id": "tx_[transaction-id]",
"created": "2017-07-24T05:45:49.311Z",
"description": "TFL.GOV.UK/CP\\VICTORIA STREET\\TFL TRAVEL CH\\SW1H 0TL GBR",
"amount": -770,
"currency": "GBP",
"merchant": null,
"notes": "",
"metadata": {
"mastercard_clearing_message_id": "mcclearingmsg_[mastercard-clearing-message-id]",
@alistairewj
alistairewj / install-postgres-10-ubuntu.md
Last active July 12, 2024 08:05
Install PostgreSQL 10 on Ubuntu

Install PostgreSQL 10 on Ubuntu

This is a quick guide to install PostgreSQL 10 - tested on Ubuntu 16.04 but likely can be used for Ubuntu 14.04 and 17.04 as well, with one minor modification detailed below.

(Optional) Uninstall other versions of postgres

To make life simple, remove all other versions of Postgres. Obviously not required, but again, makes life simple. If you have data in your previous version of postgres that you'd like to retain, then this is not recommended. Instead, you'll have to use pg_upgrade or pg_upgradecluster.

@douglasmiranda
douglasmiranda / instructions.md
Created July 19, 2018 05:51
Add email to Keybase.io PGP Key (Public Key)

Export your public key:

keybase pgp export > keybase-public.key

Export your private key:

keybase pgp export --secret &gt; keybase-private.key
@darconeous
darconeous / tesla-key-card-protocol.md
Last active July 25, 2024 03:25
Tesla Key Card Protocol

Tesla Key Card Protocol

Researched by Robert Quattlebaum darco@deepdarc.com.

Last updated 2020-02-03.

Image of Tesla Key Card Image of Tesla Model 3 Key Fob