Skip to content

Instantly share code, notes, and snippets.

View joshbuddy's full-sized avatar
🤡
meow

Joshua Hull joshbuddy

🤡
meow
View GitHub Profile
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}?" :
#!/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
@joshbuddy
joshbuddy / output
Created October 24, 2009 18:58 — forked from jpignata/output
#!/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
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", "
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();
}],
> String.prototype.markAsAwesome = function() {
> this.awesome = true;
> return this;
> }
> var s = "this is my string";
> puts(inspect(s));
< "this is my string"
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">
(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;
>> Anybase::Base73ForURL.to_native((1 << 128)-1)
=> "Se'IgbSCfu$0)cMM(odbD"
>> Anybase::Base73ForURL.to_native((1 << 128)-1).size
=> 21
>> Anybase::Hex.to_native((1 << 128)-1)
=> "ffffffffffffffffffffffffffffffff"
>> Anybase::Hex.to_native((1 << 128)-1).size
=> 32
@route_set = Usher::Interface.for(:rack)
@route_set.get("/static").serves_static_from('/public/file/root')
# serves files from /public/file/root on any request starting with /static