Skip to content

Instantly share code, notes, and snippets.

View brianleroux's full-sized avatar
💚
You are now aware that you are breathing

Brian LeRoux brianleroux

💚
You are now aware that you are breathing
View GitHub Profile
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()
@brianleroux
brianleroux / gist:30113
Created November 28, 2008 22:11
PhoneGap get geolocation
getLocation();
// GAP will invoke this function once it has the location
function gotLocation(lat, lon) {
$('lat').innerHTML = "latitude: " + lat;
$('lon').innerHTML = "longitude: " + lon;
}
@brianleroux
brianleroux / accelerometer
Created November 28, 2008 22:28
PhoneGap Code Samples
function accelerometer() {
$('accel').innerHTML = "accel: " + accelX + " " + accelY + " " + accelZ;
setTimeout(updateAccel, 100);
}
# 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
find . -name .svn -print0 | xargs -0 rm -rf
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 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
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,
<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(){
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;