This file contains 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
require 'googleauth' | |
require 'googleauth/stores/file_token_store' | |
module SEO | |
class Auth | |
OOB_URI = 'urn:ietf:wg:oauth:2.0:oob' | |
USER_ID_KEY = 'GOOGLE_SEARCH_CONSOLE_USER_ID' | |
attr_reader :token_file, :secret, :id |
This file contains 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
# This is for versioning files that we upload to S3. | |
# | |
# We want a unique time stamp in the name, so that we can cache files on browsers without | |
# worrying about cache-busting. | |
# | |
# The tricky part is deciding when to increment the version, this is accomplished | |
# by binding to the +before_cache+ hook. | |
# | |
# All you need to do to use this, is to call "has_versioned_filename" from an uploader, | |
# and add a string column "+mount_name+_version_token" to the model. |
This file contains 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 ManyToMany | |
def intersection(relation, cat_ids) | |
join = cat_ids.map do |cat_id| | |
outer_join_clause(cat_id) | |
end.join(' ') | |
where = cat_ids.map do |cat_id| | |
" cat#{cat_id}.id is not null " | |
end.join(' and ') |
This file contains 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
function logEvent(eventData) { | |
$.ajax({ | |
method: 'post', | |
url: '/analytics-endpoint', | |
data: eventData | |
}); | |
} |
This file contains 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 | |
before_filter :ensure_fresh_i18n | |
private | |
def ensure_fresh_i18n | |
I18n.backend.ensure_freshness! I18n.locale | |
end | |
end |
This file contains 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
# inheritence question: | |
# When mixing in a module, how does super work? | |
# Does it behave the same for protected methods? | |
# And private methods? | |
class Parent | |
def log(name) | |
puts name | |
puts self.class | |
end |
This file contains 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
require 'stringio' | |
class RedisSubscribe < EM::Connection | |
def self.connect(host, port, pass = '') | |
Rails.logger.debug host | |
Rails.logger.debug port | |
client = EM.connect host, port, self | |
client.auth pass if pass.present? |
This file contains 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
function myLib() { | |
return { | |
code: function () {} | |
, goes: function () {} | |
, here: function () {} | |
} | |
} | |
exporter('myLib', myLib); |
This file contains 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
(function () { | |
var initializing = false | |
, superPattern = /xyz/.test(function () { xyz; }) ? /\b_super\b/ : /.*/; | |
Object.subClass = function (properties) { | |
var _super = this.prototype; | |
initializing = true; | |
var proto = new this(); | |
initializing = false; |
This file contains 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
(function () { | |
var initializing = false | |
, superPattern = /xyz/.test(function () { xyz; }) ? /\b_super\b/ : /.*/; | |
Object.subClass = function (properties) { | |
var _super = this.prototype; | |
initializing = true; | |
var proto = new this(); | |
initializing = false; |
NewerOlder