Skip to content

Instantly share code, notes, and snippets.

<!doctype html>
<html ng-app="sampleKinveyApp">
<head>
<meta charset="utf-8">
<title>Bootstrap, from Twitter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
@lime
lime / ApplicationController.rb
Created July 2, 2013 11:11
A workaround for using cancan with strong_parameters, as suggested by AntonTrapp and JiriKolarik in this issue: https://github.com/ryanb/cancan/issues/835#issuecomment-20229737
before_filter do
resource = controller_path.singularize.gsub('/', '_').to_sym
method = "#{resource}_params"
params[resource] &&= send(method) if respond_to?(method, true)
end
begin
require 'launchy'
class Mechanize::Page
def open_in_browser
if body
file = File.new("/tmp/#{Time.now.to_i}.html", 'w')
file.write body
Launchy.open "file://#{file.path}"
system "sleep 2 && rm #{file.path} &"
class Player
constructor: (@node, @src) ->
@init()
init: ->
@node.src = @src
@node.play()
event: (type) ->
Bacon.fromEventTarget(@node, type).map ".currentTarget"
from numpy import *
from scipy.stats import beta
class BetaBandit(object):
def __init__(self, num_options=2, prior=(1.0,1.0)):
self.trials = zeros(shape=(num_options,), dtype=int)
self.successes = zeros(shape=(num_options,), dtype=int)
self.num_options = num_options
self.prior = prior
@lime
lime / update_minimum_version.rb
Created January 1, 2015 18:39
Add current version as a minimum version to gems without version constraints in Gemfile
#!/usr/bin/env ruby
file_name = 'Gemfile'
text = File.read(file_name)
new_contents = text.gsub(/^\s*gem ['"]([\w_\-]+)['"]$/) do
original = Regexp.last_match[0]
gem_name = Regexp.last_match[1]
current_version = Gem.loaded_specs[gem_name].version.to_s
"#{original}, '>= #{current_version}'"
end

Keybase proof

I hereby claim:

  • I am lime on github.
  • I am lime (https://keybase.io/lime) on keybase.
  • I have a public key whose fingerprint is 15DD A4D7 03B7 B759 89B0 CD65 D91B 06E8 58F6 FD9A

To claim this, I am signing this object:

@lime
lime / boot.rb
Last active August 29, 2015 14:22
Change default_options for Rails::Server
# Override default options for server command
# This example changes default development host to 127.0.0.1
require 'rails/commands/server'
module Rails
class Server
new_defaults = Module.new do
def default_options
environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
require 'spec_helper'
FactoryGirl.factories.each do |factory|
describe "The #{factory.name} factory" do
subject { build(factory.name) }
it { should be_valid }
factory.defined_traits.each do |trait|
describe "with trait #{trait.name}" do