Skip to content

Instantly share code, notes, and snippets.

View mathieucarbou's full-sized avatar
🏠
Working from home

Mathieu Carbou mathieucarbou

🏠
Working from home
View GitHub Profile
import org.ehcache.CacheManager
import org.ehcache.clustered.client.config.builders.ClusteredResourcePoolBuilder
import org.ehcache.clustered.client.config.builders.ClusteringServiceConfigurationBuilder
import org.ehcache.config.CacheConfiguration
import org.ehcache.config.builders.CacheConfigurationBuilder
import org.ehcache.config.builders.CacheManagerBuilder
import org.ehcache.config.units.MemoryUnit
import org.ehcache.management.config.EhcacheStatisticsProviderConfiguration
import org.ehcache.management.config.StatisticsProviderConfiguration
import org.ehcache.management.registry.DefaultManagementRegistryConfiguration
#!/bin/bash
[ ! -f build.gradle.orig ] && patch -b << 'EOF'
Index: build.gradle
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- build.gradle (revision 369b3cc846c4e3bc5566a2150e9990693d2276a8)
+++ build.gradle (revision )
8:02 $ cat a.sh
#!/bin/bash
exit 11
✔ ~/workspace/mathieu/management-apps [TAB-6693|✚ 2…2]
18:02 $ cat b.sh
#!/bin/bash
trap 'kill -TERM $PID' TERM INT
bash -c ./a.sh &
PID=$!
@mathieucarbou
mathieucarbou / Futures.java
Created March 7, 2016 17:19
Composing multiple futures into one future
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
/**
* @author Mathieu Carbou
private static <T> T callInOtherThread(Callable<T> task) throws Throwable {
ExecutorService service = Executors.newSingleThreadExecutor();
try {
Future<T> future = service.submit(task);
boolean interrupted = false;
try {
while (true) {
try {
return future.get();
} catch (InterruptedException e) {
@mathieucarbou
mathieucarbou / queuing.js
Created October 19, 2015 18:23
Dequeue a queue
var array = ['A', 'B', 'C'],
results = [],
errors = [],
worker = function(e, done) {
console.log('process', e);
if(Math.round(Math.random() * 31) % 2) {
done(null, 'result-' + e);
} else {
done(new Error(e));
}
class PortTest {
public static void main(String[] args) {
Thread.startDaemon {
println "bind on 8888 but does not accept"
new Socket().bind(new InetSocketAddress(8888))
Thread.currentThread().join()
}
Thread.startDaemon {
module.exports = spawn
var _spawn = require("child_process").spawn
var EventEmitter = require("events").EventEmitter
var cygwin = process.platform === "win32" && (process.env.ORIGINAL_PATH || '').indexOf('/cygdrive/') != -1;
function spawn (cmd, args, options) {
if(cygwin && cmd.indexOf('cmd.exe') != -1) {
cmd = 'c:\\cygwin\\bin\\bash.exe';
--- git.js 2015-05-11 16:19:29.114852900 -0400
+++ git-patched.js 2015-05-11 16:19:35.788234600 -0400
@@ -12,14 +12,23 @@
, git = npm.config.get("git")
, assert = require("assert")
, log = require("npmlog")
+ , win32 = process.platform === "win32"
+ , cygwin = win32 && (process.env.ORIGINAL_PATH || '').indexOf('/cygdrive/') != -1
function prefixGitArgs () {
@mathieucarbou
mathieucarbou / git.js
Last active September 18, 2019 13:58
// handle some git configuration for windows
exports.spawn = spawnGit
exports.chainableExec = chainableExec
exports.whichAndExec = whichAndExec
var exec = require("child_process").execFile
, spawn = require("./spawn")
, npm = require("../npm.js")
, which = require("which")