Skip to content

Instantly share code, notes, and snippets.

View FabienArcellier's full-sized avatar

Fabien Arcellier FabienArcellier

View GitHub Profile
@FabienArcellier
FabienArcellier / matrix.html
Created March 17, 2013 14:05
This snippet generate matrix falling code. I got it by unobfuscate those code. Look at it it's impressive : http://timelessname.com/sandbox/matrix.html
<html>
<head>
<script language="javascript">
function matrix_on_load()
{
s=window.screen,w=q.width=s.width,h=q.height=s.height,m=Math.random;
// Initialize the number of columns
for(p=[],i=0;i<256;p[i++]=0);
@FabienArcellier
FabienArcellier / factorielle.prolog
Created December 20, 2012 15:09
Calculate a factoriel using prolog
fact(0,1).
fact(1,1).
fact(X, Result):- X > 1, X1 is X-1, fact(X1, Result1), Result is Result1 * X.
@FabienArcellier
FabienArcellier / system.py
Last active May 17, 2018 06:50
template to use python as command engine as you would use bash -ex
#!/usr/bin/env python
import os
import sys
SCRIPT_DIR = os.path.realpath(os.path.join(__file__, '..'))
ROOT_DIR = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
def main(arguments):
@FabienArcellier
FabienArcellier / BitmapInfo.cs
Created November 28, 2012 23:05
Class in C# to extract pixel map from a specific channel
using System.Drawing;
namespace PictureHistogram
{
/// <summary>
/// Class that expose method to get pixel map from a specific channel
/// </summary>
class BitmapInfo
{
private Bitmap m_bitmap;
@FabienArcellier
FabienArcellier / prepare-commit-msg
Last active December 27, 2017 09:16
Sometime, it's useful to have the last 5 commits to name it's own commit. This hook will add this information in comment at the end of the text editor
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
@FabienArcellier
FabienArcellier / logstash.conf
Last active August 10, 2017 21:31
Use ruby object in logstash ruby filter
input {
stdin {}
}
filter {
ruby {
init => "load('ruby.rb'); @val=Myclasse.new('value')"
code => "event['method']=@val.value()"
}
}
@FabienArcellier
FabienArcellier / app.py
Created March 26, 2017 16:58
isolate tmpdir
#!/usr/bin/python
# coding=utf-8
import os
import tempfile
from subprocess import call
def main():
os.environ["TMPDIR"] = "/home/far/tmp"
print(tempfile.gettempdir())
#!/usr/bin/env bash
readonly SCRIPT_DIR=$(dirname "$(readlink -m "$0")");
function main
{
set -o errexit
set -o pipefail
set -o nounset
set -o errtrace
function loopdir {
command=$*
for d in */ ; do (cd $d; $command); done
}
function loopdirp { ## loop over directory based on a glob pattern loopdirp 'a*' rm deploy.yml
pattern=$1
shift 1
command=$*
for d in $pattern/ ; do (cd $d; $command); done
#!/usr/bin/env bash
readonly SCRIPT_DIR=$(dirname $(readlink -m $0));
function main
{
if [ -z "$1" ] && [ -z "${2}" ]; then
error_exit "Argument Identifiant projet attentu : bash ${0} path"
fi