Skip to content

Instantly share code, notes, and snippets.

@gustafe
gustafe / date-stats.pl
Created January 8, 2023 20:03
Simple Perl program to count the number of month-day-weekday combinations since 1538 CE.
#! /usr/bin/env perl
use Modern::Perl '2015';
use DateTime;
###
use utf8;
binmode(STDOUT, ':encoding(UTF-8)');
my $date = DateTime->new(year=>1583 , month=>1 ,day=>1);
my $stats;
#! /usr/bin/env perl
use Modern::Perl '2015';
###
sub fizzbuzz {
my ( $in ) = @_;
if ( $in % 15 == 0 ) { return 'fizzbuzz' }
elsif ( $in % 5 == 0 ) { return 'buzz' }
elsif ( $in % 3 == 0 ) { return 'fizz' }
else { return undef }
@gustafe
gustafe / pokemon_attack.pl
Last active July 22, 2021 11:54
Pokemon attacks in Perl
#! /usr/bin/env perl
use Modern::Perl '2015';
###
my %utterances = (
0.5 => "it is not very effective",
1 => "it is normal effective",
2 => "it is super effective!",
0 => "it has no effect",
-1 => "type not recognized!"

This is an extract of the most popular submissions with URLs matching the string 'drewdevault'.

Only submissions with a score+comments total exceeding 10 are presented.

A comments/score ratio above 1.25 is deemed 'controversial' and marked in italic.

https://gerikson.com/hnlo/

#! /usr/bin/env perl
use Modern::Perl '2015';
use Data::Dump qw/dump/;
use Test::More tests => 1;
# discussion: https://lobste.rs/s/zpqrpc/random_job_interview_challenge_clojure
my $input = 'aaaabbbcca';
my $target = '[("a", 4), ("b", 3), ("c", 2), ("a", 1)]';
my @list = split( //, $input );
my @output = ( { c => shift @list, n => 1 } );
while (@list) {
r=1 d=6 t=5 m=1
r=2 d=7 t=6 m=0
r=3 d=8 t=2 m=1
score=8 after 3 rolls
r=1 d=1 t=2 m=1
r=2 d=0 t=6 m=0
score=0 after 2 rolls
r=1 d=6 t=4 m=1
#!/usr/bin/perl -I /home/gustaf/perl5-OLD/lib/perl5/
use strict;
use warnings;
use Astro::MoonPhase;
binmode( STDOUT, ":utf8" );
sub moon_info {
my ($epoch) = @_;
my ( $MoonPhase, $MoonIllum, $MoonAge, $MoonDist,
@gustafe
gustafe / gist:699b269c5740b8caa0781606a696b231
Created February 11, 2020 13:05
some deleted HN posts
22275726|Tips and Pain Point Workarounds for Machine Learning Work in Google Colab
22276229|India's data protection bill may criminalise privacy research
22276347|Warm Water Under Antarctica
22276817|How to interrupt users periodically without being annoying
22277501|Elementary OS is crowdfunding a better distro-independent AppCenter for everyone
22277526|Norris Numbers – Walls you hit in program size (2014)
22277580|Aligning Code with How We Think
22280014|$4B in 2019 Cryptocurrency Scams out of $3.8 trillion of transaction volume
22280797|Show HN: Distribute your GDocs in a whole new way
22280864|Buzzfeed's quiz to accurately estimate your age based on installed apps
@gustafe
gustafe / gist:c2ba79629184922b72b1259b8c707dd0
Last active February 12, 2020 08:49
Top domains from 3 sites
Top 20 domains from Lobste.rs from 2019-07-05 to 2020-02-12
Total entries: 6403
1. github.com ............... 437
2. youtube.com .............. 185
3. medium.com ............... 183
4. dev.to ................... 53
5. devblogs.microsoft.com ... 52
6. arxiv.org ................ 50
7. blog.softwaremill.com .... 47
8. blog.netbsd.org .......... 30