Skip to content

Instantly share code, notes, and snippets.

# 4 workers is enough for our app
worker_processes 4
# App location
@app = "/var/rails/myapp/current"
# Listen on fs socket for better performance
listen "#{@app}/tmp/sockets/unicorn.sock", :backlog => 64
# Nuke workers after 30 seconds instead of 60 seconds (the default)
@sr75
sr75 / wordpress-htaccess-rewrite
Created December 27, 2012 16:03
wordpress htaccess rewrite to subfolder of install
# BEGIN Custom
Options -Indexes
RewriteEngine On
RewriteCond $1 !^wordpress/
RewriteRule ^(.*)$ wordpress/$1 [L]
# END Custom
@sr75
sr75 / vagrant.org
Created January 24, 2013 20:34 — forked from akiatoji/vagrant.org

Installing CentOS

Download net install iso: CentOS-6.2-x86_64-netinstall.iso

Create a new VirtualBox machine

  • Name: vagrant-centos
  • Operating System: Linux
  • Version: Red Hat
@sr75
sr75 / ExampleViewController.m
Last active December 13, 2015 17:09
Load nib/xib for iphone 5 / Retina 4 Full Screen (568h) custom views, but then default back to ios universal naming conventions (~iphone/~ipad).
#import "UIViewController+AppCategories.h"
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
nibNameOrNil = [UIViewController nibNamedForDevice:@"ExampleViewController"];
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Do any additional customization
@sr75
sr75 / rvm_ruby2_rails4_example.txt
Last active December 15, 2015 07:29
Install rails 4.0 with ruby 2.0.0 using RVM & brew
# important update xcode to 4.6 and make sure command line tools are installed under preferences
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
# if brew is already installed update existing
brew update
brew tap homebrew/dupes
# For rvm:
brew install bash curl git
@sr75
sr75 / submission_form_helper.rb
Created May 29, 2013 06:45
How to override default rails ActionView::Base.field_error_proc for individual form builders
module SubmissionFormHelper
# Override the default ActiveRecordHelper behaviour of wrapping the input.
# This gets taken care of semantically by adding an error class to the wrapper tag
# containing the input.
#
FIELD_ERROR_PROC = proc do |html_tag, instance_tag|
html_tag
end
@sr75
sr75 / mysql-backup-restore-example.md
Created September 17, 2013 13:09
mysql backup and download to dev desktop for a local restore

Say you ssh into a server as the user deployer and have a folder on the server ~/dump:

# on the server you are logged into
# backup the database
mysqldump -uroot -pstrongPassword railsapp_staging > ~/dump/YYYYMMDD_railsapp_staging.sql

# next logout/exit your ssh session to the server above
exit
@sr75
sr75 / code-style-guides.md
Last active December 24, 2015 14:09
(Google/jQuery) HTML/CSS & JavaScript Code Style guides links:
@sr75
sr75 / unstar.rb
Created December 30, 2015 04:17
unstar all the repos
# https://github.com/octokit/octokit.rb
require 'octokit'
Octokit.configure do |c|
c.login = ENV['GH_UID']
c.password = ENV['GH_PWD']
end
begin; Octokit.starred.each {|r| puts Octokit.client.unstar r.full_name}; end while Octokit.starred.size > 0;
param (
[string]$Deploy,
[switch]$SkipBackup,
[string]$Settings = "settings.xml"
)
$success = $false
function writeError($message) {
Write-Host $message -Foreground Red
break;