Skip to content

Instantly share code, notes, and snippets.

/* 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 == "") {
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
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
FormValidator = function(form){
this.forms = form || $("form[data-validate=true]");
this.setDefaults = function(){
$.validator.setDefaults({
errorElement: "span"
})
$.extend(jQuery.validator.messages, {
required: "Mandatory Field"
})
}
@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 / 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
# spec/factories/my_files.rb
FactoryGirl.define do
factory :my_file do
photo Rack::Test::UploadedFile.new(File.open(File.join(Rails.root, '/spec/fixtures/myfiles/myfile.jpg')))
end
end
process :get_geometry
def geometry
@geometry
end
def get_geometry
if (@file)
img = ::Magick::Image::read(@file.file).first
@geometry = [ img.columns, img.rows ]
end
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