Skip to content

Instantly share code, notes, and snippets.

View rickosborne's full-sized avatar

Rick Osborne rickosborne

View GitHub Profile
@rickosborne
rickosborne / couchdbx-core-builder-leopard.sh.patch
Created May 23, 2010 01:31
Patch against lstoll's couchdbx-core to allow fine-grained control of 32/64-bit builds
diff --git a/couchdbx-core-builder.sh b/couchdbx-core-builder.sh
index 9196441..8e3c4d6 100755
--- a/couchdbx-core-builder.sh
+++ b/couchdbx-core-builder.sh
@@ -7,11 +7,17 @@
# customise here:
-# use full svn path for branches like "branches/0.9.x"
+# Valid repos: "git", "github", "svn" (default)
@rickosborne
rickosborne / pe4-github.md
Created April 16, 2011 20:41 — forked from rickofs/pe4-github.md
Rick O's fork of RickOFS's original Gist

For my Relevant & Innovative Learning Scenario (RILS), I’ve chosen to use GitHub.com to show instructors for online classes how they can work in projects with similar patterns to how they would in physical classrooms.

GitHub started with a simple concept: easy source code hosting using Git, a software package designed to help teams track changes to their code. Because of its free and Open Source nature, it has since been adopted and adapted to suit needs beyond its original intent. I’ve been using Git and GitHub in the classroom for almost 2 years now and both have been amazingly helpful. But I think that GitHub’s slick user-friendly web interface to Git could be applied to more classrooms than just those with heavy development focus.

I’m a problem-solver. I love to pick and poke at something until I understand it. So when Rena expressed frustration at being able to track activity in the Literature Review assignments, I immediately started picking at the problem to see where I cou

@rickosborne
rickosborne / rick-cant-do.js
Created April 24, 2011 05:59
JavaScript var hoisting
(function(items) {
var taxFuncs = [];
for(var x in items) {
taxFuncs.push(function(){
return x * 1.1;
});
}
return taxFuncs;
})([5,10,20])[1](); // returns 22, not 11
@rickosborne
rickosborne / gist:1079133
Created July 12, 2011 22:24
Enforced getters and setters in JavaScript?
var o = (function(){
var properties = {
color : { value: "red" },
size : { value: "large", set: false },
secret : { value: "cookies", get: false }
};
return {
// this only exists in Mozilla?
__noSuchMethod__: function (name, args) {
// the name argument is the called method
var makeSandwich = function (bread, meat) {
var sandwich = "My sandwich is " + meat + " on " + bread + ".";
return sandwich;
};
console.log(makeSandwich("rye","roast beef"));
var toppingAvailable = function (topping) {
var available = {
"pepperoni": true,
"mushrooms": true
CREATE TABLE friends (
person1 INT NOT NULL,
person2 INT NOT NULL,
PRIMARY KEY (person1, person2)
);
SELECT p.*
FROM people AS p
INNER JOIN (
SELECT person1 AS friend
@rickosborne
rickosborne / prime-generator.txt
Last active December 18, 2015 13:28
(re)Learning CoffeeScript. Decided to build a prime number generator.
$ time ./primes-c 10000000 > primes10M.csv
real 2m23.426s
user 2m20.229s
sys 0m0.329s
$ time coffee primes.coffee 10000000 > primes10M.csv
real 5m35.077s
user 5m6.806s
@rickosborne
rickosborne / java-downgrade
Created August 12, 2013 18:10
The semi-officially-sanctioned instructions from Apple on how to revert to Java 6.
#!/bin/sh
sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws
@rickosborne
rickosborne / catch-up-branches
Last active December 22, 2015 07:59
Rebase a bunch of branches in a safe(r) way.
#!/bin/bash
# Attempt to do the equivalent of:
# massrebase = "!sh -c 'for branch in $@; do git rebase $0 $branch; done;'"
if [[ -z "${SOURCE_BRANCH}" ]] ; then
SOURCE_BRANCH='origin/master'
fi
# Import some helper functions
function rain(heights) {
var maxHeight = Math.max.apply(Math, heights), rightSide = heights.length - 1;
var left, right, newLeft, newRight;
for (left = 0; heights[left] < maxHeight; left++);
for (right = rightSide; heights[right] < maxHeight; right--);
var pooled = 0;
for (var height = maxHeight; height > 0; height--) {
for (newLeft = left - 1; newLeft >= 0; newLeft--) {
if (heights[newLeft] == height) {
left = newLeft;