Skip to content

Instantly share code, notes, and snippets.

View brianm's full-sized avatar
Caffeinating

Brian McCallister brianm

Caffeinating
View GitHub Profile
try (EmbeddedPostgreSQL db = EmbeddedPostgreSQL.start()) {
try (Handle h = DBI.open(db.getPostgresDatabase())) {
h.execute("CREATE DATABASE breakfast");
h.execute("CREATE USER brianm with password 'secret'");
h.execute("grant all privileges on database breakfast to brianm");
}
try (Handle h = DBI.open(db.getDatabase("brianm", "breakfast"))) {
h.execute("create table food (id serial primary key, name text)");
h.execute("insert into food (name) values ('pancake')");
this is a line
this is a second line
this is a third line
Docker.build("base" => "brianm/buildy") do |b|
b.bash "touch hello.txt"
b.put "./bd.rb" => "/really_long_name.rb"
end
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -ea -Didea.launcher.port=7532 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 12.app/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA 12.app/lib/idea_rt.jar:/Applications/IntelliJ IDEA 12.app/plugins/junit/lib/junit-rt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/deploy.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/dt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javaws.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jconsole.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/management-agent.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/plugin.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/sa-jdi.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Content
@brianm
brianm / .gitignore
Last active April 26, 2024 07:34
Go net/rpc over ssh+netcat and unix domain sockets It would be nice if ssh.Session implemented io.ReaderWriter
local_client
server
client
ext
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=()
@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
@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 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 / 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)