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
# use "git clone git://github.com/deadprogrammer/spork.git" to install | |
# spork into your directory | |
require 'rubygems' | |
require 'eventmachine' | |
require 'rocket-amf/lib/rocketamf' | |
require 'spork' | |
module SocketSampleServer | |
def post_init |
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
# The current "best way" to get the absolute path of the current script in Ruby, | |
# as far as I know.... | |
require 'pathname' | |
$prefix = Pathname.new(File.dirname(__FILE__)).realpath |
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
# the names that are generated for cards are designed to correlate | |
# with the naming system used for this SVG-formatted deck of cards | |
# http://david.bellot.free.fr/svg-cards/ | |
class Object | |
def blank? | |
self.nil? || (self.respond_to?(:empty?) && self.empty?) | |
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
#!/usr/bin/env ruby | |
require 'open-uri' | |
require 'net/http' | |
require 'uri' | |
require 'pp' | |
require 'rubygems' | |
require 'json' | |
# This is my modified version of defunkt's gist.rb | |
# http://github.com/defunkt/gist/blob/master/gist.rb |
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 exposes the root folder of your app through WebDAV, for remote editing. | |
# * I still need to implement http basic auth http://www.gittr.com/index.php/archive/sinatra-basic-authentication-selectively-applied/ | |
# * I want to find a DAV-powered way to restart the app once changes have been made.... | |
require 'rubygems' | |
require "rack_dav" | |
use Rack::CommonLogger | |
run RackDAV::Handler.new(:root => File.dirname(__FILE__)) |
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
# script for making audio or video playlists which play in the browser | |
# but which also work as playlists on the iPhone. | |
# | |
# example: | |
# playlist %w[one.mp3 two.mp3 three.mp3] | |
# | |
# sources: | |
# http://stackoverflow.com/questions/87290/how-to-embed-audio-video-on-html-page-that-plays-on-iphone-browser-over-gprs | |
# http://broadcast.oreilly.com/2009/04/iphone-web-audio-playlistshtml.html | |
# http://jchrisa.net/drl/_design/sofa/_show/post/web_audio_for_the_iphone |
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
# Start a thin server on the side, which can serve UI to the user in a | |
# WebView. That way you can make RubyCocoa UI with HTML, thanks to Sinatra. | |
require 'osx/cocoa' | |
OSX.require_framework 'WebKit' | |
class ThinDesktopController < OSX::NSObject | |
include OSX | |
ib_outlets :webView | |
ib_action :quitApp |
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
# retrieve a filename from a URL | |
require 'uri' | |
url = "http://threeve.org/blog/2008/01/run-ruby-script-automator-action.html" | |
uri = Uri.parse(url) | |
basename = File.basename(uri.path) |
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
// Simple JavaScript Templating | |
// John Resig - http://ejohn.org/ - MIT Licensed | |
// modified by Roger Jungemann - MIT License | |
// this version is designed to work under node.js | |
var cache = {}; | |
String.tmpl = function(str, data) { | |
// Figure out if we're getting a template, or if we need to | |
// load the template - and be sure to cache the result. | |
var fn = !/\W/.test(str) ? |
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
/* randomUUID.js - Version 1.0 | |
* | |
* Copyright 2008, Robert Kieffer | |
* | |
* This software is made available under the terms of the Open Software License | |
* v3.0 (available here: http://www.opensource.org/licenses/osl-3.0.php ) | |
* | |
* The latest version of this file can be found at: | |
* http://www.broofa.com/Tools/randomUUID.js | |
* |