Skip to content

Instantly share code, notes, and snippets.

View worldmind's full-sized avatar

Alexey Shrub worldmind

View GitHub Profile
@worldmind
worldmind / test.py
Last active December 19, 2018 10:47
Compare object sizes in python 3.6
import attr
from pympler import asizeof
@attr.s()
class Coordinates():
x = attr.ib()
y = attr.ib()
c = Coordinates(x=1, y=2)
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)
#!/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';
@worldmind
worldmind / minion-example.pl
Last active March 11, 2021 06:43
Minion example
#!/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' };
@worldmind
worldmind / gist:2724846
Created May 18, 2012 11:47
Perl $SIG{CHLD} handler
# 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} ) {