Skip to content

Instantly share code, notes, and snippets.

View jfernandez's full-sized avatar
🦀
Rust and eBPF

Jose Fernandez jfernandez

🦀
Rust and eBPF
View GitHub Profile
<a href="http://twitter.com/share"
data-url="{{ tld }}/{{ current_page }}?analytics=tracking_here"
class="twitter-share-button"
data-text="{{ offer.reward }} Rakeback at {{ offer.name }}"
data-count="vertical"
data-via="your_twitter_name">Tweet</a>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
- link_to "http://certify.gpwa.org/verify/pokeraffiliatesolutions.com/", :onlick => "return GPWAVerificationPopup(this)", :id => "GPWASeal" do
= image_tag "http://certify.gpwa.org/seal/pokeraffiliatesolutions.com/", :onerror => "this.width=0; this.height=0;"
@jfernandez
jfernandez / gist:722335
Created November 30, 2010 20:26
Active users in the last 15 minutes with Redis
# Adds a User ID to a sorted set using the current timestamp as the score
redis = Redis.new
redis.zadd("active-users", Time.now.to_i, user.id)
# Get all User IDs with a timestamp within the timestamp range
user_ids = redis.zrangebyscore("active-users", 15.minutes.ago.to_i, Time.now.to_i)
@jfernandez
jfernandez / gist:720630
Created November 29, 2010 21:11
Active users in the last 5 minutes
# Inside the controller code that fetches the logged in user for every request
# Note: Trying to call EXPIRE against a key that already has an associated timeout will not change the timeout of the key, but will just return 0
redis = Redis.new
minutes = 5
seconds = minutes * 60
redis.multi do
redis.sadd("active-users", user.id)
redis.expire("active-users", seconds)
class Dream
def inception(idea)
time_multiplier = 1
return enter_dream(idea, time_multiplier)
end
def enter(idea, time_multiplier)
time_multiplier = time_multiplier / 2
if idea.has_taken_root?
module PAS
RedisConfig = File.join(Rails.root, "config", "redis.yml")
def self.redis
return @redis if @redis
@redis = Redis.new(YAML::load(File.open(RedisConfig)))
end
def self.redis=(redis)
@redis = redis
module ActionMailer
class Base
def template_path
File.join(template_root, mailer_name)
end
end
end
map.resources :users do |users|
users.resources :events
end
jose:~ → rvm gemset copy ree-1.8.7-2010.01 ree-1.8.7-2010.02
info: Copying gemset from ree-1.8.7-2010.01 to ree-1.8.7-2010.02
info: Making gemset for ree-1.8.7-2010.02 pristine.
ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.
/Users/jose/.rvm/rubies/ree-1.8.7-2010.01/bin/ruby extconf.rb
creating Makefile
require 'rack-rewrite'
DOMAIN = 'www.production-hacks.com'
# Redirect to the www version of the domain in production
use Rack::Rewrite do
r301 %r{.*}, "http://#{DOMAIN}$&", :if => Proc.new {|rack_env|
rack_env['SERVER_NAME'] != DOMAIN && ENV['RACK_ENV'] == "production"
}
end