Skip to content

Instantly share code, notes, and snippets.

View glongman's full-sized avatar

Geoff Longman glongman

View GitHub Profile
#include "ruby.h"
/*
* Ruby access into the interpreter.
*/
/* Classes */
extern VALUE Z;
class MyModel < ActiveRecord::Base; end
# example model has 3 fields guid, name, and description
# find_or_create_by_name
mymodel = MyModel.find_or_create_by_name(params[:name) do |created|
created.guid = GuidGen.generate
created.description = params[:description]
#import <Foundation/Foundation.h>
/*
* call:
* PrintPathInfo();
*
* params:
* None.
*
* returns:
* nothing (void?)
@glongman
glongman / unreal.html
Created May 4, 2010 04:03
HTML5 web socket bot for Unreal3 Bots. Includes HTML bot impl and ruby proxy server
<html>
<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
<script>
// Note: the Bot implementation is called MYBOT and is defined after UT3BOT.
/* UT3BOT is a Utility that handles initiating the connection to the Unreal server
* via a web socket.
* To begin, you call
http://www2.webkit.org/perf/sunspider-0.9/sunspider.html
TEST COMPARISON FROM TO DETAILS
=============================================================================
** TOTAL **: 1.11x as fast 391.4ms +/- 5.7% 353.0ms +/- 3.8% significant
=============================================================================
diff --git a/monitor.js b/monitor.js
index 6f6d4ec..bc89c96 100644
--- a/monitor.js
+++ b/monitor.js
@@ -19,9 +19,11 @@ db.open(function(p_db) {
app.configure(function(){
app.set('root', __dirname);
app.set('db', db);
- app.use(express.staticProvider(__dirname + "public"));
- app.use(express.cookieDecoder);
require.paths.unshift(__dirname + '/lib');
require.paths.unshift(__dirname);
require.paths.unshift(__dirname + '/deps/express/lib')
var sys = require('sys'),
fs = require('fs'),
mongo = require('deps/node-mongodb-native/lib/mongodb'),
svc = require('service_json'),
weekly = require('weekly');
require 'test/unit'
class LuhnTest < Test::Unit::TestCase
def luhn_valid?(s)
return false unless s && s.is_a?(String)
return false if s.empty?
value = s.gsub(/\D/, '')
return false if value.empty?
value.
@glongman
glongman / bootstrap.rb
Created March 3, 2012 20:02 — forked from jamiepenney/bootstrap.rb
Form builder for Twitter Bootstrap v2 form elements [Fork]
# This file goes in config/initializers
require 'bootstrap_form_builder'
# Make this the default Form Builder. You can delete this if you don't want form_for to use
# the bootstrap form builder by default
ActionView::Base.default_form_builder = BootstrapFormBuilder::FormBuilder
# Add in our FormHelper methods, so you can use bootstrap_form_for.
ActionView::Base.send :include, BootstrapFormBuilder::FormHelper
@glongman
glongman / gist:2295280
Created April 3, 2012 20:27
My unsubmitted carrierwave-mongoid issue

Environment:

MacOSX 10.6.8 Ruby 1.9.3-p125 MongoDB

db version v2.0.3, pdfile version 4.5
Tue Apr  3 14:47:32 git version: 05bb8aa793660af8fce7e36b510ad48c27439697

Rails 3.2.1