Skip to content

Instantly share code, notes, and snippets.

View jrallison's full-sized avatar

John Allison jrallison

View GitHub Profile
@jrallison
jrallison / keybase.md
Created March 6, 2014 20:21
keybase.md

Keybase proof

I hereby claim:

  • I am jrallison on github.
  • I am jrallison (https://keybase.io/jrallison) on keybase.
  • I have a public key whose fingerprint is EB89 AFFA 56B8 C4AC 2700 E487 2626 D32F C175 D7F5

To claim this, I am signing this object:

@jrallison
jrallison / a.go
Created March 15, 2015 19:45
Version A
package main
import (
"customerio/core/customers"
"customerio/core/segments"
"customerio/core/spaces"
"flag"
"log"
"strconv"
"time"
@jrallison
jrallison / b.go
Created March 15, 2015 19:46
Version b
package main
import (
"customerio/core/customers"
"customerio/core/segments"
"customerio/core/spaces"
"flag"
"log"
"strconv"
"time"
jQuery("#pages ul li").hover(function(){
jQuery(this).stop(true).animate({
marginTop: "10px"
}, 250);
}, function(){
jQuery(this).stop(true).animate({
marginTop: "0px"
}, 250);
});
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|
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)
var image = new Image();
image.src = url;
image.onload = function() {
// Display image
};
@jrallison
jrallison / parameterized_cache.html.erb
Created January 20, 2011 19:22
Easily mix dynamic content with fragment caching
<% @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 %>
# Model
class Model < ActiveRecord::Base
default_scope where(:hidden => false)
def hide!
update_attributes!(:hidden => true)
end
end
@jrallison
jrallison / gist:977391
Created May 17, 2011 21:02
Everything you need to know about rollout

1) Rollout configuration is in models

/web/models/lib/models/config/rollout.rb

$rollout = Rollout.new(REDIS)

$rollout.define_group(:admin) do |user|
  user.admin?
end