This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 == "") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FormValidator = function(form){ | |
this.forms = form || $("form[data-validate=true]"); | |
this.setDefaults = function(){ | |
$.validator.setDefaults({ | |
errorElement: "span" | |
}) | |
$.extend(jQuery.validator.messages, { | |
required: "Mandatory Field" | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ui-autocomplete { | |
position: absolute; | |
top: 100%; | |
left: 0; | |
z-index: 1000; | |
float: left; | |
display: none; | |
min-width: 160px; | |
_width: 160px; | |
padding: 4px 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |