Skip to content

Instantly share code, notes, and snippets.

View cognominal's full-sized avatar

Stéphane Payrard cognominal

View GitHub Profile
@cognominal
cognominal / perlhistory.md
Last active December 15, 2022 18:15
perl history

interface: punching card --> terminal: (teletype --> video terminal :vt100:1978 ) -> GUI containers: process
sed --> awk --> perl --> raku --> shaku

chunkingr

punched card :inventor:1725 but< a tape>

@cognominal
cognominal / trim
Last active September 9, 2022 08:09
trim
sub trim($s) {
$_ = $s;
s/ ^ \s+//;
s/ \s+ $//;
$_
}
say "'" ~ trim(" toto ") ~ "'"
@cognominal
cognominal / cursor $!a
Created January 8, 2022 19:46
cursor $!a
# the goal of this experiment is to access the long name of a method
# that result in the current match.
# A match being derived from cursor, maybe its $!name is what I want.
# I try to add a &name method in Cursor.nqp but it does not it.
# I list the method name to check.
# that was obvious. I tested using nqp instead of ./nqp
sub quicksort(@list, $low, $high, &compare) {
if $low < $high {
my $q := partition(@list, $low, $high, &compare);
We couldn’t find that file to show.
@cognominal
cognominal / renumber
Last active May 20, 2021 14:39
rename files in the current folder starting with numbers by prepending 0 to get 3 digits numbers
#! /usr/bin/env raku
my @files = dir;
for @files {
rename $_, sprintf("%03s", $0 ) ~ $1 if /(\d+)(.*)/;
}
@cognominal
cognominal / blog.md
Created March 24, 2021 17:58
jsut trying gitlog

just trying

@cognominal
cognominal / bisect
Last active March 25, 2021 22:19
bisect using a raku oneliner #raku
#! /usr/bin/env raku
=begin pod
rk-bisect is given three arguments.
A file path, a raku one liner, and a sha1 (5 chars min).
A each stage of the bisection, $_ is set to
the string content of the file. The one liner
is executed and the commit is considered good if
the oneliner value is truthy.
Eventually rk-bisect print the sha1 of the first bad commit.
# unit class Sexpr;
# use Grammar::Tracer;
grammar Sexpr-Grammar is export {
token ws { [ <comment> | \s ]* } #| <wb> }
rule TOP { <.ws>? <TOP-sexpr>+ }
rule TOP-sexpr { <sexpr> }
rule sexpr { '(' <declare>? <itemy> * ')' } # { say $/.Str } }
token itemy { <sexpr> | <wordy> }
token comment { \h* '#' \V* \v }
<script>
import * as yootils from 'yootils';
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
// export let name;
let type = 'vertical', h, w, size, pos;
let dragging = false
let refs = {}
@cognominal
cognominal / index.html
Last active February 16, 2020 17:55
sekret
<div id="f" class='root'>
<div id="g">
<div id="k">foo</div>
</div>
</div>
<div id='diag'>
kkkkk
</div>