Skip to content

Instantly share code, notes, and snippets.

@masak
masak / four-commands.md
Last active December 20, 2015 07:39
Four commands working on the index

See commit 6ad6d3d36c5924c8ff502ebbb6a6216df01e7efb in git.git for an update to the README file about these four commands.

+--------------+   update-cache   +--------------+  write-tree   +-----------+
|              | ---------------> |              | ------------> |           |
| working copy |                  | staging area |               | object db |
|              | <--------------- |              | <------------ |           |
+--------------+  checkout-cache  +--------------+   read-tree   +-----------+

(update-cache and checkout-cache were later renamed to *-index.)

@masak
masak / failure.txt
Created July 5, 2013 20:17
cannot build Rakudo on Parrot
$ make && make install
cd src/vm/parrot/ops && /home/masak/ours/rakudo/install/bin/ops2c C --dynamic perl6.ops
# Parsing perl6.ops...
# Parsed perl6.ops in 3.691 seconds; found 124 ops.
# Ops parsed in 3.706 seconds.
cd src/vm/parrot/ops && cc -c -o perl6_ops.o -I/home/masak/ours/rakudo/install/include/parrot/5.5.0-devel -I/home/masak/ours/rakudo/install/include/parrot/5.5.0-devel/pmc -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHASATTRIBUTE_CONST -DHASATTRIBUTE_DEPRECATED -DHASATTRIBUTE_MALLOC -DHASATTRIBUTE_NONNULL -DHASATTRIBUTE_NORETURN -DHASATTRIBUTE_PURE -DHASATTRIBUTE_UNUSED -DHASATTRIBUTE_WARN_UNUSED_RESULT -DHASATTRIBUTE_HOT -DHASATTRIBUTE_COLD -DDISABLE_GC_DEBUG=1 -DNDEBUG -DHAS_GETTEXT -fPIC -falign-functions=16 -funit-at-a-time -fexcess-precision=standard -maccumulate-outgoing-args -Wall -Wextra -Waggregate-return -Wcast-qual -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wformat-extra-args -Wform
@masak
masak / output
Created June 20, 2013 20:29
Configure.pl fails on a clean nqp :/
$ git clone [email protected]:perl6/nqp.git
Cloning into 'nqp'...
remote: Counting objects: 29924, done.
remote: Compressing objects: 100% (8724/8724), done.
remote: Total 29924 (delta 20448), reused 29724 (delta 20263)
Receiving objects: 100% (29924/29924), 50.78 MiB | 10.82 MiB/s, done.
Resolving deltas: 100% (20448/20448), done.
$ cd nqp/
@masak
masak / PROMISE.pl
Last active December 18, 2015 17:28 — forked from labster/PROMISE.pl
use strict;
use warnings;
use feature 'say';
package Promise {
sub state {
return shift->{'state'};
}
@masak
masak / pool-administrator.pl
Last active December 18, 2015 10:29
Pool administrator math problem
use v6;
# There's a swimming pool with a water inlet and a discharging tube. The water
# inlet can make the pool full in 6 hours. The discharging tube can empty the
# pool in 8 hours.
#
# One time the pool administrator forgot to switch off the discharging tube
# when he injected the water. 40 minutes had passed when he found it.
#
# Question: how long until the pool will be full of water?
@masak
masak / example.txt
Created June 12, 2013 15:59
MAIN subs in modules in Perl 6
$ cat Foo.pm
module Foo;
sub MAIN() {
say "OH HAI";
}
$ perl6 Foo.pm
$ # no output
@masak
masak / restaurant.pl
Last active December 17, 2015 19:59
Constraint satisfaction problem http://xkcd.com/287/ solved in Perl 6
class Constraint {
has Real %.coefficients;
has Real $.sum = 0;
}
sub unknown($unknown) {
return Constraint.new( :coefficients{ $unknown => 1 } );
}
multi infix:<+>(Constraint $l, Constraint $r) {
@masak
masak / description.txt
Last active January 10, 2019 15:06
objects and operations in Dark needed for my blog
Pipe (for example set, convert, publish, take)
---- \ ----
---- \ ----
---- / ----
---- / ----
Funnel (for example aggregate)
---- \
@masak
masak / passwords.pl
Last active December 17, 2015 14:09
An update of https://gist.github.com/masak/158336 , four years later
sub only($rx) { /^ <$rx>+ $/ }
sub letters-with($n, $rx) { my $n1 = $n+1; /^ [<alpha>*] ** $n1 % <$rx> $/ }
sub letters-with-any($rx) { /^ [<alpha>*]+ % <$rx> $/ }
sub alnums-with($n, $rx) { my $n1 = $n+1; /^ [<alnum>*] ** $n1 % <$rx> $/ }
my @types =
'total ' => *,
' alphanumerics-only ' => only(/<alnum>/),
' digits-only ' => only(/\d/),
' letters-only ' => only(/<alpha>/),
@masak
masak / error
Created May 9, 2013 16:13
this is the error I get from doing the 'has %!elems{Any}'
masak@mutex ~/ours/rakudo $ git di
diff --git a/src/core/Set.pm b/src/core/Set.pm
index 5f8d556..763c625 100644
--- a/src/core/Set.pm
+++ b/src/core/Set.pm
@@ -1,5 +1,5 @@
my class Set is Iterable does Associative {
- has %!elems;
+ has %!elems{Any};