Skip to content

Instantly share code, notes, and snippets.

View ruby
ClimateDataIntervals: (self.w_ban_cell_hourlys.select_all.map do |hourly|
hash = {
Year: hourly.Year,
Month: hourly.Month,
Day: hourly.Day,
Hour: hourly.Hour,
GlobalHorizRad_WhPerMeterSquared: hourly.GlobalHorizRad,
DirectNormalRad_WhPerMeterSquared: hourly.DirectNormalRad,
DiffuseHorizRad_WhPerMeterSquared: hourly.DiffuseHorizRad,
DryBulbTemperature_C: (hourly.DryBulbTemperature / 10.0).to_f,
View gist:9474359
rectPosition: (rect) ->
rx = + rect.getAttribute('x')
ry = + rect.getAttribute('y')
rctm = rect.getCTM()
xn = rctm.e + rx * rctm.a
yn = rctm.f + ry * rctm.d
r =
x: xn
y: yn
View app_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
def current_search
Search.find(session[:search_id])
end
def current_search?
session[:search_id].present?
end
@kwerle
kwerle / content_controller_spec.rb
Created Apr 28, 2011
spec/controllers/content_controller_spec.rb
View content_controller_spec.rb
require 'spec_helper'
describe ContentController, :type => :controller do
describe "root" do
it "should work" do
get :index
end
end
end
View muchoutput
#!/usr/bin/ruby
# 40000.times { $stdout << 'x' }
17500.times { $stderr << 'x' }
View test.rb
require 'rubygems'
require "open4"
require "stringio"
require "ruby-debug"
Open4::popen4("./muchoutput") do |pid, stdin, stdout, stderr|
# stdin.puts "echo 42.out"
# stdin.puts "echo 42.err 1>&2"
stdin.close
View gist:559787
for (i=0; i < Math.min(arr_length, 4); i=i+1) {
idx = arr.shift();
new_loading = loading.clone(true);
loading.parentNode.appendChild(new_loading);
new_loading.show();
new Ajax.Updater(new_loading, '/goals/' + idx + '/list',
{ method: 'get',
insertion: 'after',
onSuccess: function(response) { new_loading.remove(); }
});
View gist:559786
for (i=0; i < Math.min(arr_length, 4); i=i+1) {
idx = arr.shift();
new_loading = loading.clone(true);
loading.parentNode.appendChild(new_loading);
new_loading.show();
new Ajax.Updater(new_loading, '/goals/' + idx + '/list',
{ method: 'get',
insertion: 'after',
onSuccess: function(response) { new_loading.remove(); }
});
View gist:371575
def matches?(stringlike)
@document = Webrat::XML.document(stringlike)
@element = @document.inner_text
case @content
when String
@element.gsub(/\s+/, ' ').include?(@content)
when Regexp
@element.match(@content)
end
You can’t perform that action at this time.