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
Delayed::Worker.logger = ActiveSupport::BufferedLogger.new("log/#{Rails.env}_delayed_jobs.log", Rails.logger.level) | |
Delayed::Worker.logger.auto_flushing = 1 | |
if caller.last =~ /.*\/script\/delayed_job:\d+$/ | |
Rails.logger = Delayed::Worker.logger | |
ActiveRecord::Base.logger = Delayed::Worker.logger | |
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
<html> | |
<head> | |
<title>my title</title> | |
</head> | |
<body> | |
<script> | |
document.body.style.background = 'lightgreen'; | |
document.write("<div style='font-family:Arial,sans-serif;font-size:14pt;font-weight:bold;'>Hello, world! Isn't life great?</div>"); | |
</script> | |
<noscript> |
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
require 'sinatra' | |
require 'rubygems' | |
require 'open-uri' | |
require 'nokogiri' | |
get '/' do | |
doc = Nokogiri::HTML(open("http://www.google.com")) | |
balls = [] | |
doc.css('a').each do |node| |
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
def current_language | |
# if a "lang" URL parameter is specified, force it | |
return params[:lang] if params[:lang].present? | |
# if the user is logged in, use their language preference stored in the DB | |
return current_user.language if logged_in? | |
# if the user has manually selected a language, return that | |
return cookies[:language_code] if cookies[:language_code] | |
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 Rapper | |
attr_accessor :name | |
def initialize(n) | |
self.name = n | |
end | |
def rap(words) | |
puts "Yo yo yo, my name is #{self.name}" | |
puts words | |
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
class Hash | |
def value_at(*keys) | |
begin | |
memo = self.dup | |
keys.each { |key| memo = memo[key] } | |
memo | |
rescue | |
nil | |
end | |
end |
NewerOlder