Skip to content

Instantly share code, notes, and snippets.

@sr75
sr75 / bash_profile
Last active June 8, 2018 03:34
Nice simple bash_profile & bashrc for rbenv/python/node/sublime/brew & bash completion terminal setup with colors on osx mavericks
# rbenv & brew git/bash completion terminal setup
# for dev desktop only on osx
# Run the following commands in order to use this script:
################################################################
# !! => Update/Install xcode Command Line Tools <= !!
# In your shell/terminal:
# Homebrew perms needed:
# sudo chown -R root:admin /usr/local
# sudo chown -R root:admin /Library/Caches/Homebrew
# ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@sr75
sr75 / launchd-conf-file-limits.md
Created April 25, 2014 13:18
increase file limits on OSX Mavericks for terminal error - too many open files

If you run into terminal error too many open files

Below are the steps to increase the limit environment setting for maxflies

Show current config:

launchctl limit

maxfiles 256 unlimited
@sr75
sr75 / testing-subdomains-cucumber-capybara.md
Created January 6, 2013 07:09
Express guide to a rails 3.2+ testing custom subdomains using cucumber capybara with pow setup... along with devise mailer config helper (only useful when needing to test custom subdomains in your rails app).

Express guide to a rails 3.2+ testing custom app subdomains using cucumber capybara with a pow setup... along with devise mailer config helper example (useful if you need to test various auth situations for custom subdomains in a rails app).

If you haven't used pow, I wouldn't recommend it for local web dev... there's much better gems for local web dev like unicorn-rails or passenger nginx standalone are far better choices IMHO. I use pow for all the local name redirects to a port like explained below, with a rails dev server listening on that port running unicorn-rails.

So we're going to use it for the awesome subdomain redirect to a local customapp.dev on a specific port magic mojo.

First install pow.cx

  • now go to pow.cx and install
  • cd ~/.pow
param (
[string]$Deploy,
[switch]$SkipBackup,
[string]$Settings = "settings.xml"
)
$success = $false
function writeError($message) {
Write-Host $message -Foreground Red
break;
@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;
@sr75
sr75 / code-style-guides.md
Last active December 24, 2015 14:09
(Google/jQuery) HTML/CSS & JavaScript Code Style guides links:
@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 / 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 / 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 / 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