Skip to content

Instantly share code, notes, and snippets.

View jjatria's full-sized avatar
🔭
Thinking of telemetry

José Joaquín Atria jjatria

🔭
Thinking of telemetry
View GitHub Profile
@jjatria
jjatria / raku-code-coverage.md
Created December 3, 2021 23:56
A post for the 2021 Raku advent calendar

Raku code coverage

Although I love using Raku, the fact that it is still a relatively young language means that there is a fair amount that is lacking when it comes to tooling, etc. Until recently, this included a way to calculate code coverage: how much of the code in a library is extercised (=covered) by that library's test suite.

Now, truth be told, this feature has been available for some time in the Comma IDE. But this (together with other arguably essential developer tools like profiling, etc) is only available in the "Complete" edition, which requires a paid subscription.

Still, I knew that the Raku compiler kept track of covered lines, so I always felt like this should be doable. It only needed someone to actually do it.

So, consider my surprise when, while recently browsing raku.land, I came across App::RaCoCo, which claims to be 'a Raku Code Coverage tool'. Sweet!

package Modulino::Load;
# ABSTRACT: Load modulinos into their own namespaces
use strict;
use warnings;
use Module::Runtime 'is_module_name';
use Carp 'croak';
# We heard you like legacy code
{
"name": "English_default",
"speech_rate": 2.1184947958366696,
"mean_f0": 94.61124538100846,
"min_f0": 75.73525640729208,
"max_f0": 100.77011149739079,
"range_f0": 25.034855090098702,
"sd_f0": 5.503345067513809,
"mean_intensity": 73.06003609952407,
"min_intensity": 62.3023482497762,
@jjatria
jjatria / wanikani_level.pl
Created April 25, 2017 23:08
Fetch time of level up in WaniKani
#!/usr/bin/env perl
use feature qw( say );
use JSON;
use LWP::Simple;
use DateTime;
my $url = "https://www.wanikani.com/api/user/$ENV{WANIKANI_API_KEY}";
my $level = $ARGV[0] // current_level();

Keybase proof

I hereby claim:

  • I am jjatria on github.
  • I am jjatria (https://keybase.io/jjatria) on keybase.
  • I have a public key ASC5pMTi6LbL-PlveySXQVzho3UV4PSgfw3lRyMMq9XaAgo

To claim this, I am signing this object:

@jjatria
jjatria / factorial.proc
Created August 28, 2015 16:55
Factorial procedure
# Calculate the factorial of a number using
# a recursive procedure.
# A demonstration of the limitations of Praat
# procedures (and of possible workarounds).
#
# Author: José Joaquín Atria
procedure factorial: .n
# Cannot use an inline if here
if !variableExists("factorial.level")
@jjatria
jjatria / praat_version.sh
Created August 22, 2015 14:39
Print praat version
# A bash function to add a -v option to Praat
# for printing the current version
praat() {
if [[ $@ == "-v" ]]; then
s=$(mktemp)
echo "printline 'praatVersion$'" > "$s"
praat "$s"
rm "$s"
else
@jjatria
jjatria / praat-if-comparison.praat
Created May 12, 2015 10:11
Compare results of if-blocks and inline-ifs in Praat
# Compare results of if-blocks and inline-ifs in Praat
# Author: J J Atria
results = Create Table with column names: "table", 0, "sorted branching time"
# How long the data set
rows = 10000
# How many iterations per data set
iterations = 20
@jjatria
jjatria / tag2filename.m3t
Created July 30, 2014 15:43
Rename files from tag for MP3Tag
$if(%discnumber%,disc_%discnumber%\,)$right(0%track%,2).$replace($regexp($regexp($regexp($regexp($regexp($regexp($regexp($regexp($regexp($regexp($regexp($regexp($regexp($replace($lower(%title%),.,, ,_,'',,ñ,n,æ,ae,¹,1,²,2,³,3,×,times,ç,c),';_*',.),'[àáâãäå]',a),'[èéêë]',e),'[ìíîï]',i),'[òóôõöø]',o),'[ùúûü]',u),'[ðþ]',th),'[ýÿ]',y),'[+&]',and),'[¿?¡!#@%^,¤‘’¥°]',),'([._]?[[({]|(\)|\]|\})[._]?|\/)',.),'(\)|\])|\}$',),'^[[({]',),_-_,.,_._,.,..,.)