Skip to content

Instantly share code, notes, and snippets.

View mqu's full-sized avatar
🏠
Working from home

Marc Quinton mqu

🏠
Working from home
  • DGAC / DTI
  • Toulouse / France
View GitHub Profile
@mqu
mqu / javascript-beautifier
Created February 1, 2013 20:26
a very simple javascript beautifier writen in php5. Usage : javascript-beautifier some-script.js > beautifull-script.js keywords : javascript, beautify, pretty, php, shell, command-line.
#!/usr/bin/php -q
<?php
/**
* JSBeautifier class
*
* @author Einar Lielmanis
* @author Kaspars Foigts
* @author Igal Alkon
*
* @package JSBeautifier
#!/usr/bin/ruby
# coding: utf-8
# author : Marc Quinton, march 2013, licence : http://fr.wikipedia.org/wiki/WTFPL
libdir = 'lib'
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
require 'pp'
@mqu
mqu / iwlist-parser.rb
Created March 27, 2013 20:15
iwlist parser in ruby.
#!/usr/bin/ruby
# coding: utf-8
# author : Marc Quinton, march 2013, licence : http://fr.wikipedia.org/wiki/WTFPL
require 'pp'
=begin
Cell 52 - Address: 00:24:D4:51:53:20
@mqu
mqu / codingame-tuto1.rb
Last active December 15, 2015 13:19
solution for codingame tutorial 1 : http://www.codingame.com/cg/#!training in ruby.
# http://www.codingame.com/ide/?target=clogin&s=1&id=719077d960bd6fa93faa2bf63cb0fff80ed64#!test:81047:true:%2523!list
=begin
Ce premier exercice a pour seul objectif de vous familiariser avec la lecture depuis l'entrée standard et l'écriture dans la sortie standard.
Pourquoi est-ce si important ? Parce que tous les exercices CodinGame suivent ce protocole et que ça serait dommage que vous perdiez du temps la dessus !
ENTRÉE :
Ligne 1 : Deux entiers n1 et n2, séparés par un espace
@mqu
mqu / codingame-tuto2.rb
Created March 28, 2013 20:15
solution for codingame tutorial2 : http://www.codingame.com/cg/#!training
# http://www.codingame.com/ide/?target=clogin&s=1&id=719077d960bd6fa93faa2bf63cb0fff80ed64#!test:81047:true:%2523!list
=begin
Dans cet exercice, on vous demande d'écrire un programme capable d'analyser un relevé de températures pour trouver quelle température se rapproche le plus de zéro.
Exemple de températures. Ici, -1 est le plus proche de 0.
ENTRÉE :
@mqu
mqu / codingame-conway.rb
Last active December 15, 2015 14:19
codingame : Conway series ; this script fails to few tests but should be OK and very quick. All the job is done with regular expression that do "group by", and perform string length. This algorithm is called "lookandsay" and is visible somewhere. keywords : codingame, ruby, conway sequence, look'say, look-and-say
def conway(start, count)
str=start
(count-1).times do
str = str.gsub(/(.)\1*/) {$&.length.to_s + $1}
end
return str.split('').join(' ')
end
# read data from STDIN or from FILES passed as args and split as lines
lines=ARGF.read.split("\n")
@mqu
mqu / calc.rb
Created April 1, 2013 16:34
a mathematical parser using Treetop and Ryby. You can parse mathematical expression (but not compute now), for example : (12*(123+4)/(54-12))/3
#!/usr/bin/ruby
# coding: utf-8
require 'pp'
require 'treetop'
class ParserNode < Treetop::Runtime::SyntaxNode
end
class IntegerNode < ParserNode
@mqu
mqu / annu.rb
Created April 15, 2013 21:38
recherche sur l'annaire http://annu.com ; supporte les recherches inversées et toutes sorte de recherche. Avoir les résultats en ligne de commande, quel bonheur.
#!/usr/bin/ruby
# coding: utf-8
# author : Marc Quinton, février 2013, licence : http://fr.wikipedia.org/wiki/WTFPL
require 'pp'
require 'rubygems'
require 'mechanize'
class PhoneEntry
@mqu
mqu / amelia-calendar-sync.php
Last active December 17, 2015 01:48
synchro très basique : Amelia -> any-calendar :- 1 : installer ce script sur un serveur Web public, une URL de la forme : http://server/calendar/- 2 : pour obtenir sa clé d'accès, il suffit d'activer : URL/getkey/<compte>- 3 : configurer l'agenda avec l'URL obtenue.
<?php
error_reporting(E_ALL);
ini_set('include_path', '.:lib:lib-extra:lib-wcap:modules:' . ini_get('include_path'));
# fichier de configuration du site Web.
# include_once('amelia-config.php');
@mqu
mqu / proxy.rb
Created May 26, 2013 07:31 — forked from torsten/proxy.rb
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009 Torsten Becker <torsten.becker@gmail.com>
require 'socket'
require 'uri'