Skip to content

Instantly share code, notes, and snippets.

View aarongough's full-sized avatar

Aaron Gough (He/Him) aarongough

View GitHub Profile
copied_array = Marshal.load(Marshal.dump(complex_array))
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Simple Form Manipulation</title>
<script type="text/javascript">
function setupForm () {
var policySearchButton = document.getElementById("policy_search_button");
var form = policySearchButton.parentNode;
policySearchButton.onclick = function() {
<script src="http://ajax-gist.com/gist/419993.js" type="text/javascript"></script>
^ Gist ID
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("#clickme").click(function() {
$("#clickme").after("<script src='http:\/\/gist.github.com\/431162.js'><\/script>");
return false;
})
# Synchronous:
Benchmarking 192.168.1.3 (be patient).....done
Document Path: /gist/1010.js
Concurrency Level: 30
Time taken for tests: 18.312 seconds
Complete requests: 100
Requests per second: 5.46 [#/sec] (mean)
Time per request: 5493.543 [ms] (mean)
Time per request: 183.118 [ms] (mean, across all concurrent requests)
blank_object = {
:parent => nil,
:slots => {},
:size => 0
}
def send(receiver, message, *params, &block)
method_owner = receiver
while(method_owner[:slots][:lookup].nil?)
puts "ERR: lookup failed for ':lookup' on object:\n#{receiver.inspect}" and break if(method_owner[:parent].nil?)
method_owner = method_owner[:parent]
end
method = method_owner[:slots][:lookup].call(receiver, message)
exit if(method.nil?)
method.call(receiver, params << block)
end
basic_object = derive_from(blank_object)
basic_object[:slots][:lookup] = Proc.new do |this, message|
method_owner = this
while(!method_owner.nil? && method_owner[:slots][message.to_sym].nil?)
puts "ERR: lookup failed for '#{message}' on object:\n#{this.inspect}" and break if(method_owner[:parent].nil?)
method_owner = method_owner[:parent]
end
method_owner[:slots][message.to_sym] unless(method_owner.nil?)
end
basic_object[:slots][:add_method] = Proc.new do |this, params|
puts "ERR: add_method called without method key" and return unless(params.first.is_a?(String) || params.first.is_a?(Symbol))
puts "ERR: add_method called without block" and return unless(params.last.is_a?(Proc))
this[:slots][params.first.to_sym] = params.last
this[:size] += 1
end
basic_object[:size] = 2