Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
File.foreach(ARGV[0], sep="\n") do |input|
puts input.chomp.chars.permutation.map(&:join).sort.uniq.join(',')
end
@pdamer
pdamer / elevator code
Created January 24, 2015 04:07
elevator
{
init: function(elevators, floors) {
elevators.dispatchElevator = function(floorNum, direction) {
if (elevator = elevators.already_going_to(floorNum, direction)) {
if (elevator.destinationQueue.indexOf(floorNum) < 2) {
return true;
}
}
var queues = elevators.map(function(elevator) { return elevator.destinationQueue.length });
var min = queues.slice().sort()[0]
module ActionView
module Template::Handlers
class Nokogiri
# Default format used by Builder.
class_attribute :default_format
self.default_format = Mime::XML
def call template
require 'nokogiri'
@pdamer
pdamer / en.yml
Created December 7, 2012 21:25
add black list to product rule
product_rule:
match_none: none
@pdamer
pdamer / 20120806152326_create_activators.rb
Created October 12, 2012 16:25
Migrate Promotions in spree upgrade to .7
class CreateActivators < ActiveRecord::Migration
def self.up
rename_table 'promotions', 'activators'
rename_column 'activators', 'code', 'to_migrate_code'
rename_column 'activators', 'usage_limit', 'to_migrate_usage_limit'
rename_column 'activators', 'combine', 'to_migrate_combine'
rename_column 'activators', 'match_policy', 'to_migrate_match_policy'
add_column 'activators', 'type', :string