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
##Userable | |
module Userable | |
def self.included(base) | |
base.has_one :user, :as => :userable, :dependent => :destroy, :autosave => true | |
base.validate :user_must_be_valid | |
base.alias_method_chain :user, :autobuild | |
base.extend ClassMethods | |
base.define_user_accessors | |
end | |
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 self.read_barcode_from_image path | |
# Call the barcode reader - and get a response of multiple lines | |
ls = `/usr/bin/zbarimg '#{path}'`.lines | |
# Handle a variety of unexpected responses that we have seen and debugged quickly over time | |
ls = [ls] if ls.is_a?(String) | |
barcodes = [] | |
return barcodes if ls.nil? || ls == 0 | |
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
/* | |
Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013 | |
*/ | |
.select2-container { | |
margin: 0 0 1rem 0; | |
position: relative; | |
vertical-align: middle; | |
font-family: inherit; | |
-webkit-appearance: none !important; | |
font-size: 0.875rem; |
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
-- model | |
some sort of constant hash: | |
HASH_NAME = { | |
0 => "Choose:", | |
1 => "On-Campus Recruiting - CSO",· | |
2 => "CSO Staff Referral", | |
3 => "Faculty Contact",· | |
4 => "Career Day",· | |
5 => "CSO Summer Job Listing",· | |
6 => "Alumni Contact",· |
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
class Account < ActiveRecord::Base | |
def self.search(name = nil) | |
# search logic | |
end | |
end |
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
" Vim functions to run RSpec and Cucumber on the current file and optionally on | |
" the spec/scenario under the cursor. | |
function! RailsScriptIfExists(name) | |
" Bundle exec | |
if isdirectory(".bundle") || (exists("b:rails_root") && isdirectory(b:rails_root . "/.bundle")) | |
return "bundle exec " . a:name | |
" System Binary | |
else | |
return a:name |
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
#!/usr/bin/env bash | |
# | |
# Script to initiate (or connect to) a rails project | |
# tmux session. | |
if [[ "$1" != "" ]]; then | |
app=$1 | |
APPDIR=$HOME/src/$app | |
cd $APPDIR | |
else |
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
export PROJECT_NAME=$1 | |
export WORKING_DIR=~/working/active/$PROJECT_NAME | |
cd $WORKING_DIR; | |
tmux start-server | |
tmux new-session -d -s $PROJECT_NAME -n work | |
tmux new-window -t$PROJECT_NAME:1 -n server | |
tmux new-window -t$PROJECT_NAME:2 -n test |
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
# # act like GNU screen | |
unbind C-b | |
set -g prefix C-a | |
# Allow C-A a to send C-A to application | |
bind C-a send-prefix | |
# start window index of 1 | |
set -g base-index 1 |
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
####Download the data from Government of India open data portal##### | |
w_dir = getwd() | |
source(file=file.path(w_dir,"Code/Core.R")) | |
checkAndDownload(c("XML","RCurl","RJSONIO","plyr")) | |
### Alternative - 1: Using APIs ### | |
#JSON# | |
getJSONDoc <- function(link, res_id, api_key, offset, no_elements){ | |
jsonURL = paste(link, | |
"resource_id=",res_id, |
OlderNewer