Skip to content

Instantly share code, notes, and snippets.

View brianm's full-sized avatar
Caffeinating

Brian McCallister brianm

Caffeinating
View GitHub Profile
public interface TheBasics
{
@SqlUpdate("insert into something (id, name) values (:id, :name)")
int insert(@BindBean Something something);
@SqlQuery("select id, name from something where id = :id")
Something findById(@Bind("id") long id);
}
require 'prettyprint' # for the p function
module Enumerable
alias :fold :inject
end
root = [["root", [
["child", [
["grandkid", []],
["grandkid2", []]]],
package com.ning.atlas.aws;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient;
import com.amazonaws.services.elasticloadbalancing.model.Instance;
import com.amazonaws.services.elasticloadbalancing.model.RegisterInstancesWithLoadBalancerRequest;
import com.ning.atlas.Installer;
import com.ning.atlas.Server;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@brianm
brianm / Twilight.xml
Created August 1, 2011 15:39
modified twilight theme for idea
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="T2" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.2" />
<option name="EDITOR_FONT_SIZE" value="14" />
<option name="EDITOR_FONT_NAME" value="Menlo" />
<colors>
<option name="ANNOTATIONS_COLOR" value="3e83e7" />
<option name="CARET_COLOR" value="ffff99" />
<option name="CARET_ROW_COLOR" value="" />
<option name="CONSOLE_BACKGROUND_KEY" value="1a1a1a" />
package org.skife.jdbi.v2.docs;
import org.skife.jdbi.v2.SQLStatement;
import org.skife.jdbi.v2.sqlobject.Binder;
import org.skife.jdbi.v2.sqlobject.BinderFactory;
import org.skife.jdbi.v2.sqlobject.BindingAnnotation;
import org.skife.jdbi.v2.sqlobject.SqlStatementCustomizer;
import org.skife.jdbi.v2.sqlobject.SqlStatementCustomizerFactory;
import org.skife.jdbi.v2.sqlobject.SqlStatementCustomizingAnnotation;
@brianm
brianm / ugh
Created October 19, 2011 18:45
java.lang.NullPointerException
at org.jruby.util.CodegenUtils.human(CodegenUtils.java:98)
at org.jruby.util.CodegenUtils.prettyParams(CodegenUtils.java:152)
at org.jruby.java.dispatch.CallableSelector.argumentError(CallableSelector.java:462)
at org.jruby.java.dispatch.CallableSelector.argTypesDoNotMatch(CallableSelector.java:436)
at org.jruby.java.invokers.RubyToJavaInvoker.findCallable(RubyToJavaInvoker.java:191)
at org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:53)
at org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:143)
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:272)
at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:80)
@Test
public void testBetterErrorMessage() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
try {
mapper.writeValueAsString(new Thing());
fail("should have raised an exception against a private class");
}
catch (Exception e) {
assertThat(e.getMessage(), containsString("private"));
@brianm
brianm / leak.c
Created January 25, 2012 19:39
a fast memory leak
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
int main(int argc, char *argv[]) {
size_t i;
void *mem, *prev;
mem = NULL;
@Test
public void testStartDeployedThing() throws Exception
{
// find the deployment url
_Root root = http.prepareGet("http://localhost:25365/")
.setHeader("accept", MediaType.APPLICATION_JSON)
.execute(new JsonMappingAsyncHandler<_Root>(_Root.class)).get();
_Action deploy = Iterables.find(root._actions, fieldEquals("rel", "deploy"));
// perform a deployment against it
function setjdk {
local ver=${1?Usage: setjdk <version>}
export JAVA_HOME=$(/usr/libexec/java_home -v $ver)
PATH=$(echo $PATH | tr ':' '\n' | grep -v Java | tr '\n' ':')
export PATH=$JAVA_HOME/bin:$PATH
}
function _setjdk_completion (){
COMPREPLY=()