Skip to content

Instantly share code, notes, and snippets.

View codeprimate's full-sized avatar

Patrick Morgan codeprimate

  • Bellingham, WA
  • 04:20 (UTC -07:00)
View GitHub Profile
@codeprimate
codeprimate / reinstall-imagemagick.sh
Created March 8, 2014 20:08
Reinstall ImageMagick with brew after OSX Update
#!/bin/bash
brew uninstall imagemagick jpeg libtiff jasper
brew install imagemagick
@codeprimate
codeprimate / nginx
Created February 3, 2014 22:04
nginx SystemV script for a Phusion Passenger installation on Linux
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@codeprimate
codeprimate / ruby_httpd.rb
Created January 1, 2014 18:00
Simple Ruby HTTP Server
#!/bin/bash
ruby -run -e httpd . -p 8080

Ruby, RVM and Mountain Lion

Key problems

Mountain Lion (10.8) has three main difference compared to Lion (10.7):

  • XCode 4.4 does not install Command Line Tools by default
  • X11 isn't available anymore
  • The installed version of OpenSSL has some bugs

How to work around

Ruby, RVM and Mountain Lion

Key problems

Mountain Lion (10.8) has three main difference compared to Lion (10.7):

  • XCode 4.4 does not install Command Line Tools by default
  • X11 isn't available anymore
  • The installed version of OpenSSL has some bugs

How to work around

@codeprimate
codeprimate / .bash_profile
Created September 26, 2013 21:18
Powerline Bash prompt
# Add to ~/.bash_profile
function _update_ps1()
{
export PS1="$(~/bin/powerline-bash.py $?)"
}
export PROMPT_COMMAND="_update_ps1"
irb -Ilib -rGEMNAME
== Free Webapp icons
http://www.elegantthemes.com/blog/resources/elegant-icon-font
http://www.justbenicestudio.com/studio/websymbols/
http://mortendk.github.io/iconify/
http://livicons.com/
@codeprimate
codeprimate / gist:6451973
Last active December 22, 2015 09:28
Devise Failed Attempt Lockout
# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
# :none = No lock strategy. You should handle locking by yourself.
config.lock_strategy = :failed_attempts
# Defines which key will be used when locking and unlocking an account
config.unlock_keys = [ :email ]
# Defines which strategy will be used to unlock an account.
def camel_case(txt)
txt.gsub(/(_*)([A-Za-z]+)(_*)/) { |m| $2.downcase.capitalize }
end
examples = [ "_foo_bar_quux_zurb_",
"foo_bar_quux",
"_foo_bar_quux",
"foo__bar-quux",
"_foo__bAr_qUUx" ]