Skip to content

Instantly share code, notes, and snippets.

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

Maxime Demolin MaximeD

🏠
Working from home
View GitHub Profile
@MaximeD
MaximeD / test
Created October 7, 2011 19:33 — forked from oelmekki/test
#!/usr/bin/env ruby
array, places = [1,2,3,8,5,8,0,4], []
puts "Maximum value of array is #{array.max.to_s}"
array.each_with_index do |val,i|
places << i if val == array.max
end
@MaximeD
MaximeD / flexion.rb
Created October 7, 2011 20:26
flexion.rb
#!/usr/bin/ruby
$pronoms = [ "je", "tu", "il/elle", "nous", "vous", "ils/elles" ] ;
terminaisons_1 = [ "e", "es", "e", "ons", "ez", "ent" ] ;
terminaisons_2 = [ "is", "is", "it", "issons", "issez", "issent" ] ;
def conjugate(verb, terminaisons)
puts "\nLes formes du verbe " + verb + " au présent de l'indicatif sont :\n"
inf = verb.gsub(/.{2}$/, "")
#!/usr/bin/env ruby
array=[1,2,0,3,3,5,0,4]
value_to_search = 3
total = 0
# ruby one-line
array.each { |value| total += 1 if value == value_to_search}
# ruby multiple
@MaximeD
MaximeD / Writing perl as perl
Created October 10, 2011 08:46
Writing perl as perl
#!/usr/bin/env perl
use strict ;
use locale ;
my @table=(1,2,3,8,5,8,0,4) ;
my @places ;
my ($index,$value) ;
# Max value
@MaximeD
MaximeD / double_shebang.sh
Created January 18, 2012 15:24
Introducing the double she-bang !
#!/bin/bash
#!/bin/bash
iconv -f iso8859-1 -t utf-8 \
2> log.karoSegment-id001 \
| sed -f ./tex2utf.sed \
2> log.karoSegment-id002 \
| /usr/bin/perl \
-pe 's!>!>\n!g' \
@MaximeD
MaximeD / encoding_test.pl
Created January 23, 2012 18:18
encoding testing
#!/usr/bin/env perl
use warnings;
use strict;
use utf8;
# Try with and without the folowing
binmode(STDOUT, ":utf8");
use Cwd;
chdir $ARGV[0];
print cwd() . "\n";
@MaximeD
MaximeD / subs_args.pl
Created February 9, 2012 10:54
have fun with subroutines args
#!/usr/bin/env perl
use strict;
use warnings;
my @file = ("med.txt");
&columnize(@file);
sub columnize {
foreach my $file(@_) {
@MaximeD
MaximeD / list2grps.rb
Created February 13, 2012 12:48
Randomize an etudiant list into groups !
#!/usr/bin/env ruby
etudiants = ["Name1", "Name2", ... , "Namen"] ;
def extract(etudiants)
random_number = rand(etudiants.length)
etudiant = etudiants[random_number]
return etudiants.delete(etudiant)
end
@MaximeD
MaximeD / vim_vs_emacs.rb
Created May 28, 2012 06:32
vim / emacs length
#!/usr/bin/env ruby
# encoding: utf-8
vim = [
"Ma configuration Vi / Vim / gVim - theClimber",
"Chapitre 16. Vim : un éditeur de texte",
"Ultimate Vim Config | Steve Francia's Epic Blog",
"Vim - Configuration complete (Page 1) / Logiciels éducatifs ...",
"vim - Documentation Ubuntu Francophone",
"The ultimate Vim configuration - vimrc",
@MaximeD
MaximeD / 50-joystick.conf
Created June 3, 2012 14:54
No joypad control mouse
# /etc/X11/xorg.conf.d/50-joystick.conf
Section "InputClass"
Identifier "joystick catchall"
MatchIsJoystick "on"
MatchDevicePath "/dev/input/event*"
Driver "joystick"
Option "StartKeysEnabled" "False"
Option "StartMouseEnabled" "False"
EndSection