Skip to content

Instantly share code, notes, and snippets.

View tessro's full-sized avatar

Tess Rosania tessro

View GitHub Profile
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.Recognition;
using System.Net;
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN" "http://www.w3.org/TR/speech-grammar/grammar.dtd">
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
http://www.w3.org/TR/speech-grammar/grammar.xsd"
xml:lang="en-US"
version="1.0"
root="command"
@tessro
tessro / gist:171195
Created August 20, 2009 16:56
Triangle Problem
#!/usr/bin/ruby
numOfTrials = 10000
numTriangles = 0
numOfTrials.times do
# generate two random breaks, in order
breaks = [ rand, rand ].sort
# load the length calculations via the breaks into an "lengths" array
@tessro
tessro / jquery.selection.js
Created September 18, 2009 15:42
A quick cross-browser jQuery plugin to select the contents of a node.
jQuery.fn.selectAll = function() {
return this.each(function() {
if (document.body.createTextRange) { // MSIE
var r = document.body.createTextRange();
r.moveToElementText(this);
r.select();
} else if (window.getSelection) { // W3C
var r = document.createRange();
r.selectNodeContents(this);
#!/usr/bin/env ruby
# http://www.facebook.com/careers/puzzles.php?puzzle_id=7
# Memory-heavy but low-computation solution
LOOP = [nil, nil, "Hoppity", nil, "Hophop", "Hoppity", nil, nil, "Hoppity", "Hophop", nil, "Hoppity", nil, nil, "Hop"]
File.open(ARGV[0], 'r') do |f|
f.readline.to_i.times do |i|
puts LOOP[i] unless LOOP[i].nil?
#!/usr/bin/env ruby
# usage: ./family.rb [trials]
# Family problem, 1000000 trials:
#
# 997496 girls, 1000000 boys
# 1.997496 children per family
# 0.997496 girls per boy
#
# Ran in 15.508096s
@tessro
tessro / redis-server
Created December 16, 2009 14:20
A CentOS initscript for Redis
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
#!/bin/sh
### BEGIN INIT INFO
# Provides: [app]
# Required-Start: $local_fs $remote_fs $network $syslog $nginx $mysql
# Required-Stop: $local_fs $remote_fs $network $syslog $nginx $mysql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the [app] app server
# Description: starts the [app] app server
@tessro
tessro / deploy.rb
Created May 15, 2010 21:15
Capistrano deployment script for JRuby/GlassFish gem.
set :application, "example_app"
set :domain, "example-app.com"
## IMPORTANT: "true" prevents the server from booting properly
## This line is sometimes recommended in other Capistrano configurations,
## but do not use it for GlassFish.
# default_run_options[:pty] = true
set :scm, :git
set :repository, "git@github.com:paulrosania/example_app.git"
#!/bin/sh
### BEGIN INIT INFO
# Provides: example_app
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the example_app app server
# Description: starts the example_app app server