Skip to content

Instantly share code, notes, and snippets.

@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){}
[["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
(function() {
var isIE = /msie/gi.test(navigator.userAgent); // http://pipwerks.com/2011/05/18/sniffing-internet-explorer-via-javascript/
this.infiniteScroll = function(options) {
var defaults = {
callback: function() {},
distance: 50
}
// Populate defaults
for (var key in defaults) {
window.infyScroll = (el_id, url)->
self = @
@finish = false
@complete = ->
self.inProgress = false
self.nextPage++
@xmlhttp = new sendAjaxRequest("", url, "GET", @complete)
@nextPage = 2
@inProgress = false
@ele = document.getElementById(el_id)
@jbmyid
jbmyid / typeheadonclick.js
Created July 3, 2015 06:58
Open ng-typeahea on click
.directive('typeaheadClickOpen', function($parse, $timeout) {
var dir;
return dir = {
restrict: 'A',
require: 'ngModel',
link: function($scope, elem, attrs) {
var triggerFunc;
triggerFunc = function(evt) {
var ctrl, prev;
ctrl = elem.controller('ngModel');
module DelegateError
extend ActiveSupport::Concern
included do
class_variable_set(:@@delegate_error_attrs , [])
after_validation :copy_errors_to_delegated_attribute
end
module ClassMethods
def delegate_errors(s_atr, t_atr)
attrs = delegate_error_attrs + [{source: s_atr, target: t_atr}]
class_variable_set(:@@delegate_error_attrs, attrs)
@jbmyid
jbmyid / country_code_timezone_offsets
Last active August 29, 2015 14:20
country_code_timezone_offsets
[{"+1":[-21600,-18000,-28800,-25200,-14400,0,-36000,-32400]},{"+355":[3600]},{"+213":[0]},{"+376":[3600]},{"+244":[3600]},{"+264":[-14400,7200]},{"+268":[-14400,7200]},{"+54":[-10800]},{"+374":[14400]},{"+297":[-14400]},{"+247":[0]},{"+43":[3600]},{"+994":[14400]},{"+242":[-18000,3600]},{"+973":[10800]},{"+880":[21600]},{"+246":[-14400,18000]},{"+375":[10800]},{"+32":[3600]},{"+501":[-21600]},{"+229":[3600]},{"+441":[-14400]},{"+975":[19800]},{"+591":[-14400]},{"+387":[3600]},{"+267":[7200]},{"+673":[28800]},{"+359":[7200]},{"+226":[0]},{"+257":[7200]},{"+855":[25200]},{"+237":[3600]},{"+238":[-3600]},{"+345":[-18000]},{"+236":[3600]},{"+235":[3600]},{"+56":[-14400]},{"+86":[28800]},{"+57":[-18000]},{"+269":[10800]},{"+682":[-36000]},{"+506":[-21600]},{"+385":[3600]},{"+53":[-10800]},{"+357":[7200]},{"+420":[3600]},{"+45":[3600]},{"+253":[10800]},{"+767":[-14400]},{"+809":[-14400]},{"+593":[-18000]},{"+20":[7200]},{"+503":[-21600]},{"+240":[3600]},{"+291":[10800]},{"+372":[10800]},{"+251":[10800]},{"+298":[0]
@jbmyid
jbmyid / confirm.js
Created April 21, 2015 13:47
service for confirm alert etc
module.service("$nalerts", ["$q","$modal",'$rootScope', function($q, $modal,$rootScope){
var scope = $rootScope.$new();
var deferred;
var defaults = {title: "Alert", message: "", type: "info"};
var modal= $modal({scope: scope, template: 'cust_dialogs/nalerts.html', show: false});
scope.answer = function(res) {
deferred.resolve(res);
modal.hide();
}
@jbmyid
jbmyid / resque_and_rspec.rb
Created November 26, 2014 09:27
Set rspec for rescue
# rails_helper.rb
# Redis and Resque config
REDIS_PID = "#{Rails.root}/tmp/pids/redis-test.pid"
REDIS_CACHE_PATH = "#{Rails.root}/tmp/cache/"
config.before(:suite) do
redis_options = {
"daemonize" => 'yes',
"pidfile" => REDIS_PID,
"port" => 9736,
"timeout" => 300,