Skip to content

Instantly share code, notes, and snippets.

View jfuerth's full-sized avatar

Jonathan Fuerth jfuerth

View GitHub Profile
@jfuerth
jfuerth / NativeCallbackExample.java
Created July 23, 2014 18:08
NativeCallbackExample.java
package ca.fuerth.gwt.playground.client;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.shared.GWT;
public class NativeCallbackExample {
public native void installGlobalFunction(String functionName) /*-{
var me = this;
$wnd[functionName] = function(message, callback) {
package ca.fuerth.misc;
import static java.lang.Long.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Memorator {
@jfuerth
jfuerth / Example.java
Created December 12, 2014 23:04
Dropdown tab support for GwtBootstrap3
TabPanelWithDropdowns tabPanel = new TabPanelWithDropdowns();
RootLayoutPanel.get().add(tabPanel);
tabPanel.addItem("First", new Text("This is the content in pane 1"));
tabPanel.addItem("Second", new Text("This is the content in pane 2"));
tabPanel.addItem("Third", new Text("This is the content in pane 3"));
tabPanel.addItem("Really really really really really long tab name", new Text("This is the content in pane 4"));
tabPanel.addItem("Fifth", new Text("This is the content in pane 5"));
DropDownContents dropDownContents = tabPanel.addDropdownTab("Dropdown");
@jfuerth
jfuerth / .bash_profile
Created April 21, 2015 13:57
Handy Shell Aliases
alias gf='git fetch --all'
alias gpo='git push origin'
alias gpu='git push upstream'
alias gt='git log --oneline --decorate --all --graph'
alias gd='git diff'
alias gs='git status'
@jfuerth
jfuerth / pre-commit
Last active August 29, 2015 14:21
Help prevent accidental disclosure of secret keys
#!/bin/sh
# To enable this hook, copy it into .git/hooks/pre-commit in your project's workspace
# or use the reinstall-git-hook-everywhere.sh script
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
@jfuerth
jfuerth / ctl.erb
Last active August 29, 2015 14:21
control script with restart protection
#!/bin/bash
RUN_DIR=/var/vcap/sys/run/hello-go
LOG_DIR=/var/vcap/sys/log/hello-go
PIDFILE=${RUN_DIR}/pid
case $1 in
start)
mkdir -p $RUN_DIR $LOG_DIR
#!/bin/bash
set -e
set -x
if [ -z "$1" ]; then
echo "Usage: $0 <stemcell_name.tgz>"
exit 1
fi
@jfuerth
jfuerth / tracker-bookmarklet.html
Last active December 22, 2016 15:45
Enhanced Pivotal Tracker Story Links!
<!DOCTYPE html>
<body style="width: 100%; font-family: helvetica,arial,sans-serif">
<h1>Enhanced Pivotal Tracker Story Links!</h1>
<a style="align:center; font-size:40pt; text-decoration: none" href='javascript:void(function(){storyIdPattern = /.*\/([0-9]+)/;storyInternalIdPattern = /story_copy_link_(.*)/;var buttons=document.querySelectorAll("button.link[data-clipboard-text]");for (i = 0; i < buttons.length; i++) {var b=buttons[i];var textAttr=b.attributes.getNamedItem("data-clipboard-text");var storyId=storyIdPattern.exec(textAttr.value)[1];var idAttr=b.attributes.getNamedItem("id");var storyInternalId=storyInternalIdPattern.exec(idAttr.value)[1];var storyTitle=document.getElementById("story_name_"+storyInternalId).value;var idButton=document.getElementById("story_copy_id_"+storyInternalId);idButton.attributes.getNamedItem("data-clipboard-text").value=storyTitle + " [#"+storyId+"]"}}())'>Enhance Story Links</a>
<p>To use it:
<ol>
<li>Drag the above link to your bookmarks bar!
<li>Expand one or more stor
@jfuerth
jfuerth / logviewer.html
Created July 12, 2016 14:57
View CF logs with line height proportional to time
<!DOCTYPE html>
<html>
<head>
<title>Log visualizer</title>
<style type="text/css">
div.logEntry {
border-bottom: 1px;
border-bottom-color: black;
border-bottom-style: solid;
position: relative;
@jfuerth
jfuerth / TraceLogger.java
Created March 12, 2018 14:53
Recipe for adding an SLF4J TRACE-level logger to a Feign-OkHttp3 client
private static class TraceLogger implements okhttp3.logging.HttpLoggingInterceptor.Logger {
/*
.client(new OkHttpClient(new okhttp3.OkHttpClient.Builder()
.addInterceptor(new okhttp3.logging.HttpLoggingInterceptor(
new TraceLogger(LoggerFactory.getLogger(FEIGN_TARGET)))
.setLevel(HttpLoggingInterceptor.Level.BODY))
.build()))
*/