Skip to content

Instantly share code, notes, and snippets.

View codejoust's full-sized avatar

Iain codejoust

View GitHub Profile
/* command "Bible" */
CmdUtils.CreateCommand({
name: "bible",
icon: "http://www.biblegateway.com/favicon.ico",
homepage: "http://www.biblegateway.com/",
author: { name: "CodeJoust", email: "http://codejoust.com/contact"},
license: "GPL",
description: "Search BibleGateway",
help: "BibleGateway: General Search",
takes: {"input": noun_arb_text},
@codejoust
codejoust / PHP Config Class.php
Created October 4, 2009 16:16
PHP5 Config Class.
<?php
class Config{
private static $_data;
private static $_instance;
public function __construct() { }
public static function getInstance(){
@codejoust
codejoust / Domain Replacement for Gmail.user.js
Created October 17, 2009 04:20
Gmail Domain Replacement - Switcher
// ==UserScript==
// @name Gmail Replace Domain
// @author http://codejoust.com
// @namespace http://mail.google.com/
// @description example script to alert "Hello world!" on every page
// @include http://mail.google.com/*
// ==/UserScript==
var your_domain = 'yourdomain.com'; //Your domain to change.
var canvas_frame = document.getElementById('canvas_frame').contentWindow.document; //The Canvas Frame in Gmail
var user_id = canvas_frame.getElementById('guser').getElementsByTagName('b')[0]; //Get the child b element containing username
#!/usr/bin/ruby
class Person
def initialize(name, email)
@name, @email = name, email.gsub('|', '').gsub('*','.')
end
def show_name
@name
end
def visit(site)
if (@data["portfolio"].match(/http:\/\//) && system("firefox #{site}"))
<?php
/**
* The Template for displaying all single product posts.
*/
?>
<?php get_header(); ?>
<div id="content">
<div class="wrap">
<div id="leftcol">
@codejoust
codejoust / api-callback.js
Created August 24, 2011 18:39
JSONP middleware callback.
module.exports = function(opts){
return function(req, res, next){
if ('callback' in req.query){
var callback = req.query.callback.replace(/[^A-Z0-9\.a-z_\$]/g, '');
if (callback.length == 0){
res.setHeader('X-Callback', 'Invalid');
next();
return;
}
var origHead = res.writeHead,
@codejoust
codejoust / import_db.py
Created August 25, 2011 15:40
import_db
import MySQLdb, re
conn = MySQLdb.connect(host = "localhost", user = "testuser", passwd = "testpass", db = "test")
cursor = db.cursor()
datafile = open('taxes.txt')
line = ''
while(line = datafile.readline()):
fields = re.split(r'\|+', line)
@codejoust
codejoust / char_test_reader.c
Created December 14, 2011 02:05
Char Test Reader (Arduino C)
// Arduino Char -> Number over serial. For testing, etc.
// @author Iain Nash iain.in
// @date 12/13/11
//#define PWM_DEMO 1
// ^ uncomment for pwm demo
#define PWM_DEMO 0
// ^ and comment this
int get_serial_num(){
@codejoust
codejoust / arduino_wii.pde
Created December 15, 2011 15:58
arduino_wii
#include <Servo.h>
Servo drive1;
Servo drive2;
void setup(){
Serial.begin(9600);
drive1.attach(5);
drive2.attach(6);
}
@codejoust
codejoust / serial_py.py
Created December 15, 2011 15:59
serial_py
import serial, cwiid, time, sys
print('Place wiimote in discoverable mode now')
wiimote = cwiid.Wiimote()
if not wiimote:
print('cannot find wiimote')
sys.exit()