Skip to content

Instantly share code, notes, and snippets.

View orthodoc's full-sized avatar
🎯
Focusing

Biswajit Dutta Baruah orthodoc

🎯
Focusing
View GitHub Profile
##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
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
/*
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;
-- 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",·
@orthodoc
orthodoc / account.rb
Created February 13, 2014 03:04 — forked from smoil/account.rb
class Account < ActiveRecord::Base
def self.search(name = nil)
# search logic
end
end
" 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
@orthodoc
orthodoc / trails.sh
Created March 24, 2014 20:48 — forked from afair/trails.sh
#!/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
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
# # 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
####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,