Skip to content

Instantly share code, notes, and snippets.

@timstott
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timstott/c1f6e9ac57011a1213b8 to your computer and use it in GitHub Desktop.
Save timstott/c1f6e9ac57011a1213b8 to your computer and use it in GitHub Desktop.
cheatsheets

Dev Cheat Sheets

Personal collection of commands and snippets that just won't stay in my head.

Git

Branches

Search and delete multiple branches

git branch | grep '3\.2' | xargs git branch -d

Push to remote with different name

git push heroku develop:master

Others

git-flow epic infographic

OpenSSL

Certificates

MD5 hash of modulus from key/cert/csr

Usefull to identify if multiple certificates have been signed with the same key.

openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl rsa -noout -modulus -in privateKey.key | openssl md5
openssl req -noout -modulus -in CSR.csr | openssl md5

Certificate expiry date

openssl x509 -noout -in certificate.crt -dates

DevOps

Vagrant

SSH as specific user

vagrant ssh -- -l deploy -i ~/.ssh/id_rsa

Ruby / Rails / RVM

RVM

Create .ruby-version and .ruby-gemset

rvm --ruby-version use 1.9.3@gemset-name

List all rubies and gemsets

rvm gemset list_all

List local gems

gem list --local

Remove rubygems

Handy on legacy projects using ancient versions of rubygems. rvm rubygems remove

Hash

Rename hash keys

Hash[ hash.map { |k,v| ["#{k}_something", v ] } ]

Time & Dates

String from time with format

Time.now.strftime('%Y/%m/%d')
=> "2014/08/11"

Snippets

Export array to CSV file

# Fetch data
a = User.active.map { |u| [u.name, u.email] }
# Transform data to CSV
csv = a.map { |e| e.join(', ') }.join("\n")
# Write to file
File.open("users.csv", "w") { |f| f.write(csv) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment