This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copied_array = Marshal.load(Marshal.dump(complex_array)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://ajax-gist.com/gist/419993.js" type="text/javascript"></script> | |
^ Gist ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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; | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blank_object = { | |
:parent => nil, | |
:slots => {}, | |
:size => 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
basic_object[:size] = 2 |