Skip to content

Instantly share code, notes, and snippets.

@eoconnell
eoconnell / Makefile
Last active June 20, 2018 11:58
CentOS/6 - Upstart - Java
JFLAGS = -g
JC = javac
.SUFFIXES: .java .class
.java.class:
$(JC) $(JFLAGS) $*.java
CLASSES = Service.java
@eoconnell
eoconnell / SpaceAge.java
Created December 6, 2017 00:50
Ref*cktoring - Software as a Craft Philly
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
@eoconnell
eoconnell / RxCq.java
Created August 9, 2017 02:20
Reactive Geode CqListener
import io.reactivex.*;
import org.apache.geode.cache.*;
import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientCacheFactory;
import org.apache.geode.cache.client.ClientRegionFactory;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.cache.query.*;
import org.apache.geode.cache.query.internal.cq.CqAttributesImpl;
import java.util.Random;
@eoconnell
eoconnell / build.gradle
Created February 25, 2017 03:45
Use Groovy Meta Object Programming to access fields on Geode PdxInstance
apply plugin: 'groovy'
repositories {
jcenter()
}
dependencies {
compile 'org.codehaus.groovy:groovy:2.4.8'
compile 'org.apache.geode:geode-core:1.1.0'
}
@eoconnell
eoconnell / MapLiteral.java
Last active August 29, 2015 14:23
A pretty, but expensive way to create maps
import java.util.AbstractMap.SimpleEntry;
import java.util.HashMap;
import java.util.Map;
// A pretty, but expensive way to create maps
public class MapLiteral {
public static <K,V> Map.Entry<K, V> e(K key, V value) {
return new SimpleEntry<K,V>(key, value);
}
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class Compressor {
private Compressor() {};
public static <V extends ICompressible<K, V>, K> Collection<V> compress(Collection<V> original) {
@eoconnell
eoconnell / DBUtil.php
Last active December 11, 2015 02:49
SQL concatenation helper for Laravel 4
<?php
class DBUtil {
/**
* Concatenate fields using the driver's valid SQL operator.
*
* @param array
*
* @example
@eoconnell
eoconnell / DAO.php
Created December 24, 2012 04:33
Experimenting with something similar to Laravel's best practices http://laravel.com/docs/models. Thoughts?
<?php namespace DAO;
class StorageException extends \Exception {}
class DuplicateRecordException extends \Exception {}
interface DAO {
/**
* Checks if an Entity exists in the datastore.
*
@eoconnell
eoconnell / bench.py
Created August 12, 2012 01:01
Benchmark of some sorting algorithms written in Python.
#!/usr/bin/python
from time import time
mark = 0
def tic():
global mark
mark = time()
@eoconnell
eoconnell / phpin.cpp
Created May 26, 2011 20:52
PHP explode and trim in C++
#include <string>
#include <vector>
/* Trims a string of any characters provided in the char list */
string trim(string str, string charlist = " \t\f\v\n\r")
{
int first, last;
last = str.find_last_not_of(charlist);
// only contains chars that are being trimmed, return ""
if (last == string::npos)