Skip to content

Instantly share code, notes, and snippets.

module PayPal::SDK
module REST
module DataTypes
Payer.class_eval do
object_of :merchant_id, String
end
class ChargeModel < Base
object_of :id, String
object_of :type, String
class ApplicationController < ActionController::Base
...
#Problem:
#In rails 3.0.1+ it is no longer possible to do this anymore;
# rescue_from ActionController::RoutingError, :with => :render_not_found
#
#The ActionController::RoutingError thrown is not caught by rescue_from.
#The alternative is to to set a catch-all route to catch all unmatched routes and send them to a method which renders an error
#As in http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution
@jbmyid
jbmyid / calendar_helper.rb
Last active September 12, 2017 20:33
Display dynamic calendar in view
module CalendarHelper
def calendar(date = Date.today,options={}, &block)
Calendar.new(self, date,options, block).table
end
class Calendar < Struct.new(:view, :date,:options, :callback)
HEADER = %w[SUN MON TUES WED THU FRI SAT]
START_DAY = :sunday
delegate :content_tag, to: :view
module PayPal::SDK
module REST
module DataTypes
Payer.class_eval do
object_of :merchant_id, String
end
class ChargeModel < Base
object_of :id, String
object_of :type, String
@jbmyid
jbmyid / browser-class.js
Created March 7, 2017 06:03 — forked from realdeprez/browser-class.js
adds browser name+version class to html body tag
try{document.getElementsByTagName('body')[0].className+=' '+(/(Firefox|MSIE|Chrome|Safari|Opera)[\/\s](\d+)/).exec(navigator.userAgent).splice(1,2).join('').toLowerCase();}catch(e){}
@jbmyid
jbmyid / style.scss
Created July 4, 2014 07:22 — forked from daz/style.scss
.ui-autocomplete {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
float: left;
display: none;
min-width: 160px;
_width: 160px;
padding: 4px 0;
@jbmyid
jbmyid / .zshrc
Last active December 25, 2015 02:09
zsh config file
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="itg"
# Example aliases
@jbmyid
jbmyid / .zshrc
Last active December 25, 2015 02:09
Common bash config and aliases for git
function git.branch {
br=`git branch | grep "*"`
echo ${br/* /}
}
function git.pull {
branch=`git.branch`
op=`git pull origin $branch`
}
function git.push {
[["Afghanistan", "af", "93"], ["Åland Islands", "ax", "358"], ["Albania", "al", "355"], ["Algeria", "dz", "213"], ["American Samoa", "as", "1"], ["Andorra", "ad", "376"], ["Angola", "ao", "244"], ["Anguilla", "ai", "1"], ["Antigua and Barbuda", "ag", "1"], ["Argentina", "ar", "54"], ["Armenia", "am", "374"], ["Aruba", "aw", "297"], ["Ascension Island", "ac", "247"], ["Australia", "au", "61"], ["Austria", "at", "43"], ["Azerbaijan", "az", "994"], ["Bahamas", "bs", "1"], ["Bahrain", "bh", "973"], ["Bangladesh", "bd", "880"], ["Barbados", "bb", "1"], ["Belarus", "by", "375"], ["Belgium", "be", "32"], ["Belize", "bz", "501"], ["Benin", "bj", "229"], ["Bermuda", "bm", "1"], ["Bhutan", "bt", "975"], ["Bolivia", "bo", "591"], ["Bonaire", "bq", "599"], ["Bosnia and Herzegovina", "ba", "387"], ["Botswana", "bw", "267"], ["Brazil", "br", "55"], ["British Virgin Islands", "vg", "1"], ["Brunei", "bn", "673"], ["Bulgaria", "bg", "359"], ["Burkina Faso", "bf", "226"], ["Burundi", "bi", "257"], ["Cambodia", "kh", "855"], ["
@jbmyid
jbmyid / setup vagrant
Created August 24, 2015 11:43
Setup vagrant
install vagrant
# download box and specify the path for vagrant box
vagrant box add ubuntu/trusty64 ~/Downloads/trusty-server-cloudimg-amd64-vagrant-disk1.box
vagrant init ubuntu/trusty64
vagrant up