Skip to content

Instantly share code, notes, and snippets.

View kwerle's full-sized avatar

Kurt Werle kwerle

View GitHub Profile
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
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(); }
});
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(); }
});
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
#!/usr/bin/ruby
# 40000.times { $stdout << 'x' }
17500.times { $stderr << 'x' }
@kwerle
kwerle / content_controller_spec.rb
Created April 28, 2011 17:26
spec/controllers/content_controller_spec.rb
require 'spec_helper'
describe ContentController, :type => :controller do
describe "root" do
it "should work" do
get :index
end
end
end
class ApplicationController < ActionController::Base
protect_from_forgery
def current_search
Search.find(session[:search_id])
end
def current_search?
session[:search_id].present?
end
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
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,