Partie optionnelle : [...]
Partie répétable 0 à N fois : {...}
public class ClosureIterator { | |
private static interface Iterator<T> { | |
T next(); | |
} | |
private static class Container<T> { | |
private T value; | |
public Container(T value) { |
import java.util.LinkedList; | |
/** | |
* Slave task that allows for asynchronous operations based on a FIFO queue. | |
*/ | |
public class Async extends Thread { | |
private LinkedList<Runnable> tasks = new LinkedList<Runnable>(); | |
private boolean stop = false; |
public class BitSet<T extends Enum<?>> { | |
private byte[] bytes; | |
@SafeVarargs | |
public BitSet(T... elements) { | |
bytes = new byte[elements.length / 8 + 1]; | |
} | |
private int bitMask(int ordinal) { |
import sys | |
# | |
# Generation config | |
# | |
PRINT_COLS = 8 | |
LETTERS_CHANGED = 2 | |
# |
def lazy(fun): | |
class Memoizer(object): | |
def __init__(self, fun): | |
self.fun = fun | |
self.set = False | |
self.res = None | |
def __call__(self): | |
if not self.set: | |
self.set = True |
// | |
// Simple template system with plain JS objects, using CSS selectors | |
// Two versions : | |
// * JSON | |
// - based on JSON objects, each element is a property | |
// * JSON-ML : | |
// - inspired from the JSON-ML markup language (http://www.jsonml.org/) | |
// - each element is a list | |
// - element type can contains id and classes like the first version (so, not standard json-ml) | |
// |
// Inspired from : http://www.sitepoint.com/multi-threading-javascript/ | |
longOperation: function (fn, initData, interval) { | |
var data = initData, busy = false; | |
var result = $q.defer(); | |
var taskId; | |
var task = function() { | |
if(!busy) { | |
busy = true; | |
var res = fn(data); | |
data = res.data; |
angular.module('ngFixedHttp', []) | |
.factory('FixedHttp', ['$http', function($http) { | |
// Can't use $http.post() because JSON format is not | |
// recognized by the web server | |
// See : http://stackoverflow.com/questions/19254029/angularjs-http-post-does-not-send-data | |
// This service is supposed to be used as a replacement for $http | |
// /!\ Not tested | |
// /!\ /!\ Doesn't work with nested JSON objects (must write custom compile function for that) /!\ /!\ |
"use strict"; | |
angular.module('timezones', []) | |
.value('CommonTimezones', [ | |
"Africa/Abidjan", | |
"Africa/Accra", | |
"Africa/Addis_Ababa", | |
"Africa/Algiers", | |
"Africa/Asmara", |