Skip to content

Instantly share code, notes, and snippets.

Avatar
Caffeinating

Brian McCallister brianm

Caffeinating
View GitHub Profile
@brianm
brianm / bash_prompt.sh
Last active Dec 29, 2015
Encode $0 into color of hostname in PS1
View bash_prompt.sh
# assumes 256 color support, do your normal case thing, etc
local green="\[\033[38;5;156m\]"
local blue="\[\033[38;5;153m\]"
local red="\[\033[38;5;009m\]"
local reset="\[\033[00m\]"
local git_stuff='$(__git_ps1 "\[\033[31m\]<\[\033[01m\]%s\[\033[22m\]>\[\033[00m\]")'
local status_color="\$(if [ \$? = 0 ]; then echo \"${green}\"; else echo \"${red}\"; fi )"
PS1="${status_color}\h${reset}:${blue}\w${git_stuff}${reset}$ "
View ObjectStreamTest.java
package org.skife.muckery.jackson;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class ObjectStreamTest {
View jdbi3_test.java
package org.jdbi.jdbi3;
import com.google.common.collect.ImmutableSet;
import org.h2.jdbcx.JdbcConnectionPool;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.Set;
import java.util.UUID;
View EmbeddedPostgres.java
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')");
View gist:6011654
this is a line
this is a second line
this is a third line
View build.rb
Docker.build("base" => "brianm/buildy") do |b|
b.bash "touch hello.txt"
b.put "./bd.rb" => "/really_long_name.rb"
end
View gist:5391842
/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
View setjdk.bash
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=()
View gist:4c123938b2884bc2ff63
package io.takari.resolution;
import java.io.Serializable;
public class Artifact implements Serializable {
private static final long serialVersionUID = 1L;
private final String groupId;
private final String artifactId;
View hateos.java
@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
You can’t perform that action at this time.