This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import attr | |
from pympler import asizeof | |
@attr.s() | |
class Coordinates(): | |
x = attr.ib() | |
y = attr.ib() | |
c = Coordinates(x=1, y=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_check_sum(card_number): | |
newlist = list(map(lambda x: double_and_sum_digits4odd(*x), enumerate(card_number[::-1]))) | |
val = sum(newlist[::-1]) | |
if val % 10 == 0: | |
return 'valid' | |
else: | |
return 'not valid' | |
def sum_digits(x): | |
digits = str(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use Test::More tests => 7; | |
BEGIN { | |
use_ok('Class::Date', 'date'); | |
} | |
my $dt0 = date '2016-06-30 12:00'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use Mojolicious::Lite; | |
use Minion; | |
# run app: morbo minion-example.pl | |
# run worker: perl minion-example.pl minion worker | |
# enqueue job: curl 'http://127.0.0.1:3000/do?msg=hello' | |
# show job status: perl minion-example.pl minion job 1 | |
plugin Minion => { SQLite => 'sqlite:test.db' }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see http://perldoc.perl.org/perlipc.html#Signals | |
# http://www.calpoly.edu/cgi-bin/man-cgi?wait+2 | |
# and Perl Cookbook, part 16.19. Avoiding Zombie Processes | |
sub REAPER { | |
local ($!, $?); | |
while ( (my $pid = waitpid(-1, WNOHANG)) > 0 ) { | |
say "Process $pid send CHLD with status $?"; | |
if ( WIFEXITED($?) or WIFSIGNALED($?) ) { | |
if ( $kids{$pid} ) { |
NewerOlder