Skip to content

Instantly share code, notes, and snippets.

@watsoncj
watsoncj / keybase.md
Created July 5, 2017 20:14
keybase.md

Keybase proof

I hereby claim:

  • I am watsoncj on github.
  • I am watsoncj (https://keybase.io/watsoncj) on keybase.
  • I have a public key ASAJ-bCY6ShGYO1yd600p6221NbRvFKsWaWL7Buk-kfGcwo

To claim this, I am signing this object:

#!/usr/bin/env clj
(println "traditional flow control solution to FizzBuzz")
(defn divides
"check if x is divisible by y without remainder"
[x y]
(= (rem x y) 0))
(loop [i 1]
(if (divides i 15)
@watsoncj
watsoncj / gist:1525043
Created December 27, 2011 20:32
Option pattern from FP for Java Developers
public final class Some<T> extends Option<T> {
private final T value;
public Some(T value) {
this.value = value;
}
public boolean hasValue() {
return true;
}
% cat app/helpers/retailer_helper.rb
# Helper methods defined here can be accessed in any controller or view in the application
Cc.helpers do
def messages
msg=""
if flash.has?(:err) or flash.has?(:ok)
msg<<"<div id='message'>"
if flash.has? :err
msg<<"<div class='err'>#{flash[:err]}</div>"
@watsoncj
watsoncj / sync_music.sh
Created July 5, 2011 14:40
2-Way Folder Sync with Rsync
#!/bin/sh
LOCAL="$HOME/Music"
REMOTE="10.10.10.10:/home/user/Music"
cd $LOCAL
rsync -vaurP . $REMOTE
rsync -vaurP $REMOTE/ .
@watsoncj
watsoncj / gist:1005449
Created June 2, 2011 22:12
pre-commit hook to prevent me from accidentally checking in debug code
#!/bin/sh
#
# This hook prevents you from committing any file containing the
# words "do not commit".
#
# The idea is that I can add a comment to prevent myself from
# committing a change related to debugging or hacking.
#
# To enable this hook, rename this file to ".git/hooks/pre-commit".
@watsoncj
watsoncj / gist:983656
Created May 20, 2011 19:54
strange cherry-pick behavior
$ git show a1e938c -- $RES
commit a1e938c7616dc1b1bbda22f1a0fff3396b86def0
Author: dude <dude@somewhere.com>
Date: Fri May 20 12:30:59 2011 -0600
WATSON-4352 added screens to configure revenue property data
diff --git a/src/java/com/unifocus/watson/resources/WatsonResources.properties b/src/java/com/unifocus/watson/resources/WatsonResources.properties
index 08f7623..db41fe3 100644
--- a/src/java/com/unifocus/watson/resources/WatsonResources.properties
@watsoncj
watsoncj / gist:951816
Created May 2, 2011 15:49
Gem is Broken
$ gem install eventmachine
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
$ gem install timetrap
ssh USER@HOST bzip2 -c /path/to/rootfs.bin | bunzip2 -c | dd of=/dev/sda7