de grosses MÀJ et ajout du projet 'antipixel'

This commit is contained in:
karchnu 2012-06-27 21:33:44 +02:00
parent 1c8a6574dd
commit 6f3dd64f72
100 changed files with 305 additions and 17 deletions

View File

@ -1,17 +0,0 @@
#!/usr/bin/perl -w
# This script displays the number of lines in a file
use strict;
die "un argument svp ! " if !defined ($ARGV[0]);
my $i=0;
open(P,"< $ARGV[0]") || die "erreur ouverture $!";
while (<P>)
{
$i++;
}
close(P);
print "nb de lignes = $i \n";

9
bash/add-torrents Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
dir=~/Téléchargements/
torrentsdir=~/torrents/
server=server
find $dir -name "*.torrent" -exec transmission-remote-cli -a "{}" && mv "{}" $torrentsdir \;
rsync -av $torrentsdir $server:$torrentsdir
#ssh $server $(< add-torrents-remote)

Binary file not shown.

66
c/weechat_plugins/test.c Normal file
View File

@ -0,0 +1,66 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TAILLE 5
#define TAILLE_CHAINE 20
#define TAILLE_BUFFER_CURRENT_SONG 200
#define TAILLE_OPTIONS 20
int main(int argc, char * argv[])
{
int i,status;
int p[2];
char ** cmd;
char * song;
char * affichage;
cmd = (char **) malloc(sizeof(char*) * argc+1);
if(argc > 3) argc = 3;
for(i = 0 ; i < argc + 2 ; i++)
cmd[i] = malloc(sizeof(char*) * TAILLE_OPTIONS);
free(cmd[i-1]);
cmd[i-1] = (char *)0;
strcpy(cmd[0],"mpc");
strcpy(cmd[i-2],"current");
if(argc == 3)
{
strcpy(cmd[1],"-h");
strcpy(cmd[2],argv[2]);
}
song = malloc(TAILLE_BUFFER_CURRENT_SONG*sizeof(char));
affichage = malloc((TAILLE_BUFFER_CURRENT_SONG + 10) * sizeof(char));
for(i = 0 ; i < TAILLE_BUFFER_CURRENT_SONG ; i++)
song[i] = '\0';
for(i = 0 ; i < TAILLE_BUFFER_CURRENT_SONG + 10 ; i++)
affichage[i] = '\0';
pipe(p);
if(fork() == 0)
{
close(p[0]);
close(0); close(2);
dup2(p[1],1);
execvp("mpc", cmd);
}
close(p[1]);
read(p[0], song, TAILLE_BUFFER_CURRENT_SONG);
close(p[0]);
wait(&status);
if(WEXITSTATUS(status) != 0)
sprintf(song,"didn't worked !!!");
sprintf(affichage,"/me ♪ %s", song);
//sprintf(affichage,"/me ♪ %s%s", weechat_color ("_red"), song); // Ne s'affiche pas correctement chez les autres
//weechat_utf8_normalize(affichage, '?'); // Pour ne pas avoir de caractères non-lisibles
printf("AFFICHAGE : %s\n",affichage);
free(song); // :')
for(i = 0 ; i < argc ; i++)
free(cmd[i]);
free(cmd);
return EXIT_SUCCESS;
}

26
perl/LeLangagePerl.txt Normal file
View File

@ -0,0 +1,26 @@
Le langage Perl
Variables :
Scalaires : $
Structurées : tableaux : @
table de hash : %
Langage contextuel = ne pas définir de type de variable
$_ = variable par défaut
exemple :
$prenom = "Eric"
print "$prenom\n";
print $prenom."\n";
print $prenom,"\n";
print '$prenom\n'
Autre exemple :
#!/usr/bin/perl
while(<>)
{
print;
};

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,52 @@
package MyWrapper;
use GD;
use strict;
use warnings;
use 5.16.0;
use Moo;
use MooX::Options;
has couleurs => ( is => 'ro', builder => '_build_colors' );
option mess => ( is => 'rw',
doc => 'message', format => 's', default => sub { 'message à afficher' } );
option couleur_externe => ( is => 'rw',
doc => 'couleur externe', format => 's', default => sub { 'bleu' });
option couleur_interne => ( is => 'rw',
doc => 'couleur interne', format => 's' );
option couleur_background => ( is => 'rw' ,
doc => 'couleur du fond (écriture)', format => 's');
sub _build_colors {
{
bleu => [0, 0, 255],
rouge => [255, 0, 0],
vert => [0, 255, 0],
noir => [0, 0, 0],
blanc => [255, 255, 255],
gris => [140, 140, 140]
};
}
sub tests {
my ($self) = @_;
my %couleurs = %{$self->couleurs};
say "mess : " . $self->mess;
say "couleur_externe : " . $self->couleur_externe;
say "Cette couleur n'existe pas !" unless exists $couleurs{$self->couleur_externe};
say "couleurs : " . join( ', ' , keys %couleurs) ;
while( my ($key , $value) = each %couleurs)
{
say "La couleur $key est : " . join(', ' , @$value);
}
# say "couleur_interne : " . $self->couleur_interne;
# say "couleur_background : " . $self->couleur_background;
}
sub run {
my $self = shift;
say "RUN !!!";
}
1;

