If you
had a string of words smushed together without spaces, how would you go about
parsing the string into words again?
http://blogs.perl.org/users/ingy_dot_net/2015/11/perl-regular-expression-awesomeness.html
https://gist.github.com/ingydotnet/94528c938ca94f684270
#!/usr/bin/env perl
use strict;
use Data::Printer;
my $input = 'minusthemessageforeverytriedword';
# All 3+ letter English words, longest to shortest:
my @long = grep {length > 2}
sort {length $b <=> length $a}
map {chomp, $_}
`cat /usr/share/dict/words`;
# `for` over `fore`, `the` over `them`
unshift @long, qw( the for );
# Too many small words in dict file. Use these:
my @short = qw(
ad ah am an as at ax be by do go he hi if in is it
me my no of oh on or ox pi so to up us we yo a I
);
# Make a gigantic list of words for the regexp:
my $list = join '|', @long, @short;
my @words = $input =~ /\G($list)(?=(?:$list)*\z)/g;
p @words;
2015/11/27
2015/11/19
GPG
Import keys from a public server:
gpg --keyserver pgp.mit.edu --search-keys <email>
gpg v1
Encrypt messages #1:
echo "hello" | gpg --symmetric --armor --passphrase "asdf" > message
cat message | gpg
gpg --encrypt --armor <filename>
gpg --decrypt --armor <filename>
How to GPG:
brew install gnupg
gpg --list-secret-keys
gpg --list-public-keys
gpg --list-public-keys
gpg --gen-key
gpg v2
brew install gnupg2
echo "hello" > message
gpg -se -ar "Name Surname" message
gpg -se -ar <long key> message
echo "hello" | gpg -e -ar <long key>
gpg -d message.asc
gpg --list-keys
gpg --keyserver pgp.mit.edu --receive-keys <long key>
gpg v2
brew install gnupg2
echo "hello" > message
gpg -se -ar "Name Surname" message
gpg -se -ar <long key> message
echo "hello" | gpg -e -ar <long key>
gpg -d message.asc
gpg --list-keys
gpg --keyserver pgp.mit.edu --receive-keys <long key>
2015/11/03
Convert timestamp to UTC date
select CONVERT_TZ(FROM_UNIXTIME(1443737234), @@session.time_zone, '+00:00') AS utc;
Get time zone from MySQL
SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP);
SELECT EXTRACT(HOUR FROM (TIMEDIFF(NOW(), UTC_TIMESTAMP))) AS `timezone`;
MySQL Timezone Cheatsheet
Read this
SELECT EXTRACT(HOUR FROM (TIMEDIFF(NOW(), UTC_TIMESTAMP))) AS `timezone`;
MySQL Timezone Cheatsheet
Read this
2015/11/02
Install modules via cpanm and cpanfile
Install cpanm from:
http://xrl.us/cpanm
cat cpanfile:
requires 'File::Slurper';
command to install:
cpanm --quiet --no-man-pages --notest --installdeps .
http://xrl.us/cpanm
cat cpanfile:
requires 'File::Slurper';
command to install:
cpanm --quiet --no-man-pages --notest --installdeps .
Subscribe to:
Posts (Atom)