Skip to content

Instantly share code, notes, and snippets.

View Zenithar's full-sized avatar

Thibault NORMAND Zenithar

View GitHub Profile
@Zenithar
Zenithar / rio.coffee
Created January 11, 2012 22:50
French RIO Checksum and Check procedure
#
# Used to calculate the checksum
# http://fr.wikipedia.org/wiki/Relev%C3%A9_d'identit%C3%A9_op%C3%A9rateur
#
exports.calcChksm = (oo, q, rrrrrr, notel) ->
concatenation = "#{oo}#{q}#{rrrrrr}#{notel}"
ordre = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+"
a = b = c = 0
for i in concatenation
@Zenithar
Zenithar / ext.coffee
Created April 6, 2012 16:36
CoffeeScript command line extension : comments and output minification
# Quoted in http://ww.zenithar.org/2012/04/06/iced-coffeescript-minification/
# Based on https://github.com/jashkenas/coffee-script/wiki/%5BExtensibility%5D-Hooking-into-the-Command-Line-Compiler
#
# Don't forget to install UglifyJS
# npm install -g uglify-js
#
# CoffeeScript = require 'coffee-script'
CoffeeScript = require 'iced-coffee-script'
{parser, uglify} = require 'uglify-js'
@Zenithar
Zenithar / secureHash.coffee
Created July 24, 2012 13:03
Hashing algorithm conform to Owasp.
crypto = require("crypto")
#
# Hashing algorithm conform to Owasp.
# https://www.owasp.org/index.php/Hashing_Java
#
exports.secureHash = (algorithm, key, message, iterations) ->
hash = crypto.createHash(algorithm)
hmac = crypto.createHmac(algorithm, key)
buf = hash.update(key).digest() + message
@Zenithar
Zenithar / application.coffee
Created August 14, 2012 16:43
Iterable Model for Backbone.js
MyCollection = require 'models/mycollections'
MyModel = require 'models/mymodel'
m1 = new MyModel({id: 1, label: 'tata'})
m2 = new MyModel({id: 14, label: 'tete'})
m3 = new MyModel({id: 2, label: 'titi'})
col = new MyCollection()
col.add m1
col.add m2
@Zenithar
Zenithar / client.js
Last active December 12, 2015 03:28
Export task as postIt from IceScrum instance
var sys = require('util'),
fs = require('fs'),
rest = require('restler'),
async = require('async'),
_ = require('underscore'),
BASEURL = "http://localhost:8080/icescrum/ws/p/",
SPRINTID = 1,
PRJKEY = "PRJ1";
IceScrum = rest.service(function(u, p) {
public class BackendMessageConverter extends ProtobufMessageConverter {
public BackendMessageConverter() {
// Server object is the object generated by protoc
super(Server.getDescriptor());
}
}
package org.atmosphere.interceptors;
import org.atmosphere.cpr.*;
public class CORSAtmosphereInterceptor implements AtmosphereInterceptor {
@Override
public void configure(AtmosphereConfig config) {
}
@Override
@Zenithar
Zenithar / Configuration.java
Last active December 18, 2015 23:09
RestExpress MultiPart File Upload support
package org.zenithar.restexpress.config;
import com.strategicgains.restexpress.Format;
import com.strategicgains.restexpress.RestExpress;
import com.strategicgains.restexpress.util.Environment;
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.io.FileCleaningTracker;
import java.io.File;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.security.oauth2.provider.code.AuthorizationRequestHolder;
import org.springframework.security.oauth2.provider.code.RandomValueAuthorizationCodeServices;
import org.springframework.util.Assert;
public class HazelcastAuthorizationCodeServices extends RandomValueAuthorizationCodeServices implements InitializingBean {
protected IMap<String, AuthorizationRequestHolder> authorizationCodeStore = null;
@Zenithar
Zenithar / Dockerfile
Last active April 10, 2020 11:43
NGiNX Nano Dockerfile tarmaker
FROM scratch
LABEL maintainer="Thibault NORMAND <me@zenithar.org>" \
docker.from="scratch" \
built.on="ubuntu 19.04" \
hardened.flags="true" \
description="Nginx built from source" \
ssl.implementation="boringssl" \
boringssl.version="master" \
pcre.version="8.43" \