Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am kramer on github.
  • I am ckeser (https://keybase.io/ckeser) on keybase.
  • I have a public key whose fingerprint is FC70 F5D1 CEC1 E407 3784 671F 6745 28AD AFC8 F7A8

To claim this, I am signing this object:

@kramer
kramer / build.gradle
Created August 11, 2014 20:36
ratpack "error" handling
buildscript {
repositories {
maven { url "http://oss.jfrog.org/repo" }
mavenCentral()
}
dependencies {
classpath 'io.ratpack:ratpack-gradle:0.9.7'
}
}
@kramer
kramer / build.gradle
Created August 6, 2014 18:36
Heavy Self Calling Ratpack
buildscript {
repositories {
maven { url "http://oss.jfrog.org/repo" }
mavenCentral()
}
dependencies {
classpath 'io.ratpack:ratpack-gradle:0.9.7'
}
}
@kramer
kramer / ConditionallyIgnoreSampleTest.java
Created July 9, 2013 06:49
Conditionally igore JUnit test cases
public class ConditionallyIgnoreSampleTest {
@Test
public void sampleTest() {
// ignore test if OS is windows
Assume.assumeTrue(!SystemUtils.IS_OS_WINDOWS);
// assertions ...
}
@kramer
kramer / applicationContext-sample-servlet.xml
Created June 17, 2013 13:04
setting default encoding for content returned with responseBody annotation
<mvc:annotation-driven>
<!-- register custom converter that returns UTF-8 encoded response-body by defualt -->
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg index="0" name="defaultCharset" value="UTF-8"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
.
class Reporter {
@RequestMapping("report")
public String doReport() {
"report"
}
}
@Controller
@RequestMapping("/a")
class AController {
@kramer
kramer / gist:5496665
Created May 1, 2013 17:11
jQuery ajax request interceptor
$.ajaxSetup({
beforeSend: function (xhr) {
xhr.setRequestHeader('X-Bottle-CsrfToken', '{{ session.csrf }}')
}
});
@kramer
kramer / gist:5438403
Created April 22, 2013 20:48
Bottlepy plugin for csrf token checking.
def require_csrf(callback):
def wrapper(*args, **kwargs):
session = request.environ.get('beaker.session')
if request.method == 'POST':
csrf = request.form.get('csrf')
if not csrf or csrf != session.get('csrf'):
abort(400)
session['csrf'] = generate_csrf_token()
body = callback(*args, **kwargs)
return body
@kramer
kramer / gist:5382951
Created April 14, 2013 14:31
chkconfig compatible rtorrent script. put in "/etc/init.d/rtorrent", then do "chkconfig --add rtorrent" and "chkconfig --level 3 rtorrent on". Originally from: "http://petrich.me/files/scripts/rtorrent"
#!/bin/bash
#
# rtorrent Startup script for rTorrent
#
# chkconfig: - 90 15
# description: rTorrent is the console torrent client
# config: /home/rtorrent/.rc.
# Source Red Hat function library.
. /etc/rc.d/init.d/functions
@kramer
kramer / README.md
Last active December 12, 2015 12:28 — forked from mbostock/.block

Enclosure diagrams use containment to represent the hierarchy. Although circle packing is not as space-efficient as a treemap, it better reveals the hierarchy. Implementation based on work by Jeff Heer. Data shows the Flare class hierarchy, also courtesy Jeff Heer.