Skip to content

Instantly share code, notes, and snippets.

View mockra's full-sized avatar

David Ratajczak mockra

View GitHub Profile
var data = <%= @deck.stats.curve.to_json.html_safe %>;
var ctx = document.getElementById("curve").getContext("2d");
new Chart(ctx).Bar(data);
# Output from @deck.stats.curve
{:labels=>["1", "2", "3", "4", "5", "6", "7"],
:datasets=>[{:fillColor=>"rgba(220,220,220,0.5)",
:strokeColor=>"rgba(220,220,220,1)",
:data=>[11, 9, 5, 6, 1, 6, 3]}]}
@mockra
mockra / array_diff.rb
Created June 21, 2013 06:35
Array Diff - find additions and deletions between arrays
class ArrayDiff
attr_reader :one, :two
def initialize one, two
@one, @two = one.to_a, two.to_a
end
def deletions
one_dup = one.clone
two.each { |x| one_dup.slice!(one_dup.index(x)) if one_dup.index(x) }
def set_all args = {}
args.each do |key, value|
send "#{key}=", value
end
end
namespace :ember do
task :update do
[['~/.ember', 'git://github.com/emberjs/ember.js.git', 'ember.js'],
['~/.ember-data', 'git://github.com/emberjs/data.git', 'ember-data.js']
].each { |i| EmberBuild.new(*i).update }
end
end
class EmberBuild
attr_reader :ember_dir, :repo, :file_name, :gem_file
task :cron => [ :environment, :email ] do
end
task :email do
if Time.now.hour % 6 == 0
# Send Email
end
end