Skip to content

Instantly share code, notes, and snippets.

@thejbsmith
thejbsmith / Rails Singleton Model
Last active April 16, 2024 00:29
Rails Singleton Model
Rails Singleton Model
Taken from:
http://stackoverflow.com/questions/399447/how-to-implement-a-singleton-model/12463209#12463209
@thejbsmith
thejbsmith / switch_iterm2_profile_during_ssh_sessions.sh
Created April 16, 2015 13:42
Switch iTerm2 Profile during SSH Sessions
# Add the following to your .bash_profile or .bashrc file in order to switch to a different iTerm profile during an ssh session.
# This same code could be re-purposed for any command, not just ssh
# Set iTerm2 Profile
set_iterm_profile() {
echo -e "\033]50;SetProfile=$1\a"
}
# Switch iTerm2 Profile during SSH Sessions
ssh() {
@thejbsmith
thejbsmith / linux_snippets.sh
Created February 5, 2015 14:58
Linux Snippets
# Create Tar (with date)
tar czvf [foldername_$(date +%m%d%Y).tar.gz] [/folder/to/archive]
@thejbsmith
thejbsmith / sql_ordering.sql
Created February 3, 2015 17:56
SQL Ordering: Ordering by a specific field, while moving one or more items to the beginning or end of the results
/*
In the database, there is a table called `countries` with a `name` field.
The database contains the following entries for countries:
Canada, Mexico, Argentina, Brazil, United States, Ireland, North Korea, Other
*/
/*
Order by a specific field, while moving one or more items to the beginning
*/