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
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
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?
@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)
@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)
- 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;"
<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>
<iframe src="http://www.facebook.com/plugins/like.php?href={{ current_page_url | html_escape }}&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require 'resque/server'
run Rack::URLMap.new \
"/" => Mailto::Application,
"/resque" => Resque::Server.new
@jfernandez
jfernandez / gist:1051472
Created June 28, 2011 16:00
Commits in branch2 missing from branch1 by author
git log <branch1>..<branch2> --author=<pattern>
#!/bin/bash
############################################################################
# Script to open a directory in TextMate excluding certain directories that
# tend to slow down the Find in Project... function.
#
# Place in an executable loctation with a name of your choosing.
# I use `ate' and have it in ~/Local/bin (which has been added to $PATH)
############################################################################