Skip to content

Instantly share code, notes, and snippets.

View coopernurse's full-sized avatar

James Cooper coopernurse

View GitHub Profile
{
"resourceKey": {
"EDE_PROPERTY_ADDRESS": "999 Pine Ave."
},
"symbol": {
"view_1.disclaimer_1": "Guaranteed or Your Money Back",
"agent_1.photo_1": "http://acme-broker.example.com/agents/agent-1.jpg"
}
}
public class FooException extends Exception {
public enum Type {
notFound(404), alreadyExists(401), emailInvalid(401);
private int httpStatusCode;
Type(int httpStatusCode) {
this.httpStatusCode = httpStatusCode;
Tools used:
https://github.com/kdlucas/byte-unixbench
https://github.com/akopytov/sysbench
both were compiled from source on the given machines.
----------------------------------------------------
import java.util.Iterator;
import java.util.NoSuchElementException;
public abstract class BaseIterator<T> implements Iterator<T> {
private T nextItem;
@Override
public boolean hasNext() {
return fetchNext() != null;
@coopernurse
coopernurse / TestQueue.java
Created February 10, 2016 20:54
test of non-ascii sqs handling
public class TestQueue {
public static void main(String argv[]) throws Exception {
Log4JInit.init();
AWSCredentials creds = new EnvironmentVariableCredentialsProvider().getCredentials();
AmazonSQS sqs = new AmazonSQSClient(creds).withRegion(Regions.US_WEST_2);
String queueUrl = sqs.getQueueUrl("jamescuser_sync").getQueueUrl();
String test = "Lorem ipsum是指一篇用于网页设计、排印、布局和印刷的伪拉丁文章,其用于代替英语去强调设计元素而不是内容。它也被称为占位符文(或填充文)。它是一个很便利的模板工具。它用于帮助编排文章或演示文稿的视觉元素,如排印,字体,或布局。Lorem ipsum 大多是由古典作家和哲学家西塞罗创作的拉丁文的一部分。它的单词和字母由于添加或去移除而被改变了,所以故意使其内容荒谬;它不是真实的,正确的,再也不是可理解的拉丁语。虽然lorem ipsum看起来仍像古典拉丁语,但实际上它没有任何意义。因为西塞罗的文本不包含K";
@coopernurse
coopernurse / gist:6bd79f786372cd82ec10
Created November 12, 2015 21:09
dogestry deadlock
PC=0x43e151
goroutine 0 [idle]:
runtime.futex(0xa49a98, 0x0, 0x0, 0x0, 0x0, 0xa48fc0, 0x1, 0x40cb8f, 0x40cdae, 0xa49a98, ...)
/usr/local/go/src/runtime/sys_linux_amd64.s:277 +0x21
runtime.futexsleep(0xa49a98, 0x0, 0xffffffffffffffff)
/usr/local/go/src/runtime/os_linux.c:49 +0x47
runtime.notesleep(0xa49a98)
/usr/local/go/src/runtime/lock_futex.go:145 +0xae
stopm()
@coopernurse
coopernurse / ensure-free-space.sh
Created October 14, 2015 23:16
bash script to free up disk space up to a threshold
#!/bin/bash
dir="$1"
if [ ! -d "$dir" ]; then
echo "$dir is not a directory. Exiting."
exit 1
fi
minimum="$2"
if [ -z "$minimum" ]; then
#!/usr/bin/env python
import time
from bottle import route, run, template, get, post, request, static_file
@route('/pics/<filepath:path>')
def server_static(filepath):
return static_file(filepath, root='pics')
@route('/hello/<name>')
@coopernurse
coopernurse / java2.md
Last active September 27, 2016 23:21
Java lesson 2

Java - Lesson 2

JARs

JAR (Java ARchive) files are zip files that typically contain compiled Java .class files (and sometimes other file types). JAR files are used to package libraries and full programs so they can be easily distributed.

The jar tool that comes with the JDK can be used to create and inspect JAR files.

@coopernurse
coopernurse / java1.md
Last active August 29, 2015 14:25
java lesson 1

Java

Basic Java tools

Most Java developers use an IDE to edit and compile Java code. The IDE simplifies build and run tasks by executing the compiler and Java runtime with the correct arguments.

If you have a grasp of how the compiler works from the command line, configuring your IDE will be easy. If you aren't familar with the command line tools, using an IDE