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
require 'java' | |
require 'jodconverter-cli-2.2.1.jar' | |
def convert(file_in,file_out) | |
inputFile = java.io.File.new(file_in) | |
outputFile = java.io.File.new(file_out) | |
# connect to an OpenOffice.org instance running on port 8100 | |
connection = com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection.new(8100) | |
connection.connect() |
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
getLocation(); | |
// GAP will invoke this function once it has the location | |
function gotLocation(lat, lon) { | |
$('lat').innerHTML = "latitude: " + lat; | |
$('lon').innerHTML = "longitude: " + lon; | |
} |
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
function accelerometer() { | |
$('accel').innerHTML = "accel: " + accelX + " " + accelY + " " + accelZ; | |
setTimeout(updateAccel, 100); | |
} |
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
# fucking around to hack together the most ghetto date_select known to man | |
require 'date' | |
def date_select( field, options={} ) | |
# wraps content with a specified tag | |
def rapper(tag, options={}) | |
"<#{ tag }>#{ yield if block_given? }</#{ tag }>" | |
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
find . -name .svn -print0 | xargs -0 rm -rf |
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
class InvalidateCachedUnreadPostsCountsAndGenerateAllToSpeedUpLoad < ActiveRecord::Migration | |
def self.up | |
DiscussionGroupUnreadPostsCount.delete_all | |
all_users = User.find(:all) | |
all_users.in_groups_of(100) do |users| | |
fork do | |
# reconnect because forking rapes the connection pool |
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 method is heavily adapted from the Rails method of determining the subdomain. | |
require 'rubygems' | |
require 'sinatra' | |
require 'rack/request' | |
# We re-open the request class to add the subdomains method | |
module Rack | |
class Request | |
def subdomains(tld_len=1) # we set tld_len to 1, use 2 for co.uk or similar |
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
Experiments in revision control: Curry recipe. | |
My personal recipe for Japanese curry, which has mutated over the years and is | |
now open-source thanks to github, hot damn. Some of the ingredients are not | |
very Japanese, but curry came to Japan from England which got it from India to | |
begin with, so whatever. | |
1.5 - 2 lbs. of meat, prefer thin-sliced beef (komagire), pork works, too. | |
Thin-sliced stuff is always best, but in a pinch stewing beef works. Bacon | |
works surprisingly well. Chicken will work, technically, but if you must, |
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
<html> | |
<head> | |
<title>XUI Flickr Example</title> | |
<script type="text/javascript" src="xui.js" charset="utf-8"></script> | |
<script type="text/javascript" charset="utf-8"> | |
x$(window).load(function(e){ | |
// unobtrusive add behavior to thte | |
x$('a.fetch-image').touchstart(function(e){ | |
var url = "http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?"; | |
x$("#imagebox").xhr( url, { callback:function(){ |
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
var kAccelerometerFrequency = 25; //Hz | |
var kFilteringFactor = 0.1; | |
var kEraseAccelerationThreshold = 2.0; | |
var kMinEraseInterval = 0.5; | |
var lastTime = new Date().getTime(); | |
var myAccelerometer = new Array(3); | |
myAccelerometer[0] = 0; | |
myAccelerometer[1] = 0; | |
myAccelerometer[2] = 0; |
OlderNewer