Skip to content

Instantly share code, notes, and snippets.

View alexsnaps's full-sized avatar

Alex Snaps alexsnaps

View GitHub Profile
### Keybase proof
I hereby claim:
* I am alexsnaps on github.
* I am alexsnaps (https://keybase.io/alexsnaps) on keybase.
* I have a public key whose fingerprint is 27B8 94D1 A81E C2D0 019F 3845 E616 FB14 12C4 F75B
To claim this, I am signing this object:
@alexsnaps
alexsnaps / main.cpp
Last active February 2, 2017 18:49
msgpack EXT issue
#include <iostream>
#include <msgpack.hpp>
#include <unistd.h>
static const std::size_t MSGPACK_CHUNK_SIZE = 8 * 1024; // 64KB works fine!
void assert_key_exists(const msgpack::object &object, const char string[6]);
bool equal_to_symbol_p(const msgpack::object &object, const std::string &string);
void dump_map(const msgpack::object &object);
@alexsnaps
alexsnaps / ehcache.xml
Last active August 29, 2015 14:11
Ehcache JSR-107 cache-template module
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'>
<service>
<jsr107:defaults default-template="tinyCache">
<jsr107:cache name="users" template="usersTemplate"/>
</jsr107:defaults>
</service>
@alexsnaps
alexsnaps / ehcache.xml
Last active August 29, 2015 14:11
Ehcache XML cache-template
<ehcache:config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:ehcache='http://www.ehcache.org/v3'>
<ehcache:cache-template name="example">
<ehcache:key-type>java.lang.String</ehcache:key-type>
<ehcache:value-type>java.lang.String</ehcache:value-type>
<ehcache:capacity>120</ehcache:capacity>
</ehcache:cache-template>
@alexsnaps
alexsnaps / Address.java
Last active August 29, 2015 14:06
Bi-directional associations
public class Address {
private final int id;
public Set<Employee> employees = new HashSet<Employee>();
public Address(final int id) {
this.id = id;
}
@alexsnaps
alexsnaps / OnHeapStoreTest.java
Last active August 29, 2015 14:06
SPI testing
@Test
public void testStoreSPI() {
SPITester tester = new StoreTester(new Factory<OnHeapStore>())
.runTestSuite()
.throwJUnitException();
}
// I probably should have this code in its own method, to explain the intent with a proper method name...
while (true) {
try {
Thread.currentThread().join();
} catch (InterruptedException f) {
//ignore
}
}
// I also first thought I was on crack when I wrote these lines... Yet, as it turns out, this code is correct!
@alexsnaps
alexsnaps / config-fun.asciidoc
Last active August 29, 2015 13:56
Some Ehcache 3.0 config examples

Some Ehcache 3.0 config examples

1. Simple Cache configs

1.1 Bare minimal

Creates a simple cache, heap only. Capacity eviction all up to the Cache(Manager)?

scheduler.scheduleJob(
localTrigger(
newTrigger()
.forJob("importantJob"))
.where(node()
.has(atLeastAvailable(512, MemoryConstraint.Unit.MB)
.is(OsConstraint.LINUX)))
.build());