Skip to content

Instantly share code, notes, and snippets.

==> ./configure prefix=/Users/adamv/homebrew/Cellar/cmus/2.7.1_1 mandir=/Users/adamv/homebrew/Cellar/cmus/2.7.1_1/share/man
checking for program clang... /Users/adamv/homebrew/Library/ENV/4.3/clang
checking for program gcc... /Users/adamv/homebrew/Library/ENV/4.3/gcc
checking for CFLAGS -std=gnu99 -pipe -Wall -Wshadow -Wcast-align -Wpointer-arith -Wwrite-strings -Wundef -Wmissing-prototypes -Wredundant-decls -Wextra -Wno-sign-compare -Wformat-security... yes
checking for CFLAGS -Wold-style-definition... yes
checking for CFLAGS -Wno-pointer-sign... yes
checking for CFLAGS -Werror-implicit-function-declaration... yes
checking for CFLAGS -Wno-unused-parameter... yes
checking if CC can generate dependency information... yes
checking byte order... little-endian
package test.util;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import java.io.IOException;
import java.net.URL;
@adamv
adamv / table.py
Last active November 17, 2015 18:10
class Table(object):
def __init__(self):
self.rows = []
def add(self, row):
self.rows.append(row)
def render(self):
if not self.rows:
return
import com.google.common.base.Strings;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* S3Location represents an S3 bucket and a key.
*/
public class S3Location {
/**
@adamv
adamv / blah.java
Last active September 2, 2015 21:57
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import java.util.Comparator;
import java.util.List;
import java.util.ListIterator;
public class Incr2 {
static class Datum {
final int id;
@adamv
adamv / gist:b97aa9363a90378394b9
Created August 19, 2015 22:29
When the run-if boostrap action doesn't work...
check_if_master() {
python - <<'__SCRIPT__'
import sys
import json
instance_file = "/mnt/var/lib/info/instance.json"
with open(instance_file) as f:
props = json.load(f)
is_master = props.get('isMaster', False)
class WorkaroundInputStream extends FilterInputStream {
static final int CONTROL_Z = 26;
protected WorkaroundInputStream(InputStream in) {
super(in);
}
@Override
public int read() throws IOException {
// Subclass TextOutputFormat so we can use a base ".json" extension.
// adamv: I feel as if this shouldn't be this complicated.
static class JsonTextOutputFormat extends TextOutputFormat<LongWritable, Text> {
@Override
public RecordWriter<LongWritable, Text>
getRecordWriter(TaskAttemptContext job
) throws IOException, InterruptedException {
Configuration conf = job.getConfiguration();
boolean isCompressed = getCompressOutput(job);
String keyValueSeparator = conf.get(SEPERATOR, "\t");
@adamv
adamv / gist:3f67a16a605e11627bed
Created June 5, 2015 17:57
Create and use a temporary file.
#!/usr/bin/env python3.4
import tempfile
from subprocess import call
with tempfile.NamedTemporaryFile() as f:
for i in range(500):
f.write(bytes("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\n", 'UTF-8'))
f.flush()
call(["cat", f.name])
@adamv
adamv / gist:28f275ca7ca87818ef53
Last active August 29, 2015 14:22
JSON string -> ? -> Smile
import com.fasterxml.jackson.core.JsonFactory
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.util.TokenBuffer
import com.fasterxml.jackson.dataformat.smile.SmileFactory
object SmileDemo {
val JSON_FACTORY: JsonFactory = new JsonFactory()
val SMILE_FACTORY: SmileFactory = new SmileFactory()
val JSON = new ObjectMapper(JSON_FACTORY)