Skip to content

Instantly share code, notes, and snippets.


Daniel Sockwell codesections

View GitHub Profile
codesections / omni-sigil.raku
Created December 21, 2022 14:26
A Raku class that implements all three of the Positional, Associative, and Callable roles
View omni-sigil.raku
#| A class that implements the Positional, Associative, and Callable roles.
#| Accordingly, this type can be bound variables with any sigil
class Seuss does Positional does Associative does Callable does Iterable {
= Nil, '🐠', '<°))))><';
= (:blue<🐟>, :red<🐡>);
method of { Mu }
codesections /
Created December 20, 2018 22:03
Basic static file server with actix-web
extern crate actix_web;
use actix_web::{fs, server, App};
fn main() {
server::new(|| {
codesections /
Last active May 16, 2022 23:48
use futures::{Async, Future, Poll};
use tokio::io::{AsyncRead, AsyncWrite, Error, ReadHalf, WriteHalf};
use tokio::net::TcpStream;
use warp::{path, Filter, Stream};
struct Receiver {
rx: ReadHalf<TcpStream>,
impl Stream for Receiver {
type Item = String;
codesections /
Last active March 20, 2022 04:35
Naive static file server in rust
use std::io::prelude::*;
use std::net::TcpListener;
use std::net::TcpStream;
mod app;
fn main() {
let listener = TcpListener::bind("").unwrap();
for stream in listener.incoming() {
let stream = stream.unwrap();
codesections / Handles.rakumod
Created February 21, 2022 20:22
Grammar::Handles, a Raku module for grammar delegation
View Handles.rakumod
# Grammar::Handles
my module Grammar::Handles::Helpers {
class X::Grammar::Can'tHandle is Exception {
has $.type is required;
multi method CALL-ME(|c) { die|c)}
method message { q:to/§err/.trim.indent(2);
The `handles` grammar trait expects a Grammar, the name
of a Grammar, a Pair with a Grammar value, or a list of
any of those types. But `handles` was called with:
codesections / Subgrammar.rakumod
Created February 16, 2022 07:07
A role for using multiple grammars/action objects at once in Raku
View Subgrammar.rakumod
role Subgrammar[::G :$grammar, :$actions] {
multi method slag(G) {
my $old-actions = self.actions;
self.set_actions: $actions;
my @wrapped = G.^methods(:local).map: -> &m {
with self.^methods.first({.name eq &}) {
next if $_ === &m or .name eq 'BUILDALL';
.wrap: method (|c) { m self, |c } }
codesections /
Created December 7, 2021 18:35
Most depended on Raku packages (2021-11-24)

This list was generated using the Citation Indices module by Richard Hainsworth (finanalyst) and lists the 30 most-often-depended-modules in the Raku ecosystem as of 2021-11-24 (including both direct and transitive dependencies). For more info, see the ModuleCitation module; thanks, Richard!

Module Name Recursive Citation Index Module Description
JSON::Fast 42.37
MIME::Base64 31.45 Encoding and decoding Base64 ASCII strings
File::Directory::Tree 30.89 Port of File::Path::Tiny - create and delete directory trees
URI 28.44 A URI implementation using Raku grammars to implement RFC 3986 BNF
OpenSSL 24.11 OpenSSL bindings
File::Temp 23.35
codesections / linkedList.js
Created January 6, 2019 23:01
A simple linked list implemented in JavaScript
View linkedList.js
const LinkedList = function() {
this.head = null;
this.tail = null;
LinkedList.prototype.addToTail = function(value) {
const newTail = { value, next: null };
if (this.tail) { = newTail;
codesections /
Last active November 4, 2021 10:04
A proof of concept showing streaming from a Redis pub/sub channel to Server Sent Events
use futures::{Async, Poll};
use redis;
use std::time::Duration;
use warp::{path, Filter, Stream};
struct OutputStream {
con: redis::Connection,
impl OutputStream {
codesections / immitating-julia.raku
Created September 7, 2021 18:49
Raku is pretty flexible
View immitating-julia.raku
constant gcd = &[gcd];
constant collect = *.bounds;
constant extrema = &minmax;
my &find_gcd = gcd ∘ collect ∘ extrema;