Skip to content

Instantly share code, notes, and snippets.

View tildedave's full-sized avatar
🌮
Hungry

Dave King tildedave

🌮
Hungry
View GitHub Profile
@tildedave
tildedave / ruby-1.8.7-is-poorly-scoped.rb
Created December 2, 2010 14:03
from Andrew Kennedy
# scoping in ruby 1.8.7
x = 0
[1,2,3].each{|x| puts x}
puts x
;; Directory Conversion Functions
(defun list-to-directory (list)
(let (value)
(dolist (element list value)
(setq value (file-name-as-directory (concat value element))))))
(defun path-to-file (path filename)
(concat (list-to-directory path) filename))
@tildedave
tildedave / smixinstall.pl
Created January 27, 2011 13:38
Install useful maven target installations into ServiceMix hotdeploy directory
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use File::Copy;
use Getopt::Long;
my $smix_directory = "";
@tildedave
tildedave / automated-war-deploy.pl
Created January 31, 2011 21:41
Watch a WAR file for changes, and then deploy it to the root of a running tomcat instance.
#!/usr/bin/perl
use strict;
use warnings;
use File::Monitor;
use File::Path::Expand;
use File::Copy;
use File::Remove;
use App::Rad;
module CuckooHash
where
import Data.Array
import Data.Maybe
data Cell a b = EmptyCell | Cell a b
deriving Show
type HashArray a b = Array Int (Cell a b)
module KataRomanCalculator
where
import Test.HUnit
import qualified Data.String.Utils as StringUtils
data RomanNumeral = RomanNumeral String
deriving (Show, Eq)
strip n (RomanNumeral s) = (RomanNumeral (drop n s))
@tildedave
tildedave / php-scoping.php
Created February 25, 2011 15:19
scoping in php for static/non-static methods + inheritance
class A
{
function foo()
{
if (isset($this)) {
echo '$this is defined (';
echo get_class($this);
echo ")\n";
} else {
echo "\$this is not defined.\n";
@tildedave
tildedave / mock-restful.clj
Created March 12, 2011 12:36
Mock Restful Server: endpoint for your clients, just add moustache routes
(ns mock-restful.core
(:use net.cgrand.moustache
ring.util.response
ring.middleware.params
clojure.contrib.logging
[ring.adapter.jetty :only [run-jetty]]))
(defn remember-request [request]
(do
(log :info (format "%s %s" (:request-method request) (:uri request)))
@tildedave
tildedave / action-result.cs
Created March 23, 2011 02:04
Coerce an MVC ActionResult to a subclass as part of a unit test
private static T IsResult<T>(ActionResult result) where T : ActionResult
{
Assert.IsInstanceOf<T>(result);
return (T)result;
}
@tildedave
tildedave / TooManyMembers.java
Created April 27, 2011 01:19
Too many members, OO fail
protected Map<JLiftVarLabel, Node> variableToNodeMap;
protected MultiMap<JLiftVarLabel, JLiftVarLabel> directVariableAffectMap;
protected MultiMap<JLiftVarLabel, JLiftVarLabel> directVariableAffectingMap;
protected MultiMap<Node, Label> specialSinks;
protected Map<Node, JLiftVarLabel> nodeToVariableMap;
protected Map<JLiftVarLabel, Collection<JLiftVarLabel>> cacheVarLabelAffectMap;
protected Map<JLiftVarLabel, Collection<JLiftVarLabel>> cacheVarLabelAffectingMap;