Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
IanVaughan / uninstall_gems.sh
Created June 9, 2012 20:37
Uninstall all rbenv gems
#!/usr/bin/env bash
uninstall() {
list=`gem list --no-versions`
for gem in $list; do
gem uninstall $gem -aIx
done
gem list
gem install bundler
}
@skyriverbend
skyriverbend / rails_switch_branch.py
Created November 15, 2012 05:54
Rails: Switch branches and run migrations
#!/usr/local/bin/python
"""
To use this script, you must be in the root directory of a Rails project that
is using git. You should also make sure that your directory does not contain any
uncommitted changes. Then run:
$ python rails_switch_branch.py name_of_another_branch
Running the above will do the following:
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 5, 2024 22:16
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@kevin-smets
kevin-smets / iterm2-solarized.md
Last active June 8, 2024 10:07
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@Kartones
Kartones / postgres-cheatsheet.md
Last active June 7, 2024 13:13
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Decoherence
Decoherence / JSON_Parse.hs
Last active August 29, 2015 14:12
Haskell: Quick JSON Parse using Aeson
import Data.ByteString.Lazy.Internal
import Data.Aeson
import Control.Applicative
data Person = Person String Int deriving (Show)
instance FromJSON Person where
parseJSON (Object p) =
Person <$>
(p .: "name") <*>
@Decoherence
Decoherence / ReaderT_and_WriterT.hs
Last active August 2, 2022 02:26
Haskell: Monad Transformers -- Combine ReaderT and WriterT
-- | Main entry point to the application.
module Main where
import Control.Monad.Reader
import Control.Monad.Writer
{-
The ReaderT transformer is used to retrieve a read-only value from some environment.
The WriterT transformer will log the result of each retrieval.
Running the two transformers together yields a log of each step along with the actual results.
@Decoherence
Decoherence / JSON_Lens_Auto_Derive.hs
Last active August 29, 2015 14:16
Haskell JSON: Demonstrates how to automatically derive JSON instances for easy encoding/decoding of a nested data record. Also construct lenses for easy viewing/modification of fields.
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
import Control.Lens
import Data.Aeson
import qualified Data.ByteString.Lazy.Char8 as C
import GHC.Generics
-- For production code, use Text instead of String
data Person = Person { _personName :: String
, _personAge :: Int
@Decoherence
Decoherence / PrimeNumbers.hs
Last active August 29, 2015 14:19
Command-line utility to quickly generate prime numbers (Haskell)
import Control.Applicative
import Control.Monad
import Options
import Safe
{-
Command-line arguments:
-m: biggest prime less than m (required)
-l: show full list (optional)