Skip to content

Instantly share code, notes, and snippets.

@dex4er
Last active April 3, 2024 08:13
Show Gist options
  • Save dex4er/1330416 to your computer and use it in GitHub Desktop.
Save dex4er/1330416 to your computer and use it in GitHub Desktop.

Revisions

  1. dex4er revised this gist Apr 3, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions url.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    # URL encoding by RFC 3986 (by line)
    perl -MURI::Escape -pe '$_=uri_escape($_)'
    perl -MURI::Escape -pe '$_=uri_unescape($_)'
    perl -MURI::Escape -lpe '$_=uri_escape($_)'
    perl -MURI::Escape -lpe '$_=uri_unescape($_)'
  2. dex4er revised this gist Jul 8, 2014. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions plack.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,11 @@
    # Test webserver
    plackup -e 'sub { [ 200, [], [Data::Dumper::Dump @_] ] }'
    plackup -e 'sub{[200,[],[Data::Dumper::Dumper@_]]}'

    # Fileserver
    plackup -MPlack::App::Directory -e 'Plack::App::Directory->new'

    # HTTP proxy (Starlight is the most stable server)
    starlight -MPlack::App::Proxy -e 'enable q{AccessLog}; enable q{Proxy::Connect}; enable q{Proxy::Requests}; Plack::App::Proxy->new->to_app'
    starlight -MPlack::App::Proxy -e 'enable q{AccessLog};enable q{Proxy::Connect};enable q{Proxy::Requests};Plack::App::Proxy->new->to_app'

    # Serving cgi-bin scripts
    plackup -MPlack::App::CGIBin -e 'Plack::App::CGIBin->new(root=>".",exec_cb=>sub{1})->to_app'
  3. dex4er revised this gist Jun 20, 2014. 2 changed files with 3 additions and 3 deletions.
    2 changes: 1 addition & 1 deletion perl.sh
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    rlwrap -m -A -pgreen -S"perl> " perl -CS -w -MData::Dump -wnE'@a=eval;print"\033[0;33m";dd@a;print"\033[0;31m$@"if$@'
    rlwrap -m -A -pgreen -S"perl> " perl -CS -w -MData::Dump -wnE'@_=eval;print"\033[0;33m";dd@_;print"\033[0;31m$@"if$@'
    4 changes: 2 additions & 2 deletions plack.sh
    Original file line number Diff line number Diff line change
    @@ -4,5 +4,5 @@ plackup -e 'sub { [ 200, [], [Data::Dumper::Dump @_] ] }'
    # Fileserver
    plackup -MPlack::App::Directory -e 'Plack::App::Directory->new'

    # HTTP proxy (Starlet is the most stable server)
    plackup -s Starlet -MPlack::App::Proxy -e 'my $proxy = Plack::App::Proxy->new->to_app; sub { my $env = shift; $env->{"plack.proxy.url"} = $env->{REQUEST_URI}; $proxy->($env) }'
    # HTTP proxy (Starlight is the most stable server)
    starlight -MPlack::App::Proxy -e 'enable q{AccessLog}; enable q{Proxy::Connect}; enable q{Proxy::Requests}; Plack::App::Proxy->new->to_app'
  4. dex4er revised this gist Jun 20, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions perl.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    rlwrap -m -A -pgreen -S"perl> " perl -CS -w -MData::Dump -wnE'@a=eval;print"\033[0;33m";dd@a;print"\033[0;31m$@"if$@'
  5. dex4er revised this gist Sep 10, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions plack.sh
    Original file line number Diff line number Diff line change
    @@ -4,5 +4,5 @@ plackup -e 'sub { [ 200, [], [Data::Dumper::Dump @_] ] }'
    # Fileserver
    plackup -MPlack::App::Directory -e 'Plack::App::Directory->new'

    # HTTP proxy (with Twiggy or Starlet)
    plackup -s Twiggy -MPlack::App::Proxy -e 'my $proxy = Plack::App::Proxy->new->to_app; sub { my $env = shift; $env->{"plack.proxy.url"} = $env->{REQUEST_URI}; $proxy->($env) }'
    # HTTP proxy (Starlet is the most stable server)
    plackup -s Starlet -MPlack::App::Proxy -e 'my $proxy = Plack::App::Proxy->new->to_app; sub { my $env = shift; $env->{"plack.proxy.url"} = $env->{REQUEST_URI}; $proxy->($env) }'
  6. dex4er revised this gist Sep 7, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions date.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # Normalize date
    perl -MPOSIX::strptime=strptime -MPOSIX=strftime -le '$f="%Y-%m-%d %H:%M:%S"; print strftime $f, strptime "2012-3-14 5:6:7", $f'
  7. dex4er revised this gist Aug 29, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions plack.sh
    Original file line number Diff line number Diff line change
    @@ -4,5 +4,5 @@ plackup -e 'sub { [ 200, [], [Data::Dumper::Dump @_] ] }'
    # Fileserver
    plackup -MPlack::App::Directory -e 'Plack::App::Directory->new'

    # HTTP proxy
    plackup -MPlack::App::Proxy -e 'my $proxy = Plack::App::Proxy->new->to_app; sub { my $env = shift; $env->{"plack.proxy.url"} = $env->{REQUEST_URI}; $proxy->($env) }'
    # HTTP proxy (with Twiggy or Starlet)
    plackup -s Twiggy -MPlack::App::Proxy -e 'my $proxy = Plack::App::Proxy->new->to_app; sub { my $env = shift; $env->{"plack.proxy.url"} = $env->{REQUEST_URI}; $proxy->($env) }'
  8. dex4er renamed this gist Aug 28, 2012. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions psgi.sh → plack.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    # Simplest webserver
    plackup -MYAML::Syck --port 8080 -e 'sub { [ 200, [], [Dump \%ENV] ] }'
    # Test webserver
    plackup -e 'sub { [ 200, [], [Data::Dumper::Dump @_] ] }'

    # Simplest proxy
    # Fileserver
    plackup -MPlack::App::Directory -e 'Plack::App::Directory->new'

    # HTTP proxy
    plackup -MPlack::App::Proxy -e 'my $proxy = Plack::App::Proxy->new->to_app; sub { my $env = shift; $env->{"plack.proxy.url"} = $env->{REQUEST_URI}; $proxy->($env) }'
  9. dex4er revised this gist Aug 13, 2012. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions psgi.sh
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,5 @@
    # Simplest webserver
    plackup -MYAML::Syck --port 8080 -e 'sub { [ 200, [], [Dump \%ENV] ] }'

    # Simplest proxy
    plackup -MPlack::App::Proxy -e 'my $proxy = Plack::App::Proxy->new->to_app; sub { my $env = shift; $env->{"plack.proxy.url"} = $env->{REQUEST_URI}; $proxy->($env) }'
  10. dex4er revised this gist Apr 26, 2012. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions base64.sh
    Original file line number Diff line number Diff line change
    @@ -3,3 +3,6 @@ perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)' < file

    # Decoding file
    perl -MMIME::Base64 -ne 'print decode_base64($_)' < file.b64

    # HMAC-SHA1
    perl -MDigest::HMAC_SHA1 -le '$_=Digest::HMAC_SHA1->new($ARGV[0])->add($ARGV[1])->b64digest; $_.="=" x length % 4; print' TestKey TestString
  11. dex4er revised this gist Apr 6, 2012. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions ucp.sh
    Original file line number Diff line number Diff line change
    @@ -4,14 +4,14 @@ perl -MEncode -ple '$_=encode "GSM0338", decode "UTF-8", $_; $l=length($_)*2; $l
    # Decode GSM 03.38 7-bit string to UTF-8
    perl -MEncode -ple 's/^(..)//; $l = (hex($1)+2)*4; $b=unpack "b*", pack "H*", $_; $b=~s/(.{7})/$1./g; $b=substr $b, 0, $l; $b=substr $b, 0, int(length($b)/8)*8; $_=decode "GSM0338", pack "b*", $b;'

    # Encode UTF-8 as ESTI GSM 03.38 IRA string
    # Encode UTF-8 string as ESTI GSM 03.38 IRA hex string
    perl -MEncode -ple '$_=uc unpack "H*", encode "GSM0338", decode "UTF-8", $_'

    # Decode ESTI GSM 03.38 to UTF-8 IRA string
    # Decode ESTI GSM 03.38 to UTF-8 IRA hex string
    perl -MEncode -ple '$_=encode "UTF-8", decode "GSM0338", pack "H*", $_'

    # Encode UTF-8 as UCS2-LE IRA string
    # Encode UTF-8 as UCS2-LE IRA hex string
    perl -MEncode -ple '$_=uc unpack "H*", pack "n*", unpack "v*", encode "UCS-2LE", decode "UTF-8", $_'

    # Decode UCS2-LE IRA string to UTF-8
    # Decode UCS2-LE IRA hex string to UTF-8
    perl -MEncode -ple '$_=encode "UTF-8", decode "UCS-2LE", pack "v*", unpack "n*", pack "H*", $_'
  12. dex4er revised this gist Jan 30, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion psgi.sh
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    # Simplest webserver
    $ plackup -MYAML::Syck --port 8080 -e 'sub { [ 200, [], [Dump \%ENV] ] }'
    plackup -MYAML::Syck --port 8080 -e 'sub { [ 200, [], [Dump \%ENV] ] }'
  13. dex4er revised this gist Jan 30, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions psgi.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # Simplest webserver
    $ plackup -MYAML::Syck --port 8080 -e 'sub { [ 200, [], [Dump \%ENV] ] }'
  14. dex4er revised this gist Jan 20, 2012. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions base64.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # Encoding file
    perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)' < file

    # Decoding file
    perl -MMIME::Base64 -ne 'print decode_base64($_)' < file.b64
  15. dex4er revised this gist Nov 30, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions regexp.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # Assemble regexp from list of strings
    perl -MRegexp::Assemble -pe 'BEGIN { $r=Regexp::Assemble->new }; $r->add($_); undef $_; END { print $r->re, "\n" }'
  16. dex4er revised this gist Nov 30, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions ucp.sh
    Original file line number Diff line number Diff line change
    @@ -5,13 +5,13 @@ perl -MEncode -ple '$_=encode "GSM0338", decode "UTF-8", $_; $l=length($_)*2; $l
    perl -MEncode -ple 's/^(..)//; $l = (hex($1)+2)*4; $b=unpack "b*", pack "H*", $_; $b=~s/(.{7})/$1./g; $b=substr $b, 0, $l; $b=substr $b, 0, int(length($b)/8)*8; $_=decode "GSM0338", pack "b*", $b;'

    # Encode UTF-8 as ESTI GSM 03.38 IRA string
    perl -MEncode -ple '$_=unpack "H*", encode "GSM0338", decode "UTF-8", $_'
    perl -MEncode -ple '$_=uc unpack "H*", encode "GSM0338", decode "UTF-8", $_'

    # Decode ESTI GSM 03.38 to UTF-8 IRA string
    perl -MEncode -ple '$_=encode "UTF-8", decode "GSM0338", pack "H*", $_'

    # Encode UTF-8 as UCS2-LE IRA string
    perl -MEncode -ple '$_=unpack "H*", pack "n*", unpack "v*", encode "UCS-2LE", decode "UTF-8", $_'
    perl -MEncode -ple '$_=uc unpack "H*", pack "n*", unpack "v*", encode "UCS-2LE", decode "UTF-8", $_'

    # Decode UCS2-LE IRA string to UTF-8
    perl -MEncode -ple '$_=encode "UTF-8", decode "UCS-2LE", pack "v*", unpack "n*", pack "H*", $_'
  17. dex4er revised this gist Nov 30, 2011. 1 changed file with 15 additions and 6 deletions.
    21 changes: 15 additions & 6 deletions ucp.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,17 @@
    # Encode ASCII string as GSM 7bit string (without charmap conversion)
    perl -ple '$l=length($_)*2; $l -= $l>6 ? int($l/8) : 0; $b=unpack("b*", $_); $b=~s/(.{7})./$1/g; $_=sprintf "%02X%s", $l, uc unpack("H*", pack("b*", $b))'
    # Encode UTF-8 string as GSM 03.38 7-bit string
    perl -MEncode -ple '$_=encode "GSM0338", decode "UTF-8", $_; $l=length($_)*2; $l -= $l>6 ? int($l/8) : 0; $b=unpack "b*", $_; $b=~s/(.{7})./$1/g; $_=sprintf "%02X%s", $l, uc unpack "H*", pack "b*", $b'

    # Encode UTF-8 as ESTI GSM 03.38
    perl -MEncode -pe '$_=encode("gsm0338", $_)'
    # Decode GSM 03.38 7-bit string to UTF-8
    perl -MEncode -ple 's/^(..)//; $l = (hex($1)+2)*4; $b=unpack "b*", pack "H*", $_; $b=~s/(.{7})/$1./g; $b=substr $b, 0, $l; $b=substr $b, 0, int(length($b)/8)*8; $_=decode "GSM0338", pack "b*", $b;'

    # Decode ESTI GSM 03.38 to UTF-8
    perl -MEncode -pe '$_=decode("gsm0338", $_)'
    # Encode UTF-8 as ESTI GSM 03.38 IRA string
    perl -MEncode -ple '$_=unpack "H*", encode "GSM0338", decode "UTF-8", $_'

    # Decode ESTI GSM 03.38 to UTF-8 IRA string
    perl -MEncode -ple '$_=encode "UTF-8", decode "GSM0338", pack "H*", $_'

    # Encode UTF-8 as UCS2-LE IRA string
    perl -MEncode -ple '$_=unpack "H*", pack "n*", unpack "v*", encode "UCS-2LE", decode "UTF-8", $_'

    # Decode UCS2-LE IRA string to UTF-8
    perl -MEncode -ple '$_=encode "UTF-8", decode "UCS-2LE", pack "v*", unpack "n*", pack "H*", $_'
  18. dex4er revised this gist Nov 29, 2011. 3 changed files with 5 additions and 5 deletions.
    2 changes: 1 addition & 1 deletion json.sh
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,4 @@
    perl -MJSON -ple '$_=encode_json eval $_'

    # JSON 2 Perl
    perl -MJSON::PP -MJSON::Syck=Load -MData::Dumper -ple '$_=Dumper(Load(encode_json(JSON::PP->new->relaxed->allow_barekey->decode($_))));'
    perl -MJSON::PP -MJSON::Syck=Load -MData::Dumper -pe '$_=Dumper(Load(encode_json(JSON::PP->new->relaxed->allow_barekey->decode($_))));'
    4 changes: 2 additions & 2 deletions ucp.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    perl -ple '$l=length($_)*2; $l -= $l>6 ? int($l/8) : 0; $b=unpack("b*", $_); $b=~s/(.{7})./$1/g; $_=sprintf "%02X%s", $l, uc unpack("H*", pack("b*", $b))'

    # Encode UTF-8 as ESTI GSM 03.38
    perl -MEncode -pi -e '$_=encode("gsm0338", $_)'
    perl -MEncode -pe '$_=encode("gsm0338", $_)'

    # Decode ESTI GSM 03.38 to UTF-8
    perl -MEncode -pi -e '$_=decode("gsm0338", $_)'
    perl -MEncode -pe '$_=decode("gsm0338", $_)'
    4 changes: 2 additions & 2 deletions url.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    # URL encoding by RFC 3986 (by line)
    perl -MURI::Escape -ple '$_=uri_escape($_)'
    perl -MURI::Escape -ple '$_=uri_unescape($_)'
    perl -MURI::Escape -pe '$_=uri_escape($_)'
    perl -MURI::Escape -pe '$_=uri_unescape($_)'
  19. dex4er revised this gist Nov 29, 2011. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion ucp.sh
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,8 @@
    # Encode ASCII string as GSM 7bit string (without charmap conversion)
    perl -ple '$l=length($_)*2; $l -= $l>6 ? int($l/8) : 0; $b=unpack("b*", $_); $b=~s/(.{7})./$1/g; $_=sprintf "%02X%s", $l, uc unpack("H*", pack("b*", $b))'
    perl -ple '$l=length($_)*2; $l -= $l>6 ? int($l/8) : 0; $b=unpack("b*", $_); $b=~s/(.{7})./$1/g; $_=sprintf "%02X%s", $l, uc unpack("H*", pack("b*", $b))'

    # Encode UTF-8 as ESTI GSM 03.38
    perl -MEncode -pi -e '$_=encode("gsm0338", $_)'

    # Decode ESTI GSM 03.38 to UTF-8
    perl -MEncode -pi -e '$_=decode("gsm0338", $_)'
  20. dex4er revised this gist Nov 23, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions xml.sh
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,9 @@ perl -MXML::Compile::Schema -le '$r=shift @ARGV; $s=XML::Compile::Schema->new; $
    # XSD 2 example YAML
    perl -MYAML -MXML::Compile::Schema -le '$r=shift @ARGV; $s=XML::Compile::Schema->new; $s->importDefinitions($_) for @ARGV; print Dump eval $s->template("PERL", $r, show=>"ALL")'

    # XML to YAML
    perl -MYAML -MXML::Compile::Schema -MXML::Compile::Util=type_of_node -le '$x=XML::LibXML->new->parse_fh(\*STDIN); $r=$x->documentElement; print Dump (XML::Compile::Schema->new(\@ARGV)->compile(READER=>type_of_node($r), sloppy_integers=>1, sloppy_floats=>1)->($r));' *.xsd < file.xml

    # YAML to XML
    perl -MYAML=LoadFile,Dump -MXML::Compile::Schema -le
    '$d=LoadFile(shift @ARGV); $r=shift @ARGV; $x=XML::LibXML::Document->new("1.0", "UTF-8"); $x=XML::Compile::Schema->new(\@ARGV)->compile(WRITER => $r)->($x, $d); print $x->toString(1)' file.yml '{http://some.name.space/}rootTag' *.xsd
  21. dex4er revised this gist Nov 23, 2011. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions xml.sh
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,15 @@ perl -MXML::Twig -MText::Wrap -e 'package Text::Wrap; $columns=78; $huge="overfl
    perl -MXML::Twig -MText::Wrap -e 'package Text::Wrap; $columns=78; $huge="overflow"; XML::Twig->new(pretty_print=>"indented_a")->parse(\*STDIN)->print;'

    # XSD 2 example XML
    # Arguments: '{http://some.name.space/}rootTag' *.xsd
    perl -MXML::Compile::Schema -le '$r=shift @ARGV; $s=XML::Compile::Schema->new; $s->importDefinitions($_) for @ARGV; print $s->template("XML", $r, show=>"ALL")'
    perl -MXML::Compile::Schema -le '$r=shift @ARGV; $s=XML::Compile::Schema->new; $s->importDefinitions($_) for @ARGV; print $s->template("XML", $r, show=>"ALL")' '{http://some.name.space/}rootTag' *.xsd

    # XSD 2 example YAML
    perl -MYAML -MXML::Compile::Schema -le '$r=shift @ARGV; $s=XML::Compile::Schema->new; $s->importDefinitions($_) for @ARGV; print Dump eval $s->template("PERL", $r, show=>"ALL")'

    # YAML to XML
    perl -MYAML=LoadFile,Dump -MXML::Compile::Schema -le
    '$d=LoadFile(shift @ARGV); $r=shift @ARGV; $x=XML::LibXML::Document->new("1.0", "UTF-8"); $x=XML::Compile::Schema->new(\@ARGV)->compile(WRITER => $r)->($x, $d); print $x->toString(1)' file.yml '{http://some.name.space/}rootTag' *.xsd

    # YAML to XML where data are inside hash key
    perl -MYAML=LoadFile,Dump -MXML::Compile::Schema -le
    '$d=LoadFile(shift @ARGV); $r=shift @ARGV; ($a=$r)=~s/{.*}//; $x=XML::LibXML::Document->new("1.0", "UTF-8"); $x=XML::Compile::Schema->new(\@ARGV)->compile(WRITER => $r)->($x, $d->{$a}); print $x->toString(1)' file.yml '{http://some.name.space/}action' *.xsd
  22. dex4er revised this gist Nov 22, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions xml.sh
    Original file line number Diff line number Diff line change
    @@ -7,3 +7,6 @@ perl -MXML::Twig -MText::Wrap -e 'package Text::Wrap; $columns=78; $huge="overfl
    # XSD 2 example XML
    # Arguments: '{http://some.name.space/}rootTag' *.xsd
    perl -MXML::Compile::Schema -le '$r=shift @ARGV; $s=XML::Compile::Schema->new; $s->importDefinitions($_) for @ARGV; print $s->template("XML", $r, show=>"ALL")'

    # XSD 2 example YAML
    perl -MYAML -MXML::Compile::Schema -le '$r=shift @ARGV; $s=XML::Compile::Schema->new; $s->importDefinitions($_) for @ARGV; print Dump eval $s->template("PERL", $r, show=>"ALL")'
  23. dex4er revised this gist Nov 22, 2011. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion xml.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    # Pretty printing in compact form
    perl -MXML::Twig -MText::Wrap -e 'package Text::Wrap; $columns=78; $huge="overflow"; XML::Twig->new(pretty_print=>"indented_c")->parse(\*STDIN)->print;'

    # Pretty printing with attributes in separate lines
    # Pretty printing with attributes in separate lines (VCS-friendly)
    perl -MXML::Twig -MText::Wrap -e 'package Text::Wrap; $columns=78; $huge="overflow"; XML::Twig->new(pretty_print=>"indented_a")->parse(\*STDIN)->print;'

    # XSD 2 example XML
    # Arguments: '{http://some.name.space/}rootTag' *.xsd
    perl -MXML::Compile::Schema -le '$r=shift @ARGV; $s=XML::Compile::Schema->new; $s->importDefinitions($_) for @ARGV; print $s->template("XML", $r, show=>"ALL")'
  24. dex4er revised this gist Nov 21, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ucp.sh
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    # Encode ASCII string as GSM 7bit string (without charmap conversion)
    perl -ple 'chomp; $l=length($_)*2; $l-=$l>6?int($l/8):0; $b=unpack("b*",$_); $b=~s/(.{7})./$1/g; $_=sprintf "%02X%s", $l, uc unpack("H*", pack("b*", $b))'
    perl -ple '$l=length($_)*2; $l -= $l>6 ? int($l/8) : 0; $b=unpack("b*", $_); $b=~s/(.{7})./$1/g; $_=sprintf "%02X%s", $l, uc unpack("H*", pack("b*", $b))'
  25. dex4er revised this gist Nov 21, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions ucp.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # Encode ASCII string as GSM 7bit string (without charmap conversion)
    perl -ple 'chomp; $l=length($_)*2; $l-=$l>6?int($l/8):0; $b=unpack("b*",$_); $b=~s/(.{7})./$1/g; $_=sprintf "%02X%s", $l, uc unpack("H*", pack("b*", $b))'
  26. dex4er revised this gist Nov 18, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions xml.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Pretty printing in compact form
    perl -MXML::Twig -MText::Wrap -e 'XML::Twig->new(pretty_print=>"indented_c")->parse(\*STDIN)->print;'
    perl -MXML::Twig -MText::Wrap -e 'package Text::Wrap; $columns=78; $huge="overflow"; XML::Twig->new(pretty_print=>"indented_c")->parse(\*STDIN)->print;'

    # Pretty printing with attributes in separate lines
    perl -MXML::Twig -MText::Wrap -e 'XML::Twig->new(pretty_print=>"indented_a")->parse(\*STDIN)->print;'
    perl -MXML::Twig -MText::Wrap -e 'package Text::Wrap; $columns=78; $huge="overflow"; XML::Twig->new(pretty_print=>"indented_a")->parse(\*STDIN)->print;'
  27. dex4er revised this gist Nov 18, 2011. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions xml.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # Pretty printing in compact form
    perl -MXML::Twig -MText::Wrap -e 'XML::Twig->new(pretty_print=>"indented_c")->parse(\*STDIN)->print;'

    # Pretty printing with attributes in separate lines
    perl -MXML::Twig -MText::Wrap -e 'XML::Twig->new(pretty_print=>"indented_a")->parse(\*STDIN)->print;'
  28. dex4er revised this gist Nov 18, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion json.sh
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,4 @@
    perl -MJSON -ple '$_=encode_json eval $_'

    # JSON 2 Perl
    perl -MJSON::PP -MJSON::Syck -MData::Dumper -ple '$_=Dumper(JSON::Syck::Load(JSON::PP->new->encode(JSON::PP->new->relaxed->allow_barekey->decode($_))));'
    perl -MJSON::PP -MJSON::Syck=Load -MData::Dumper -ple '$_=Dumper(Load(encode_json(JSON::PP->new->relaxed->allow_barekey->decode($_))));'
  29. dex4er revised this gist Nov 18, 2011. 2 changed files with 8 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions json.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # Perl 2 JSON
    perl -MJSON -ple '$_=encode_json eval $_'

    # JSON 2 Perl
    perl -MJSON::PP -MJSON::Syck -MData::Dumper -ple '$_=Dumper(JSON::Syck::Load(JSON::PP->new->encode(JSON::PP->new->relaxed->allow_barekey->decode($_))));'
    3 changes: 3 additions & 0 deletions url.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    # URL encoding by RFC 3986 (by line)
    perl -MURI::Escape -ple '$_=uri_escape($_)'
    perl -MURI::Escape -ple '$_=uri_unescape($_)'
  30. dex4er revised this gist Nov 18, 2011. 2 changed files with 2 additions and 6 deletions.
    2 changes: 2 additions & 0 deletions md5.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # MD5 checksum (whole file)
    perl -MDigest::Perl::MD5=md5_hex -le 'undef $/; $_=<STDIN>; print md5_hex($_)'
    6 changes: 0 additions & 6 deletions oneliners.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +0,0 @@
    # MD5 checksum (whole file)
    perl -MDigest::Perl::MD5=md5_hex -le 'undef $/; $_=<STDIN>; print md5_hex($_)'

    # URL encoding by RFC 3986 (by line)
    perl -MURI::Escape -ple '$_=uri_escape($_)'
    perl -MURI::Escape -ple '$_=uri_unescape($_)'