This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Copy and paste the following in ~/.bash_profile | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
BLUE="\[\033[1;34m\]" | |
LIGHT_RED="\[\033[1;31m\]" | |
LIGHT_GREEN="\[\033[1;32m\]" | |
WHITE="\[\033[1;37m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def valid(format, value) | |
case format | |
when "email" | |
regex = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i | |
when "url" | |
regex = /^(http:\/\/|https:\/\/)?(www.)?[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})([.]?[a-zA-Z]{2})?(\/\S*)?$/i | |
msg = "Start with http:// or https://" | |
when "number" | |
regex = /^\d{1,3}(\,?\d{3})*$/ | |
when "date" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ways to execute a shell script in Ruby | |
# Example Script - Joseph Pecoraro | |
cmd = "echo 'hi'" # Sample string that can be used | |
# 1. Kernel#` - commonly called backticks - `cmd` | |
# This is like many other languages, including bash, PHP, and Perl | |
# Returns the result of the shell command | |
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In ~/.bash_profile | |
# Git tab completion | |
# source /usr/local/etc/bash_completion.d/git-completion.bash | |
# homebrew => source /usr/local/Cellar/git/1.7.2.3/etc/bash_completion.d/git-completion.bash | |
# copied file to ~/.git-completion.sh | |
source ~/.git-completion.sh | |
GIT_PS1_SHOWDIRTYSTATE=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo brew install maven | |
Maven is installed. Try mvn --version. If you want to know what is extracted and installed use the verbose mode: | |
sudo brew -v install maven | |
The most common things you will need are available: maven, gradle, git, groovy, all there. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Run document | |
{ | |
"title": "Find info for these 50 companies", | |
"line_id": 23453453, | |
"order": {"amount": 23454, "service_charge": 2342}, | |
} | |
## Initial Unit document | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Last login: Thu Dec 23 08:46:03 on ttys000 | |
ruby-1.8.7-head [~] brew install ffmpeg | |
==> Downloading http://www.tortall.net/projects/yasm/releases/yasm-1.1.0.tar.gz | |
######################################################################## 100.0% | |
==> ./configure --prefix=/usr/local/Cellar/yasm/1.1.0 --disable-debug --disable-dependency-tracking | |
==> make install | |
/usr/local/Cellar/yasm/1.1.0: 42 files, 3.7M, built in 17 seconds | |
==> Downloading http://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20100903-2245.tar.bz2 | |
######################################################################## 100.0% | |
==> ./version.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!ruby | |
# w = Station.first.build_worker(:reward => 2.0, :number => 1) | |
# w.save! | |
# Each station worker is copied to human_worker which is inherited from dummy_worker (later is referenced in station) | |
Station.all.each do |station| | |
worker = station.worker | |
human_worker = HumanWorker.new(:number => worker.number, :reward => worker.reward, :worker_type => worker.worker_type, :station_id => station.id) | |
station.dummy_worker = human_worker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# after deploy worker is references_one and human_worker << worker | |
# add references_one dummy_worker and copy dummy_worker.rb | |
# station.rb | |
class Station | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
# Fields | |
field :station_type |
OlderNewer