Skip to content

Instantly share code, notes, and snippets.

@jabley
jabley / code_event.rb
Last active December 11, 2015 04:48
Initial exercise at the Developing Project Guidance through Code History Mining workshop
# This was a minor addition to the provided code_event.rb class
def dir_name
File.dirname(file_name)
end
(fn [sos]
(letfn [
(combine [x y]
(let [diff [nil (.toUpperCase (str (clojure.set/difference x y)))] ]
(conj (clojure.set/intersection x y) diff)))
(remove-dontcares [minterms] (set (remove vector? minterms)))
(get-off-by-ones [all-minterms [current-key current-vals]]
(let [
off-by-one
(map #(combine current-key %)
@jabley
jabley / gist:3722616
Created September 14, 2012 15:25
bash script to rename files with extension handling
for f in $(ls); do table="${f%.*}"; mv "${table}.csv" "${table}_DATA_TABLE.csv"; done
@jabley
jabley / convert2csv.sh
Created September 13, 2012 11:05
Scripts to help with converting an Oracle .dmp to CSV
#!/bin/sh
# script to automate the load and export to CSV of an oracle dump
# This script assumes:
# * you have the vagrant published key available locally in your .ssh directory
# * You have the Oracle VirtualBox image running locally
# ** ssh port-forwarding is configured for host port 2022 -> guess port 22.
set -e
@jabley
jabley / oracle2mysql.sed
Created July 12, 2012 10:43
Help convert Oracle DDL to MySQL
s/NUMBER(22,0)/BIGINT/
s/NUMBER(9,0)/INT/
s/NUMBER(8,0)/INT/
s/NUMBER(6,0)/MEDIUMINT/
s/NUMBER(5,0)/SMALLINT/
s/NUMBER(3,0)/TINYINT/
s/NUMBER(2,0)/TINYINT/
s/NUMBER(1,0)/BIT/
s/NUMBER(16,2)/DECIMAL(16,2)/
s/NUMBER(11,2)/DECIMAL(11,2)/
@jabley
jabley / prettyjson.scala
Created March 15, 2012 14:28
How to pretty print a large json document
:cp /Users/jabley/.m2/repository/com/google/code/gson/gson/2.1/gson-2.1.jar
import java.io.{OutputStreamWriter, FileOutputStream, FileReader}
import com.google.gson.{GsonBuilder, JsonParser}
val gson = new GsonBuilder().setPrettyPrinting().create()
val json = new JsonParser().parse(new FileReader("get-menu-and-start-order.json"))
val fos = new FileOutputStream("get-menu-and-start-order.pretty.json")
val writer = new OutputStreamWriter(fos)
gson.toJson(json, writer)
@jabley
jabley / generate_log
Created March 6, 2012 09:35
grep pipe filters broken on OSX Lion
#!/bin/sh
# Script to generate logging output
while true; do
echo $(date +%Y-%m-%dT%H-%M-%S) "WARN Here is a log message about events"
sleep 1;
done
@jabley
jabley / gist:1892225
Created February 23, 2012 10:48
Javascript function to iterate an array of functions, returning the first truthy result
function findResult(fns, args, fallback) {
var result;
for (var i = 0; i < fns.length; ++i) {
result = fns[i].apply(null, args);
if (result) {
return result;
}
}
return fallback;
}
@jabley
jabley / video-events.js
Created January 27, 2012 10:58
Script to show video events in HTML5
// Investigating http://www.w3.org/2010/05/video/mediaevents.html
// Firefox creates pause and play events when seeking / seeked on a playing video, Chrome does not.
// Execute this script in Firebug console or similar to capture events
var script = document.createElement("script");
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js";
document.getElementsByTagName("head")[0].appendChild(script);
$("#video").bind("play", function() {console.log("play " + new Date()); })
$("#video").bind("pause", function() {console.log("pause " + new Date()); })
@jabley
jabley / quotes.md
Created January 24, 2012 16:00
Various cool-sounding quotes

"Institutions will try to preserve the problem to which they are the solution." -- Clay Shirky