Skip to content

Instantly share code, notes, and snippets.

@lime
lime / grep-modernizr-v2.8.3.sh
Last active December 21, 2016 13:33
Find Modernizr CSS classes in Rails
# Modernizr 2.8.3, list collected from https://github.com/Modernizr/Modernizr/tree/v2.8.3
git grep -E '\.(no-)?(js|adownload|apng|applicationcache|audio|audiodata|backgroundsize|battery|bgpositionshorthand|bgpositionxy|bgrepeatround|bgrepeatspace|blobconstructor|blobworkers|borderimage|borderradius|boxshadow|canvas|canvastext|classlist|contenteditable|contentsecuritypolicy|cookies|cors|createelement|cssanimations|csscalc|csscolumns|cssfilters|cssgradients|cssmask|csspositionsticky|cssreflections|cssremunit|cssresize|cssscrollbar|csstransforms|csstransforms3d|csstransitions|cssvhunit|cssvmaxunit|cssvminunit|cssvwunit|cubicbezierrange|customprotocolhandler|dart|datalistelem|dataset|datauri|dataview|dataworkers|details|devicemotion|deviceorientation|display|draganddrop|emoji|eventsource|exif|fileinput|filereader|filesystem|flexbox|flexboxlegacy|fontface|formvalidation|framed|fullscreen|gamepads|generatedcontent|geolocation|getusermedia|hashchange|history|hsla|ie8compat|indexedDB|inlinesvg|json|lastchild|localize
@lime
lime / application.scss
Created September 28, 2016 12:05
Optional @import in sass / sass-rails
// ...
// -----------------------------------------------------------------------------
// Import JS generated CSS
// -----------------------------------------------------------------------------
@import "OPTIONAL:../javascripts/bundle/jscss/main";
@import "OPTIONAL:../javascripts/bundle/jscss/admin";
@lime
lime / .phraseapp.yml
Last active August 16, 2016 12:23
Generate .phraseapp.yml for multiple locale files in Rails
---
phraseapp:
project_id: YOUR-PROJECT-ID
file_format: yml
push:
sources:
- file: config/locales/activerecord.<locale_name>.yml
params:
tags: activerecord
update_translations: true
@lime
lime / 01_script.sh
Last active April 19, 2016 21:54
shrinkpack with glob.sync performance
npm shrinkwrap && ~/code/Syrupy/scripts/syrupy.py ~/code/shrinkpack/index.js
@lime
lime / rbenv-patch
Last active January 28, 2016 15:28 — forked from philou/rbenv-patch
This script uses skaes/rvm-patchsets to patch a ruby-build package before installing it with rbenv. It uses ruby 2.1.2 with all patches in the railsexpress patchset, but it should work with any ruby / patch as long as they are compatible.
#!/bin/sh
mkdir /tmp/ruby-build-patch
cd /tmp/ruby-build-patch
# download the patches
git clone git@github.com:skaes/rvm-patchsets.git
# download and rename the ruby-build version definition
wget https://raw.github.com/sstephenson/ruby-build/master/share/ruby-build/2.1.2
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
@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'

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 / 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
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