Skip to content

Instantly share code, notes, and snippets.

View rjungemann's full-sized avatar

Roger Jungemann rjungemann

View GitHub Profile
@rjungemann
rjungemann / strftime.js
Created January 31, 2010 01:55
An implementation of strftime for JS
// version 0.11 by Daniel Rench
// More information: http://dren.ch/strftime/
// This is public domain software
Number.prototype.pad =
function (n,p) {
var s = '' + this;
p = p || '0';
while (s.length < n) s = p + s;
return s;
@rjungemann
rjungemann / clouds.html
Created February 1, 2010 06:58
A "moving clouds" example with JQuery
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<!-- An example of using JQuery to make looping clouds. -->
<head>
<title>Transition Test</title>
<style>
#frame {
width: 600px;
@rjungemann
rjungemann / bunk
Created February 2, 2010 04:54
A modifiable script to download a fresh, non-root set of Ruby, gems, and other files in one fell swoop, in a way that's quick and allows the directory to be copied or moved.
# A script to create a new project. Just download, chmod it to 755, then try:
# bunk project_name
project_name = ARGV[0]
`mkdir #{project_name} #{project_name}/lib #{project_name}/bin`
files = {
"LICENSE.txt" => %{(The MIT License)
Copyright (c) 2009 thefifthcircuit.
@rjungemann
rjungemann / DynamicEvent.as
Created February 2, 2010 23:53
ActionScript DynamicEvent, RemoteClass, and RemoteClassSamples
// a simple pure-AS3 DynamicEvent class
package com.thefifthcircuit.utils {
import flash.events.Event;
public dynamic class DynamicEvent extends Event {
public function DynamicEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) {
super(type, bubbles, cancelable)
}
}
}
@rjungemann
rjungemann / locator.as
Created February 3, 2010 23:16
A generic locator class for ActionScript
package com.thefifthcircuit.utils {
public class Locator {
private static var obj:* = {};
private function shallowGet(query:String):* {
var parsed:String = "^" + query + "$";
var matches:Array = [];
for(var key:String in obj) {
if(key.match(new RegExp(parsed))) {
@rjungemann
rjungemann / s3_cost
Created February 22, 2010 23:13
Amazon S3 pricing estimate
# based off of video quality chart at http://chadvonnau.com/youtube.html and
# the Amazon S3 pricing chart at http://aws.amazon.com/s3/#pricing
#
# 2000 users a day for a month, each watching an hour of Hulu-quality video
# would cost $64.79/month.
#
# 5000 users a day for a month, each watching 15 minutes of Hulu-quality video
# would cost $40.49/month.
require 'activesupport'
@rjungemann
rjungemann / watch.js
Created February 23, 2010 19:39
JQuery monitoring DOM properties
// Thanks to James Podolsey for this code, from the "Monitoring DOM
// Properties" article, located at
// http://james.padolsey.com/javascript/monitoring-dom-properties/
jQuery.fn.watch = function(id, fn) {
return this.each(function() {
var self = this, oldVal = self[id];
$(self).data('watch_timer',
setInterval(function() {
@rjungemann
rjungemann / gist:314088
Created February 25, 2010 00:51 — forked from headius/gist:314044
Little Java JS Rhino runner
~/projects/jruby ➔ cat remote_rhino.rb
require 'java'
$CLASSPATH << 'http://mirrors.ibiblio.org/pub/mirrors/maven2/rhino/js/1.7R2/js-1.7R2.jar'
ctx = org.mozilla.javascript.Context.enter
scope = ctx.init_standard_objects nil
result = ctx.evaluate_string scope, 'function f(x){return x+1} f(7)', 'x', 1, nil
puts result
@rjungemann
rjungemann / config.ru
Created February 25, 2010 06:32
Ruby PayPal example
require 'sinatra/base'
module PaypalSample
class App < Sinatra::Base
get "/" do
@business_name = ""
@login = "[email protected]"
@amount = "1.00"
@return_url = ""
@cancel_url = ""
@rjungemann
rjungemann / config.ru
Created February 25, 2010 06:49
Sinatra helper for Cortado Java "HTML 5" movie viewer
require 'sinatra/base'
module CortadoSample
class App < Sinatra::Base
get "/" do
%{<video controls width="640" height="480">
<source src="BigBuckBunny.ogv" type="video/ogg" />
<!--<source src="video.mp4" type="video/mp4" />-->
<applet code="com.fluendo.player.Cortado.class" archive="cortado.jar" width="640" height="480">