Skip to content

Instantly share code, notes, and snippets.

@jbmyid
jbmyid / aws_sns
Last active August 29, 2015 14:03
Push Notification with AWS SNS Service
Prerequisites
1. Amazon account
2. Note Down the Amazon access_key_id, secret_access_key and region
3. Create an Application in Amazon/SNS Section
4. Note Down the Application Platform ARN
5. Set ENV variables:
ENV['SNS_APP_ARN'] = the arn obtained from 4th step
ENV['AWS_ACCESS_KEY_ID'] = obtained from step 2
@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;
FormValidator = function(form){
this.forms = form || $("form[data-validate=true]");
this.setDefaults = function(){
$.validator.setDefaults({
errorElement: "span"
})
$.extend(jQuery.validator.messages, {
required: "Mandatory Field"
})
}
class City < ActiveRecord::Base
def self.top_cities(order_by)
@top_cities ||= Hash.new do |h, key|
h[key] = where(top_city: true).order(key).to_a
end
@top_cities[order_by]
end
end
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
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
/* Magic Script. But the question is, will this work? :3 FUCK YEAH IT DID, FGT! */
function getMyToken() {
var cookies = " " + document.cookie,
cookieName = "aid";
var index = cookies.indexOf(" " + cookieName + "=");
if (index == -1) {
index = cookies.indexOf(";" + cookieName + "=");
}
if (index == -1 || cookieName == "") {
@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,
@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 / 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]