This file contains hidden or 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 | |
| exec /opt/scala-2.10/bin/scala -feature "$0" "$@" | |
| !# | |
| object Primes { | |
| private lazy val notDivisibleBy2: Stream[Long] = 3L #:: notDivisibleBy2.map(_ + 2) | |
| private lazy val notDivisibleBy2Or3: Stream[Long] = notDivisibleBy2 | |
| .grouped(3) | |
| .map(_.slice(1, 3)) | |
| .flatten |
This file contains hidden or 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 | |
| exec /opt/scala-2.10/bin/scala -feature "$0" "$@" | |
| !# | |
| import scala.language.postfixOps | |
| /** | |
| * From https://stackoverflow.com/questions/25129721/scala-memoization-how-does-this-scala-memo-work. | |
| * | |
| * Generic way to create memoized functions (even recursive and multiple-arg ones) |
This file contains hidden or 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
| # moved to noel-yap/.bash |
This file contains hidden or 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 | |
| proj_repo=$(git config --get remote.origin.url | sed -E -e 's|(ssh://)?git@github.com[/:]||' -e 's|\.git$||') | |
| upstream=$(curl "https://api.github.com/repos/${proj_repo}" | jq '.parent.git_url' | sed -e 's|"||g') | |
| git remote add upstream ${upstream} |
This file contains hidden or 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
| def doHttpPost(final String path, final String query) { | |
| final authority = 'example.com' | |
| final url = new URL("http://${authority}/${path}") | |
| final connection = url.openConnection() | |
| connection.with { | |
| setRequestMethod('POST') | |
| doOutput = true | |
| final writer = new OutputStreamWriter(outputStream) | |
| writer.with { |
This file contains hidden or 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
| # Allows one to have a multi-line shebang just like in Scala. Just as in Scala, be sure to end the multi-line shebang with a !#. | |
| # example usage: trampoline "${GRADLE_HOME}/bin/gradle" "$@" | |
| function trampoline() { | |
| local command=("$@") | |
| umask 077 | |
| tmpdir="$(mktemp -d -t $$.XXXXXXXXXXXXXXXX)" | |
| trap 'rm -rf -- "${tmpdir}"' INT TERM HUP EXIT |
This file contains hidden or 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 -evx | |
| PERFORCE_DEPOT_PATH=$1@all | |
| GIT_REPOSITORY_URL=$2 | |
| git_project_name=$(echo ${GIT_REPOSITORY_URL} | sed -e 's|^.*/||' -e 's|\.git||') | |
| rm -rf ${git_project_name} | |
| git clone ${GIT_REPOSITORY_URL} |
This file contains hidden or 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 -evx | |
| PERFORCE_DEPOT_PATH=$1 | |
| GIT_REPOSITORY_URL=$2 | |
| git_project_name=$(echo ${GIT_REPOSITORY_URL} | sed -e 's|^.*/||' -e 's|\.git||') | |
| rm -rf ${git_project_name} | |
| git clone ${GIT_REPOSITORY_URL} |
This file contains hidden or 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
| class TaskUtil { | |
| static def recursivelyApplyToTaskDependencies(Task parent, Closure closure) { | |
| closure(parent) | |
| parent.dependsOn.findAll { dependency -> | |
| dependency instanceof Task | |
| }.each { task -> | |
| recursivelyApplyToTaskDependencies(task, closure) | |
| } | |
| } |
This file contains hidden or 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
| task outputs() << { | |
| tasks.each { task -> | |
| println "${task.name}.outputs: ${task.outputs.getFiles().asType(Collection)}" | |
| } | |
| } |