Skip to content

Instantly share code, notes, and snippets.

View markalanevans's full-sized avatar
🎯
Focusing

Mark Evans markalanevans

🎯
Focusing
View GitHub Profile
@markalanevans
markalanevans / ngClass.boolean.js
Created April 5, 2013 18:12
#angularjs #ngClass How to use an ngClass expression to set a custom class if a $scope.value is true. For this example, when the validations.shipping_cost_per_item is set, the "error" class will be applied to the outer div.
<div ng-class="{error: validations.shipping_cost_per_item}" class="control-group">
<label class="control-label">Shipping Cost Per Item</label>
<div class="controls">
<input class="input-small" type="text" ng-model="merchant.shipping_cost_per_item"/>
<span class="help-inline">{{validations.shipping_cost_per_item}}</span>
</div>
</div>
@markalanevans
markalanevans / symbolize_hash
Created March 29, 2013 16:28
Ruby Method to to convert a hash, with strings as keys, to symbols
def symbolize(obj)
return obj.inject({}){|memo,(k,v)| memo[k.to_sym] = symbolize(v); memo} if obj.is_a? Hash
return obj.inject([]){|memo,v | memo << symbolize(v); memo} if obj.is_a? Array
return obj
end

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
#Install Brew
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
#Command Line Tools
brew install tmux
brew install macvim --override-system-vim
brew linkapps
#Description: OSX Git Prompt - make your git repo prompts look pretty
#Owner: Mark Evans:
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
" Pathogen
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
call pathogen#helptags()
" Disable vi-compatibility
set nocompatible
" Remember more history
set history=1000
set-option -g default-shell /bin/zsh
set -g prefix C-a
bind C-a send-prefix
unbind C-b
set -sg escape-time 1
set -g base-index 1
setw -g pane-base-index 1
bind r source-file ~/.tmux.conf \; display "Reloaded!"
bind | split-window -h
bind - split-window -v
@markalanevans
markalanevans / redis-init-rhel
Created November 3, 2011 03:22
Simple RedHat Redis init.d script
#!/bin/sh
#
# redis Startup script for Redis Server
#
# chkconfig: - 90 10
# description: Redis is an open source, advanced key-value store.
#
# processname: redis-server
# config: /etc/redis.conf
# pidfile: /var/run/redis.pid
@markalanevans
markalanevans / underscore_array_keys
Created October 21, 2011 22:55
LowerCase and Underscore PHP array
function underscore_array_keys($data){
foreach ($data as $n => $v){
$newKey = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $n));
unset($data[$n]);
if (is_array($v)){
$data[$newKey] = underscore_array_keys($v);
}else{
$data[$newKey] = $v;
}
}
@markalanevans
markalanevans / git-prompt
Last active September 27, 2015 11:58
A Git Prompt which adds the branch you are on to the prompt.
#Description: OSX Git Prompt - make your git repo prompts look pretty
#Installation: In your .bash_profile, add a line: source .gitprompt
#FileName: .gitprompt
#Owner: Mark Evans:
#Stolen From: http://asemanfar.com/Current-Git-Branch-in-Bash-Prompt
#also install git complet: brew install git bash-completion
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`