Howto build deb package with Perl module (Lingua::Identify)

What is Lingua::Identify?Lingua::Identify is Perl module used for text language identification - remember that language identification is not 100% accurate. Why use Lingua::Identify? Here is list of most important (for me) features of this module it's free and it's open-source;it has unicode support in standard;it's a module, which means you can easily write your own applicationit supports big inputsit's maintainedHow to create deb package of Lingua::Identify? # Install packages required to build *.deb apt-get install dh-make-perl devscripts apt-file apt-file update # Install Lingua::Identify dependences from packages apt-get install libclass-factory-util-perl libtext-affixes-perl # Lingua::identify depends on Text::Ngram (but this is not packaged) # wget #…

TP-LINK TD-8910G - restart połączenia

Ponad dwa lata temu opisywałem router TP-LINK TD-W8910G urządzenie wciąż sprawuje się wyśmienicie.

Ostatnimi czasy chciałem dokonać zmiany adresu IP w regularnych odstępach czasu, oczywiście jak się można łatwo domyślić router TP-LINK nie posiada wbudowanej takiej opcji. Ale nic straconego, jako że urządzenie ma dosyć prosty interfejs do zarządzania dostępny poprzez telnet oraz www, napisałem dwa proste skrypty resetujące połączenie z moim ISP.

Pierwszy z nich dokonuje tylko restartu połączenia - do poprawnego działania wymaga zainstalowanego narzędzia expect (apt-get install expect).

Drugi natomiast służy do wykonania pełnego restartu routera i wymaga narzędzia curl (apt-get install curl). Skrypt restartujący połączenie w TP-LINK #!/usr/bin/expect # variables set router set username admin set password xxxxx # code set timeout 100 spawn telnet "$router" expect "Login:" send "$username\r" expect "Password:" send "$passw…

List all installed and available Perl modules

Code below provides list of modules which perl interpreter can find in runtime. Code#!/usr/bin/perl # # Author: Tomasz Gaweda # Date: 2011.12.23 17:00 # Purpose: Print all modules installed # in perl distribution # # Usage: perl use strict; use warnings; use File::Find; my @modules; my $IgnorePatt = join("|",@INC) ;#$IgnorePatt =~ s/\|\.// ; find( sub { my $f = $File::Find::name; if ( $f =~ s/^(${IgnorePatt})\/(.*?)\.pm$/$2/ ) { $f =~ s/[\/\\]/::/g; push @modules, $f; } } , grep { -d } @INC ); print "There are [".scalar(@modules)."] modules that perl can locate on runtime...\n"; print "Printing List in Minute\n" ; sleep 3; print join("\n", sort{ lc $a cmp lc $b} @modules)."\n";Sample outputThere are [2346] modules that perl can locate on runtime... Printing List in Minute AcidRip::acidrip AcidRip::interface AcidRip::messages AcidRip::signals AE Algorithm::C3 Algorithm::Diff …

Encoding files "on the fly" with Blowfish using Perl

Some time ago friend of mine asked me if I could write him an CGI script which encodes his backup file and allows to download it using HTTP protocol.He is using some kind of VPS so my CGI app had some limitations:file must be encoded "on the fly" to save disk space (no temporary files)encoding should be memmory efficient - because VPS hasn't got very much RAM and backup files are quite largeencoding should be fast - so the best solution would be using XS moduleAfter some research I've created this two scripts: Warning: Scripts depends on external Perl modules which are available at CPAN and in Debian repository. apt-get install libcrypt-cbc-perl libcrypt-blowfish-perlBlowfish CGI encoding using Perl#!/usr/bin/perl use strict; use warnings; use CGI; use HTML::Entities; use Crypt::CBC; use File::Spec; my $as_cgi = 1; # if run from apachce set to 1 if CLI 0 my $key = "ala_ma_kota.123"; my $fName = './large_file.bin'; my $chunkSize = 1024; my $ou…

Using perl to extract files from large directory structure

When I work on Windows I use Activesite Active Perl to do some stuff. Recently I had to copy about 60 files from large directory structure to a new place (about 800 files in nasty directory structure). It was rather boring stuff to do, so I used perl to finish job because it would be pretty easy task to do using hashes (I had names of files given in text file). Unfortunately I had some problems on completion of job, because there was a problem with encoding of file path name on Windows.Below I provide simple script demonstration how to handle national characters in path using perl on Windows.#!/usr/bin/perl use strict; use warnings; use utf8; use Encoding; # Win32::Codepage::Simple is available in ActiveState Perl use Win32::Codepage::Simple qw(get_codepage get_acp); use File::Find; use File::Copy; use File::Path; use File::Basename; binmode STDOUT, ":utf8"; binmode STDERR, ":utf8"; my $dir = "./copy_from_here/"; my $dest = "./copy_here/…

How to manage and disable bash history

You can change Bash history behaviour changing environment variables. Here is simple reference about this settings.

Arrays in PostgreSQL quick example

What is an array in database?PostgreSQL allows columns of a table to be defined as variable-length multidimensional arrays. Arrays of any built-in or user-defined base type, enum type, or composite type can be created. Arrays are not supper efficient way of doing things, but they are sometimes handy.Create some test dataSuppose we have table like this:CREATE TABLE survey_test ( id SERIAL, gender CHAR(1), school CHAR(2), -- can be: LO, TH, ZW q_9 VARCHAR(10) -- can be: [A-J]{0,10} );Where we store this data: