Skip to content

Instantly share code, notes, and snippets.

View mdijoux's full-sized avatar

Marc Dijoux mdijoux

  • Simplon.Prod
  • Réunion, France
View GitHub Profile
@mdijoux
mdijoux / offset-ip.sh
Last active August 4, 2022 04:35
Offset IP
###################################################
# Offset an IP address by any number of addresses #
###################################################
offset_ip(){
IP=$1
OFFSET=$2
# Convert IP as hexadecimal number
IP_HEX=$(printf '%.2X%.2X%.2X%.2X\n' `echo $IP | sed -e 's/\./ /g'`)
@mdijoux
mdijoux / seq_wget.sh
Created April 29, 2016 10:33
Retrieve sequencial files with wget
#!/bin/sh
if [ $# -lt 3 ]; then
echo "Usage: $0 url_format seq_start seq_end [wget_args]"
exit
fi
url_format=$1
seq_start=$2
seq_end=$3
@mdijoux
mdijoux / app.js
Last active August 29, 2015 14:26
SimpleSchema formly Mapping with walk
function formlyFieldsFromSchema(sschema) {
var fields = [];
var currentGroup = fields;
var groupStack = [];
var callbacks = {
leaf: function (sschema, key) {
var schema = sschema.schema(key);
//SimpleSchema <-> formly mapping
var mapping = {
public boolean resoudre(int k){
if(k==this.N){
return true;
}
for(int i=0; i<this.N; i++){
for(int j=0; j<this.N; j++){
//On parcours l'échiquier à la recherche d'une position valide
Piece p = this.creerPiece(i,j);
//On teste la position de la piece
if(p.compatible(this.pieces)){
#!/bin/sh
# Reset Firewall
iptables -t filter -F
iptables -t filter -X
# Bloquage total
iptables -t filter -P INPUT DROP
iptables -t filter -P OUTPUT DROP
iptables -t filter -P FORWARD DROP
# Ne pas casser les connexions
#!/bin/sh
echo "Flushing iptables rules..."
sleep 1
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
@mdijoux
mdijoux / gitkeep.sh
Last active August 29, 2015 14:01
A command line to fill a directory tree with .gitkeep files
find . -type d -empty | xargs ls | grep -v ./.git/ | sed -e 's/:$/\/.gitkeep/' | xargs touch
@mdijoux
mdijoux / daemon.c
Created May 10, 2014 11:28
A linux daemon template
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>
@mdijoux
mdijoux / index.js
Created May 5, 2014 09:17
Express view rendering based on extension
var App = express();
App.engine('html', require('ejs').renderFile);
App.set('views', '/');
App.set('view engine', 'html');
App.use(function(req, res, next){
res.locals.title = 'Test';
next();
});