Skip to content

Instantly share code, notes, and snippets.

View jprudent's full-sized avatar
🦋
Chasing butterflies

Jérôme Prudent jprudent

🦋
Chasing butterflies
View GitHub Profile
@jprudent
jprudent / gist:4762623
Created February 12, 2013 12:42
Javascript module
var myNamespace = (function () {
var myPrivateVar, myPrivateMethod;
// A private counter variable
myPrivateVar = 0;
// A private function which logs any arguments
myPrivateMethod = function( foo ) {
console.log( foo );
Buckethead - Soothsayer
@jprudent
jprudent / LearAsyncTest
Created June 5, 2013 10:08
self injecting spring test
import fr.pmu.commons.spring.SpringBuilder;
import org.junit.*;
import org.junit.Test;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;
;; Anything you type in here will be executed
;; immediately with the results shown on the
;; right.
(use 'clojure.test)
(with-test
(defn extract-scheme
"extract scheme from url"
@jprudent
jprudent / gist:6375265
Last active December 21, 2015 22:29
substract 2 vectors in clojure
(defn minus [v1 v2]
"substract 2 vectors, v2 must be a subset of v1"
(reduce (fn [acc v]
(let [index (.indexOf acc v)]
(into (subvec acc 0 index) (subvec acc (inc index))))) v1 v2))
(minus [:c :a :b :b :a :a :b] [:a :a :b :a]) ; [:c :b :b]
@jprudent
jprudent / gist:6485375
Created September 8, 2013 15:00
Convert a clojure sequence to a scala.collection.immutable.List
(defn to-scala-list [& vals]
(reduce
#(.apply scala.collection.immutable.$colon$colon$/MODULE$ %2 %1)
(scala.collection.immutable.Nil$/MODULE$)
(map to-jmhc-tile vals)))
@jprudent
jprudent / gist:8383414
Created January 12, 2014 11:22
Solving the 16th first problems of project Euler with clojure
(ns euler-clj.core
:use [clojure.test])
;; problem 1
(with-test
(defn multiple-of-3-and-5
"Find the sum of all the multiple of 3 and 5 below `limit`"
[limit]
@jprudent
jprudent / consistent-hashing.clj
Created January 12, 2016 12:00
A simple implementation of consitant hashing in Clojure
(defprotocol ConsistentHashRing
(add-node [this node] "add node to the ring")
(remove-node [this node] "remove node and its replicas of the ring")
(find-node [this data] "find the node responsible of data"))
(defn- find-closest-key [xs h]
(or (first (drop-while #(> h %) xs))
(first xs)))
(extend-protocol ConsistentHashRing
#include <stdio.h>
#include <signal.h>
void infinite_loop(int signum) {
printf("in loop");
//signal(5, infinite_loop);
__asm__("int3");
}
int main(int argc, char ** argv) {
@jprudent
jprudent / ptrace_ex4.c
Created June 25, 2016 11:32
ptrace ex 4
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <sys/user.h>
#include <sys/reg.h>
int waitchild(pid_t pid) {