$rollout = Rollout.new(REDIS)
$rollout.define_group(:admin) do |user|
user.admin?
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
jQuery("#pages ul li").hover(function(){ | |
jQuery(this).stop(true).animate({ | |
marginTop: "10px" | |
}, 250); | |
}, function(){ | |
jQuery(this).stop(true).animate({ | |
marginTop: "0px" | |
}, 250); | |
}); |
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
def first_n_primes(n) | |
return [] if n <= 0 | |
@primes ||= [2] | |
x = @primes.last + 1 | |
until @primes.length >= n | |
prime = true | |
@primes.each do |p| |
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
Nameserver trace for challenge.gov: | |
Looking for who is responsible for root zone and followed d.root-servers.net. | |
Looking for who is responsible for gov and followed f.usadotgov.net. | |
Looking for who is responsible for challenge.gov and followed a.ns.zerigo.net. | |
Nameservers for challenge.gov: | |
c.ns.zerigo.net returned (SERVFAIL) | |
a.ns.zerigo.net returned (SERVFAIL) |
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
var image = new Image(); | |
image.src = url; | |
image.onload = function() { | |
// Display image | |
}; |
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
<% @somethings.each do |something| %> | |
<%= cache("somethings:#{something.id}", :time => something.created_at) do %> | |
<div class="something"> | |
<%= render "somethings/expensive_calculation" %> | |
<!-- time.strftime(...) calculated dynamically every time --> | |
<p class="timestamp"><%= time.strftime("%B %d, %Y") %></p> | |
</div> | |
<% 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
# Model | |
class Model < ActiveRecord::Base | |
default_scope where(:hidden => false) | |
def hide! | |
update_attributes!(:hidden => true) | |
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
# In controllers | |
mixpanel("event name") | |
# Anywhere else | |
Mixpanel.new(:event => "event name", :id => some_user.id, :ip => ???).track! | |
# ApplicationController | |
def mixpanel(event, opts = {}) | |
unless current_user.admin? || masquerading? | |
opts = {:event => event, :id => current_user.id, :ip => request.remote_ip}.merge(opts) |
mysql> explain SELECT * FROM `submissions` WHERE `submissions`.`id` = 5334;
+----+-------------+-------------+-------+---------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+-------+---------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | submissions | const | PRIMARY | PRIMARY | 4 | const | 1 | |
+----+-------------+-------------+-------+---------------+---------+---------+-------+------+-------+
1 row in set (0.01 sec)
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
diff --git a/Gemfile b/Gemfile | |
index 861f72a..e63813d 100644 | |
--- a/Gemfile | |
+++ b/Gemfile | |
@@ -5,7 +5,8 @@ gem 'rails', '3.0.10' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
-gem 'sqlite3' | |
+gem 'mysql' |
OlderNewer