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
puts "Rails environment is #{Rails.env}" | |
products_without_master = Spree::Product.joins('left outer join spree_variants sv on sv.product_id = spree_products.id and sv.is_master = 1').where('sv.id is null').all | |
ids_without_master = products_without_master.map(&:id) | |
puts "Spree products without master variants are #{ids_without_master.count} in number and have ids #{ids_without_master}" | |
updated_at_values = products_without_master.map(&:updated_at) | |
ActiveRecord::Base.transaction do | |
puts "Creating missing master variants inside a transaction..." |
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
function! s:RandomNumber(limit) | |
let components = split(reltimestr(reltime()), '\.') | |
let microseconds = components[-1] + 0 | |
return microseconds % a:limit | |
endfunction | |
function! s:RandomScheme() | |
let choices = [] | |
for fname in globpath(&runtimepath, 'colors/*.vim', 1) | |
let choices += [fnamemodify(fname, ':t:r')] |
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
#!/usr/bin/env bash | |
set -u | |
set -e | |
export GIT_WORK_TREE="/var/www/example.com" | |
export NODE_VERSION="0.10" | |
echo "--> Checking out..." | |
git checkout -f |
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
function! FoldAllBut( foldminlines ) | |
folddoclosed | |
\ if ( (foldclosed(".") >= 0 ) && ( foldclosedend(".") - foldclosed(".") + 1 < a:foldminlines )) | |
\ exe "normal! zO" | |
\ endif | |
endfunction |
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
module Abilities | |
def self.ability_for(user) | |
if user.admin? | |
AdminAbility.new(user) | |
else user | |
MemberAbility.new(user) | |
else | |
GuestAbility.new | |
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
#!/usr/bin/env ruby1.9 | |
# encoding: UTF-8 | |
require 'rubygems' | |
require 'inline' | |
require 'time' | |
class DamerauLevenshtein | |
def distance(str1, str2, block_size=2, max_distance=10) | |
res = distance_utf(str1.unpack("U*"), str2.unpack("U*"), block_size, max_distance) | |
(res > max_distance) ? nil : res |