Skip to content

Instantly share code, notes, and snippets.

View zoras's full-sized avatar
🏠
Working remotely 🌏 Available for Hire

Saroj Maharjan zoras

🏠
Working remotely 🌏 Available for Hire
View GitHub Profile
#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\]"
@zoras
zoras / gist:609395
Created October 4, 2010 08:42 — forked from bikashp/gist:589180
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"
# 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
@zoras
zoras / gist:616341
Created October 8, 2010 04:06
Git tab completion
# 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
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.
## Run document
{
"title": "Find info for these 50 companies",
"line_id": 23453453,
"order": {"amount": 23454, "service_charge": 2342},
}
## Initial Unit document
{
# 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")
@zoras
zoras / install ffmpeg
Created December 23, 2010 03:27
brew install ffmpeg
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
#!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
@zoras
zoras / after_deploy.rb
Created January 13, 2011 10:47
cf document migration
# 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