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
# ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9.6.0] | |
user system total real | |
by_define_method 0.680000 0.000000 0.680000 ( 0.700586) | |
by_explicit_definition 0.560000 0.010000 0.570000 ( 0.581977) | |
by_eval 0.550000 0.000000 0.550000 ( 0.553484) | |
by_class_eval 0.540000 0.010000 0.550000 ( 0.561800) | |
by_class_eval_block 0.540000 0.000000 0.540000 ( 0.548041) | |
by_module_eval 0.550000 0.010000 0.560000 ( 0.560635) | |
by_module_eval_block 0.520000 0.000000 0.520000 ( 0.539168) |
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
require 'lib/usher' | |
u = Usher::Interface.for(:text) do | |
on('my name is :name') { |name| | |
puts "hey #{name}, nice to meet you" | |
} | |
on('hey :first_name( :last_name)') {|first_name, last_name| | |
puts last_name ? | |
"how are you doing #{first_name} #{last_name}?" : |
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
require "rubygems" | |
require "rbench" | |
def omg_slow | |
Array['one', 'two', 'three'] | |
end | |
def omg_fast | |
['one', 'two', 'three'] | |
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
#!/usr/bin/env python | |
"""Universal feed parser | |
Handles RSS 0.9x, RSS 1.0, RSS 2.0, CDF, Atom 0.3, and Atom 1.0 feeds | |
Visit http://feedparser.org/ for the latest version | |
Visit http://feedparser.org/docs/ for the latest documentation | |
Required: Python 2.1 or later | |
Recommended: Python 2.3 or later |
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
#!/usr/bin/env ruby | |
require 'pcaplet' | |
Pcaplet.new('-i en1 -s 1500').each do |packet| | |
if packet.class == Pcap::TCPPacket and !packet.tcp_data.nil? | |
words = packet.tcp_data.split | |
words.reject! { |word| word.match(/[^A-Za-z]/) || word.length < 5 } | |
random_word = words[rand(words.size)] | |
system("clear && figlet -c #{random_word}") if random_word | |
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
irb(main):001:0> def my_awesome_sauce; end | |
=> nil | |
irb(main):002:0> methods | |
=> ["chws", "inspect", "irb_kill", "irb_push_binding", "tap", "install_alias_method", "pwws", "context", "clone", "irb_source", "public", "irb_workspaces", "public_methods", "object_id", "__send__", "irb_popws", "instance_variable_defined?", "irb_quit", "irb_change_workspace", "equal?", "freeze", "jobs", "irb_push_workspace", "extend", "irb_load", "send", "irb_print_working_workspace", "methods", "cws", "irb_pushb", "kill", "conf", "hash", "irb_current_working_binding", "dup", "to_enum", "instance_variables", "quit", "popws", "irb_fg", "eql?", "instance_eval", "irb_cwws", "irb", "id", "irb_change_binding", "singleton_methods", "irb_help", "pushb", "exit", "taint", "private", "irb_print_working_binding", "instance_variable_get", "frozen?", "enum_for", "workspaces", "display", "instance_of?", "irb_pop_binding", "method", "to_a", "irb_chws", "irb_pushws", "instance_exec", "type", "irb_require", "irb_pwws", "protected_methods", "irb_cb", " |
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
require('./lib/sherpa') | |
var sys = require("sys"), http = require("http"); | |
http.createServer(new Sherpa.interfaces.NodeJs([ | |
['/hello', function (request, response) { | |
response.sendHeader(200, {"Content-Type": "text/plain"}); | |
response.sendBody("Hello World\n"); | |
response.finish(); | |
}], |
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
crapbook-pro:emjay joshua$ node examples/nodejs/test.js | |
--------------------------------- RENDERED | |
Doing simple output | |
simple output | |
Outputting a variable passed into the template. | |
test title | |
Doing output with mixed in method, tag. | |
<test attr="value"> |
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
> String.prototype.markAsAwesome = function() { | |
> this.awesome = true; | |
> return this; | |
> } | |
> var s = "this is my string"; | |
> puts(inspect(s)); | |
< "this is my string" |
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
(function () { | |
// exports will be set in any commonjs platform. | |
// because the anonymous function is being called without | |
// a scope being set, "this" will refer to the global scope. | |
// In a browser, that's the window. In other JS platforms, | |
// it may be some other thing. | |
var out = typeof exports !== "undefined" ? exports : this; |