This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.io.FileType | |
def files = [] | |
def extensions = ['.groovy', '.md', '.yml', '.gradle', '.json', '.html', '.puml', '.properties'] | |
def foldersToExclude = ['/.gradle/', '/.idea/', '/build/'] | |
def dir = new File("/path/to/checked/out/git/repo") | |
println "dir = $dir" | |
dir.eachFileRecurse (FileType.FILES) { file -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Utility methods to make logging a little cleaner. Instead of having to put | |
* log.isDebugEnabled() (and etc) checks everywhere we want to log to debug, this will do the | |
* check in a single place. And because the strings to log are being passed as a closure, they | |
* will be lazily evaluated. | |
* | |
* Note: this trait assumes there is a "log" variable on the class, presumably injected into | |
* Grails artefacts or through use of the groovy.util.logging.Slf4j annotation. | |
* | |
* Note: updated all methods to static so these can be called from static methods. Required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import grails.async.Promise | |
import grails.async.Promises | |
import scala.concurrent.Future | |
import akka.dispatch.Futures | |
import akka.dispatch.OnComplete | |
import java.util.concurrent.Callable | |
def actorSystem = ctx.getBean('actorSystem') | |
def dispatcher = actorSystem.dispatcher() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gradle tests | |
// single file: | |
gradle -Dtest.single=TestClass :module-name:test --info | |
// single method: | |
gradle :module-name:test --tests *TestClass.methodToTest --info --stacktrace | |
// single test, Grails 3: | |
grails test-app -integration com.mypackage.myapp.MySpec.my_test_which_may_need_underscores_for_this_to_work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# DESCRIPTION: | |
# | |
# Set the bash prompt according to: | |
# * the branch/status of the current git repository | |
# * the branch of the current subversion repository | |
# * the return value of the previous command | |
# | |
# USAGE: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# history tweaks (Setting HISTSIZE and HISTFILESIZE to something nonnumeric makes for no limits) | |
export HISTFILESIZE="SAVE_IT_ALL_YO" | |
export HISTSIZE="SAVE_IT_ALL_YO" | |
export HISTTIMEFORMAT='%Y-%m-%d %H:%M.%S | ' | |
export HISTIGNORE="ll:exit:history:[bf]g:jobs" | |
export HISTCONTROL=ignorespace | |
shopt -s histappend | |
# think about separating out history files | |
#export HISTFILE="${HOME}/.history/$(date -u +%Y/%m/%d.%H.%M.%S)_${HOSTNAME}_$$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// comparing my thoughts on how to answer this common question, vs what was found at the following link: | |
// http://www.programmerinterview.com/index.php/data-structures/reverse-a-linked-list/ | |
// In the link above, the recursive solution works in an interview to prove you can think recursively, | |
// but doesn't work in a real-world scenario because it's prone to stack overflow errors. | |
class Node { | |
Node next | |
Integer i | |
String toString() { i as String } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Single stack frame. Returns the "Nth" Fibonacci number - aka the Nth number in the sequence. | |
def fibIter | |
fibIter = { int step, int endStep, long currVal, long nextVal -> | |
if ( step == endStep ) return currVal | |
fibIter.trampoline( ++step, endStep, nextVal, currVal+nextVal ) | |
}.trampoline() | |
def fibonacci = { int seqNum -> | |
if ( seqNum < 0 ) println "fail" // needs better error handling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# directory shortcuts | |
alias home='cd ~' | |
alias work='cd ~/workspace' | |
alias proj='cd ~/projects' | |
alias doc='cd ~/Documents' | |
alias down = 'cd ~/Downloads' | |
# navigation shortcuts | |
alias ..='cd ..' | |
alias ..2='cd ../..' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// slate javascript config | |
// global configs | |
slate.log("-- setting up global configs --"); | |
slate.configAll({ | |
defaultToCurrentScreen: false, | |
orderScreensLeftToRight: true, | |
checkDefaultsOnLoad: true, | |
nudgePercentOf: "screenSize", |