Skip to content

Instantly share code, notes, and snippets.

View dpavlin's full-sized avatar

Dobrica Pavlinušić dpavlin

View GitHub Profile
ack-grep --type-add perl=.ep
@dpavlin
dpavlin / test-8bit-encoding.sh
Created June 23, 2010 15:57
Dump all variations of Croatian 8-bit encodings
#!/bin/sh -x
file=$1
function encoding {
echo "# $1"
head $file | iconv -f $1 -t utf-8
}
encoding cp850
use Benchmark qw(:all);
use Devel::Size;
use DevXX::Size;
use Storable;
sub _storable_freeze {
length Storable::freeze $_[0];
}
@dpavlin
dpavlin / jmbg.pl
Created July 13, 2010 12:44
validate JMBG
#!/usr/bin/perl
use warnings;
use strict;
sub valid_jmbg {
my $jmbg = shift;
return 0 unless $jmbg =~ /^\d{13}$/;
my @c = split(//, $jmbg);
my $S=0;
@dpavlin
dpavlin / audacity-labels.pl
Created August 12, 2010 18:31
Dump labels from Audacity into <li> with formatting
#!/usr/bin/perl
# usage:
# ./audacity-labels.pl 6-nosql-take-3.aup
use warnings;
use strict;
use XML::Simple;
use Data::Dump qw(dump);
@dpavlin
dpavlin / jmbag.pl
Last active April 30, 2017 20:48
JMBAG checksum validator/calculator
#!/usr/bin/perl
use warnings;
use strict;
sub jmbag_check {
my $jmbag = shift;
$jmbag = sprintf "%09d", $jmbag if length $jmbag < 9;
my $sum = 0;
my $pos = 0;
@dpavlin
dpavlin / mysqldump-4-to-5-migration.pl
Created July 10, 2012 19:31
Migrate MySQL 4.0 dump to 5.5 format
#!/usr/bin/perl
use warnings;
use strict;
my $create_table = 0;
sub key {
my ($unique,$key,$name,$cols) = @_;
$name = "`$name`" if defined $name;
return " $unique$key $name (" . join(',', map {
@dpavlin
dpavlin / qr-wifi.sh
Created August 21, 2013 12:08
Generate #QR code for #WIFI network
#/bin/sh -xe
# Generate QR code for WIFI network
test -z "$1" && echo -n "ssid: " && read ssid || ssid=$1
test -z "$2" && echo -n "password: " && read pass || pass=$2
qrencode -o /tmp/qr-${ssid}.png "WIFI:S:$ssid;T:WPA;P:$pass;" ; qiv -m /tmp/qr-${ssid}.png
@dpavlin
dpavlin / mchck-ezPort-buspirate.txt
Last active August 24, 2017 22:29
mchck buspirate SPI try to enter ezPort mode (non-working at the moment) moved to wiki at https://github.com/mchck/mchck/wiki/ezPort
newest version of this gist is part of wiki at https://github.com/mchck/mchck/wiki/ezPort
ezPort setup for flasing rig is deescibed at https://mchck.org/blog/2013-09-12-mc_hck_flashing_rig
pinout from updated https://github.com/mchck/mchck/wiki/Pinout
MCU pinput source http://cache.freescale.com/files/32bit/doc/data_sheet/K20P48M50SF0.pdf
ezPort description, chapter 29, http://cache.freescale.com/files/32bit/doc/ref_manual/K20P48M50SF0RM.pdf
MCU MCHCK ezPort
@dpavlin
dpavlin / thomson-download.pl
Created December 8, 2013 23:24
Download Thomson master journal list
#!/usr/bin/perl
use warnings;
use strict;
use Mojo::UserAgent;
use Mojo::DOM;
my $ua = Mojo::UserAgent->new;
my @selection = qw( H Y B K D SS );