Skip to content

Instantly share code, notes, and snippets.

@michel47
michel47 / read_multiline.sh
Created Aug 22, 2020
pour a multiline string in a shell variable using <<EOT
View read_multiline.sh
#
# for sh
solution="$(cat <<-EOT
use cat instead of read
and don't forget
to use "" to protect your "\\\\n"
to be replaced w/ spaces.
EOT
View keybase.md

Keybase proof

I hereby claim:

  • I am michel47 on github.
  • I am michelc (https://keybase.io/michelc) on keybase.
  • I have a public key whose fingerprint is FAD0 F155 9C15 C16D 1C82 D8F0 1092 2EF0 40B0 11EF

To claim this, I am signing this object:

@michel47
michel47 / keybase.md
Created Aug 15, 2020
keybase claim of id
View keybase.md

Keybase proof

I hereby claim:

  • I am michel47 on github.
  • I am michel47 (https://keybase.io/michel47) on keybase.
  • I have a public key whose fingerprint is 5C19 0E40 DE17 68D1 4F55 43F9 02BF B5E1 314C 4080

To claim this, I am signing this object:

@michel47
michel47 / hashslice.pl
Created Apr 18, 2016
how to assign a hash table by slice (i.e setting a hash with both the key and value arrays)
View hashslice.pl
#!perl
# how to assign a hash table in parallel
# using the whole slice !!!
# read more : http://perldoc.perl.org/perldata.html
#
# courtersy Michel Combes (@ Advancement of Civilization Effort Org.)
my %hash;
my @array = (1 .. 5);
my @keys = ('a' .. 'e');
@michel47
michel47 / de(n)code58.pl
Created Jan 29, 2016
Generic string to base n conversion (encode and decode)
View de(n)code58.pl
#!perl
my $IPFSalphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
if ($0 eq __FILE__) {
my $e = '987654321ABC';
my $a = &decode_base($e,$IPFSalphabet);
printf "%s -> %s\n",$e,unpack('H*',$a);
my $e = &encode_base($a,$IPFSalphabet);
printf "%s -> %s\n",unpack('H*',$a),$e;
View FFTnd.bat
@:=' -- $RCSfile: FFTnd.bat,v $
@start c:\strawberry\perl\bin\perl.exe -x -S %0 %* & goto endofperl '; # vim: filetype=perl nowrap
#!perl
# note by doing an FFT I go from spacial domain to frequency domain...
# i.e. bridging the physical world to the spiritual one <3
#
my ($source) = q$Source: /my/perl/script/fftnd.pl $ =~ /: (\S+)/;
eval { our $pwd = Win32::GetCwd() }; # current directory
@michel47
michel47 / autocrop.pl
Last active Jan 26, 2016
Image autocrop
View autocrop.pl
#!perl
use PDL;
my $file = shift || 'example.jpg'; # if no argument is passed use example.jpg
my $thres = 0.40;
# chopping the file path ...
my $s = rindex($f,'/');
my $fpath = ($s > 0) ? substr($f,0,$s) : '.';
my $filename = substr($file,$s+1);
You can’t perform that action at this time.