This file contains hidden or 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
| This is the talk that I just gave at the LA Ruby Meetup, minutes ago. | |
| It was on the Watts not-framework. Watts can be found at | |
| http://github.com/pete/watts , which has documentation and examples. | |
| The "slide deck" is the text file below, which was run through a small | |
| Ruby script that recognized "-- $header" as delimiters. | |
| Enjoy. | |
| Update 2013-01-28: There was a bug in Watts, and in this presentation, | |
| specifically that unknown methods ought to be responded to with a "501 Not |
This file contains hidden or 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 'time' | |
| Commands = { | |
| :git => 'git annotate %s', | |
| :svn => 'svn blame --force %s', | |
| } | |
| Filters = Hash.new(lambda { |line| line }) |
This file contains hidden or 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
| I turned this gist into a "real" repository. It is here: http://github.com/pete/cats . | |
| Here, placed side-by-side for comparison, are GNU's implementation of | |
| cat, Plan 9's implementation, Busybox's implementation, and NetBSD's | |
| implementation, Seventh Edition Unix (1979), and 4.3BSD. | |
| For good measure (and because I suppose I am now committed to collecting | |
| cats) also included are Second Edition Unix (in assembly) and Inferno's | |
| implementation (in Limbo) for good measure. |
This file contains hidden or 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
| # These are the defaults that you're likely to want to change. They can be set | |
| # in your environment as well. It's just shell, so you can do arbitrary things | |
| # here if you want. | |
| ptfontsize=16 | |
| ptdim=158x20 | |
| ptfg='#FFEDB3' | |
| ptbg='#262C42' | |
| ptbindkey=F23 |
This file contains hidden or 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 | |
| # "Fork and Forget" | |
| # Don't wait if you don't have to: A mini-tutorial about concurrency | |
| # mechanisms in Ruby and basic Unix systems programming, and how you can use | |
| # them to avoid waiting. | |
| # | |
| # I have heard that people are occasionally unfamiliar with this strategy. | |
| # It's a common idiom, regardless of language, and it is also essentially built | |
| # into Erlang (and Termite Scheme, etc.). | |
| # |
This file contains hidden or 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
| # This file was written so that this line of code would do a valid thing in | |
| # Ruby: | |
| # Object.effect.affect('@genuflect', :circumspect).collect { |object| object.respect! } | |
| # I'm very sorry, everyone. | |
| class Class | |
| alias_method :effect, :new | |
| class << self; alias_method :architect, :new; end | |
| end |
This file contains hidden or 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
| // Greasemonkey script for murdering AJAX and making sure it's really dead. I | |
| // am mostly using it for Google searches so I don't have to set wacky | |
| // preferences every time I wipe cookies or use a different computer. It's | |
| // useful in lots of places for just totally murdering XHR. | |
| // My usual strategy is to either block hosts at the DNS resolution level | |
| // (PowerDNS and abusing /etc/hosts: these are for the win) and to block Flash | |
| // by default. This piece is for when I want to use a site and its bad | |
| // behavior isn't a result of Flash. |
This file contains hidden or 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 | |
| def handle_input str | |
| if str.nil? | |
| puts "Bye." | |
| exit | |
| end | |
| puts "REVERSO: #{str.reverse}" | |
| end |
This file contains hidden or 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
| new function() { | |
| var ss = document.createElement('style'); | |
| var head = document.getElementsByTagName('head')[0]; | |
| ss.innerHTML = "body p, div { font-size: 1em !important; " + | |
| "font-family: \"Liberation Sans\" !important; }" + | |
| "body { font-size: 1em; font-family: \"Liberation Mono\"; };"; | |
| head.appendChild(ss); | |
| }; |
This file contains hidden or 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
| # By popular request[1], a simple Makefile. It turns one .c file into one | |
| # executable. | |
| # Put the name of the targets here: | |
| TARGETS = hello_world | |
| all: $(TARGETS) | |
| %: %.c | |
| cc $(CFLAGS) $< -o $@ |