Skip to content

Instantly share code, notes, and snippets.

@beckje01
beckje01 / .git_ps1
Created February 2, 2014 19:50
Bash Prompt adapted
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
git_status="$(git status 2> /dev/null)"
@beckje01
beckje01 / gist:30c886df1189f3d2dea7
Created July 14, 2014 14:19
HttpClient Proxy Scratch
get { HttpClient httpClient ->
def result = httpClient.request("http://beckje01.com", { RequestSpec requestSpec ->
requestSpec.body.type("text/plain").stream { it << request.body.text }
requestSpec.method(request.method.toString())
request.headers.getNames().each {
requestSpec.headers.set(it, request.headers.get(it))
}
})
result.onError({
@beckje01
beckje01 / contextExample.groovy
Created July 28, 2014 08:49
Ratpack Context Examples
@Grab('io.ratpack:ratpack-groovy:0.9.6')
import ratpack.registry.RegistrySpec
import static ratpack.groovy.Groovy.*
import static ratpack.registry.Registries.registry
ratpack {
handlers {
handler {
import org.apache.log4j.MDC
class LoggingFilters {
public static final String CORRELATION_HEADER = "X-CorrelationId" //Our Standard
def filters = {
correlationId(controller: '*', action: '*') { //For all requests
before = {
String correlationId = request.getHeader(CORRELATION_HEADER)
### Keybase proof
I hereby claim:
* I am beckje01 on github.
* I am beckje01 (https://keybase.io/beckje01) on keybase.
* I have a public key whose fingerprint is 857D 6372 9EA4 7492 4FB7 D95A C3C2 391B B016 F80A
To claim this, I am signing this object:
@beckje01
beckje01 / BearerAuthHandler.groovy
Created May 13, 2015 15:03
OAuth2 Vertx 3 Bearer Token start
import io.vertx.core.http.HttpHeaders
import io.vertx.core.http.HttpServerRequest
import io.vertx.core.json.JsonObject
import io.vertx.ext.apex.RoutingContext
import io.vertx.ext.apex.handler.impl.AuthHandlerImpl
import io.vertx.ext.auth.AuthProvider;
class BearerAuthHandler extends AuthHandlerImpl {
@beckje01
beckje01 / Off-left technique
Created April 18, 2011 19:22
Shows how to hide off to the left a jQuery UI tab
.ui-tabs .ui-tabs-hide {
position: absolute;
left: -10000px;
}
@beckje01
beckje01 / barcheck.js
Created April 18, 2011 19:33
Check for Address Bar in iOS
if(window.navigator.standalone)
{//This page is currently standalone
console.log("stand alone");
}
if(!("standalone" in window.navigator))
{//This Page is shown in a browser that can't
console.log("can't do standalone");
}
@beckje01
beckje01 / dateUtils.js
Created May 8, 2011 19:22
A simple set of functions for dealing outputting with ISO dates
/*
* dateUtils.js
*
* A simple set of utilites for dealing with dates
*
*/
function toISOFormat(date)
{
@beckje01
beckje01 / BuildConfig.groovy
Created October 15, 2012 19:16
Grails Release Plugin External Maven Config
def mavenConfigFile = new File("${basedir}/grails-app/conf/mavenInfo.groovy")
if (mavenConfigFile.exists()) {
def slurpedMavenInfo = new ConfigSlurper().parse(mavenConfigFile.toURL())
slurpedMavenInfo.grails.project.repos.each {k, v ->
println "Adding maven info for repo $k"
grails.project.repos."$k" = v
}
}
else {
println "No mavenInfo file found."