Skip to content

Instantly share code, notes, and snippets.

View ideaoforder's full-sized avatar

Mark Dickson ideaoforder

  • Sitesteaders Developement
View GitHub Profile
@ideaoforder
ideaoforder / statsd.init
Last active August 29, 2015 13:56
Init File for statsd
#!/bin/bash
### BEGIN INIT INFO
# Provides: statsd
# Required-Start: $remote_fs $network $local_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
. /lib/lsb/init-functions
@ideaoforder
ideaoforder / osx_postgresql
Created March 19, 2014 15:10
OS X Postgres Setup
# Install PostgresApp
Download/Install PostgresApp from http://postgresapp.com/
# Add Postgres to your path
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin
source $HOME/.bash_profile OR source $HOME/.profile
# Build the PG gem (note the version--you may need to update this)
bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
bundle install (assuming you've got the pg gem listed)
Install XCode tools
https://developer.apple.com/downloads/index.action
OR OS X GCC
https://github.com/kennethreitz/osx-gcc-installer
Install Homebrew
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew install git
@ideaoforder
ideaoforder / open_source_repo
Created January 7, 2015 17:58
Open-Sourcing a Github Repo
First and foremost: DON'T USE THE AMAZON MASTER KEY/SECRET
Use an IAM USER for each site/repo, with its own creds, so you can reset them easily and limit access
Secondly, use .env/secrets.yml--either using Heroku/Foreman, dot-env (Rails 3), or secrets.yml (Rails 4)
https://devcenter.heroku.com/articles/config-vars
Last thing, you'll need to scrub sensitive data out of your app's history (even if you reset/deleted those passwords, best to remove them from the history as well--you want to seem like a pro, don't you?)
https://help.github.com/articles/remove-sensitive-data/
https://rtyley.github.io/bfg-repo-cleaner/
@ideaoforder
ideaoforder / ruby_mysql2.md
Last active August 29, 2015 14:27
Install ruby mysql2 gem on OSX

locate mysql_config

gem install mysql2 -- --with-mysql-config=/usr/local/MYSQL_PATH/bin/mysql_config

@ideaoforder
ideaoforder / rbenv_ruby-2.2.2.md
Last active August 29, 2015 14:27
Rbenv Ruby Upgrade
Install Ruby 2.2.2
cd ~/.rbenv/plugins/ruby-build
git pull
rbenv install 2.2.2

https://github.com/sstephenson/rbenv

Set the current shell to use it, and prepare for Rails - This won't affect current install
check process starling_22122 with pidfile YOUR_WEB_APP/pids/starling_22122.pid
start program = "/home/YOUR_USER/scripts/starling start 22122"
stop program = "/home/YOUR_USER/scripts/starling stop 22122"
if cpu > 80% for 5 cycles then restart
if failed port 22122 with timeout 10 seconds then restart
if 3 restarts within 5 cycles then timeout
mode active
group YOUR_APP_NAME
check process workling0 with pidfile YOUR_WEB_APP/log/workling0.pid
group YOUR_APP_NAME
start program = "/home/YOUR_USER/scripts/workling start 0"
stop program = "/home/YOUR_USER/scripts/workling stop 0"
if totalmem > 60 Mb then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if loadavg(5min) greater than 10 for 8 cycles then restart
if 3 restarts within 5 cycles then timeout
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: starling
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop starling server
### END INIT INFO
#
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: workling
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop worklings
### END INIT INFO
#