Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / my.cnf.txt
Created June 6, 2012 22:59
mysql-innodb-large-server-example-configuration
# *** Application-specific options follow here ***
#
# The MySQL server
#
[mysqld]
# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
@sr75
sr75 / my.cnf
Created April 14, 2013 17:41
Optimized my.cnf for mysql server when setting up physical servers or vps. Configured for 2GB of memory allocated to the mysql process. Adjust connections and max memory for larger setups with more available memory.
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
@sr75
sr75 / yaml2json-python-bash-alias
Created June 10, 2019 20:28
yaml2json python bash alias one liner
# https://medium.com/@frontman/how-to-parse-yaml-string-via-command-line-374567512303
alias yaml2json="python3 -c 'import sys,json,yaml;f=open(sys.argv[1]);d=yaml.safe_load(f);f.close();print(json.dumps(d))'"
# yaml2json ./vars.yml | jq ...
@sr75
sr75 / .gitconfig
Last active October 24, 2019 21:17
gitconfig for git v1.8+ with terminal color and command aliases
[user]
name = yourname
email = yourname @ whatever
[core]
excludesfile = yourhomedir/.gitignore
#git config --global core.eol lf
#git config --global core.autocrlf input
eol = lf
autocrlf = input
#git rm -rf --cached .
@sr75
sr75 / remove-python27-osx-via-pythonorg-installer-dmg.md
Last active June 5, 2020 02:37
remove python 2.7 on mac osx if installed via python.org installer .dmg
# sudo rm -rf /Library/Frameworks/Python.framework
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
sudo rm -rf "/Applications/Python 2.7"
cd /usr/local/bin && \
sudo ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | xargs rm
@sr75
sr75 / osx-homebrew-setup.md
Last active June 18, 2020 06:35
Mac Yosemite OSX - Homebrew (RVM/MySQL/Redis) setup

Mac Homebrew (RVM/MySQL/Redis) setup

Follow the steps below to setup a local development environment:

XQuartz

Recommended to download latest XQuartz

iTerm2

@sr75
sr75 / mysql_max_text_limits_active_record.rb
Created April 15, 2013 15:09
mysql 5.6 rails active_record migration text max lengths for a database created with utf8
# just an active_record migration example for reference
# source of this logic: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
class CreateMetaTexts < ActiveRecord::Migration
def up
create_table :meta_texts do |t|
t.text :default_text_63KB, limit: 63.kilobytes # 64512 < 65535 limit for when text datatype changes to mediumtext datatype
t.text :medium_text_64KB, limit: 64.kilobytes # 65536 > 65535 limit and triggers text datatype to mediumtext datatype
t.text :medium_text_15MB, limit: 15.megabytes # 15728640 < 16777215 limit for when mediumtext changes to longtext datatype