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
@mathieucarbou
mathieucarbou / jquery.xdomain.js
Created July 29, 2011 23:45
jQuery CORS Plugin - transparently add CORS support for IE8+ in jQuery using XDomainRequest. Support cookies.
PROJECT MOVED TO https://github.com/Ovea/cors
/**
* https://gist.github.com/1114981
*
* By default, support transferring session cookie with XDomainRequest for IE. The cookie value is by default 'jsessionid'
*
* You can change the session cookie value like this, before including this script:
*
* window.SESSION_COOKIE_NAME = 'PHP_SESSION';
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Singleton;
import org.junit.Test;
import com.google.inject.AbstractModule;
import com.google.inject.Provider;
import com.mycila.inject.jsr250.Jsr250;
import com.mycila.inject.jsr250.Jsr250Injector;
@mathieucarbou
mathieucarbou / svnup.groovy
Created August 16, 2011 00:07
Subversion recursive update in Groovy using Java 7 Fork/Join framework
#!/usr/bin/env groovy
import java.util.concurrent.ForkJoinPool
import java.util.concurrent.RecursiveAction
import java.util.concurrent.TimeUnit
def root = (args && args[0] ? args[0] : '.' as File).canonicalFile
def cpus = Runtime.runtime.availableProcessors()
println "Updating all projects in ${root}..."
@mathieucarbou
mathieucarbou / sportstracklive.groovy
Created June 29, 2012 04:25
GPX batch upload to sportstracklive.com
#!/usr/bin/env groovy
import groovy.io.FileType
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
import org.apache.http.HttpResponse
import org.apache.http.client.methods.HttpPost
import org.apache.http.client.params.ClientPNames
import org.apache.http.client.params.CookiePolicy
@mathieucarbou
mathieucarbou / clock.js
Last active August 29, 2015 13:57
Javascript Clock based on timeZone to overcome moment issue https://github.com/moment/moment-timezone/issues/66
Clock = function (timeZone) {
this.timeZone = timeZone;
};
Clock.prototype = {
now: function () {
var nowZone = moment.tz(this.timeZone).zone();
return moment().zone(nowZone);
},
@mathieucarbou
mathieucarbou / kryo.java
Created May 8, 2014 17:43
Redisson Kryo Encoder
import com.esotericsoftware.kryo.Kryo;
public interface KryoPool {
Kryo get() throws Exception;
void yield(Kryo kryo);
}
//////////////////////////////////////////////////////////////
@mathieucarbou
mathieucarbou / MongoJsr310.java
Created May 15, 2014 00:43
Add Java 8 Date Time support to MongoDB Serialization
import com.guestful.jsr310.Jsr310Extensions;
import com.guestful.jsr310.ZonedInterval;
import org.bson.BSON;
import java.time.*;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
@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")
--- 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 () {
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';