View File

@ -0,0 +1,36 @@
#!/usr/local/bin/perl
use GD;
my $x = 100;
my $y = 15;
my $intersection = $x - 30;
my $espace_entre_mots = 2;
my $w1 = "Alsace";
my $w2 = "Réseau";
my $w3 = "Neutre";
# create a new image
$im = new GD::Image($x,$y);
# allocate some colors
$grey = $im->colorAllocate(140,140,140);
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$red = $im->colorAllocate(255,0,0);
$blue = $im->colorAllocate(0,0,255);
# make the background transparent and interlaced
#$im->transparent($white);
$im->interlaced('true');
# Put a black frame around the picture
$im->rectangle(0, 0, $x -1, $y -1, $black);
$im->filledRectangle(1, 1, $x -2, $y -2, $white);
$im->filledRectangle(2, 2, $intersection - $espace_entre_mots, $y -3, $red);
# make sure we are writing to a binary stream
binmode STDOUT;
# Convert the image to PNG and print it on standard output
print $im->png;

View File

@ -0,0 +1,8 @@
#!/usr/bin/env perl
use strict;
use warnings;
use MyWrapper;
my $wrapper = MyWrapper->new_with_options();
$wrapper->tests();
$wrapper->run();

18
perl/essai.perl Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/perl
while(<>)
{
if($_ =~ "Salut")
{
print "OK\n";
}
};
while(<>)
{
print if $_=~/"Bonjour"/;
};
# Encore plus simple !!
while(<>)
{
print if /"Bonjour"/;
};

16
perl/essai2.perl Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/perl
# Tableaux
@tab1 = ("lu", "ma", "me");
@tab2 = @tab1[1,2];
@tab2 = @tab1;
print $tab[0];
print $#tab1; # $# = index du dernier élément
$tab1[3] = "Je";
$tab1[30] = "Mon Langage Perl";
$#tab $_
@ARGV
$ARGV[0] # Le premier argument saisi
$#ARGV

24
perl/essai3.perl Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/perl
# Exercices tableaux
@alphabet = ("a" .. "z");
@cartes = ("01".."10","valet","dame","roi");
@annee=("a1","a2","lp");
@promo=@annee;
@tout = (@alphabet , "dut" , @cartes , 1145, "\n");
print @tout;
# Autre exercice
@jours=("Lundi","Mardi","Mercredi");
foreach $jours(@jours)
{
print $jours."\n";
}
# Perl : les nombres : < > <= >= == !=
# Chaînes : lt gt eq ne
# !~ et =~ sont des opérateurs d'appartenance

21
perl/grep.pl Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/perl -w
# -w pour les erreurs
$motif = shift(@ARGV);
# $motif=$ARGV[0]
#Shift
# Manière non explicite
while(<>)
{
if(/$motif/) { print ; };
};
# Manière explicite
while($ligne = <>)
{
if($ligne =~ /$motif/)
{
print $ligne;
}
};

14
perl/grep2.pl Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/perl
$motif=$ARGV[0];
shift;
foreach $f (@ARGV)
{
open(F,"<$f") || die "Impossible de lire le fichier $f : $!";
while(<F>)
{
if(/$motif/)
{ print "Motif trouvé dans $f : $_ \n";}
};
}

BIN
perl/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

15
perl/wc.pl Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/perl -w
# Utilisation : wc.pl fichier
open(F, "<$ARGV[0]") || die "Problème d'ouverture de fichier ! ";
$i = 0 ;
while(<F>)
{
$i++;
};
close(F);
print "Nombre de lignes : $i \n";