Skip to content

Instantly share code, notes, and snippets.

View bdw's full-sized avatar
💭
Hacking

Bart Wiegmans bdw

💭
Hacking
View GitHub Profile
@bdw
bdw / geojson-to-postgis.py
Created April 12, 2016 10:03
geojson to postgis
#!/usr/bin/env python
from __future__ import print_function, unicode_literals
import operator
import psycopg2
import psycopg2.extras
import io
import json
import sys
import logging
This file has been truncated, but you can view the full file.
Specialization of '' (cuid: 1)
Before:
Spesh of '' (cuid: 1, file: ./t/spec/S32-str/sprintf-b.t:188)
BB 0 (0x7fe9ddcb3818):
line: 188 (pc 0)
Instructions:
no_op
Successors: 1
@bdw
bdw / ListUtil.pm
Created August 27, 2019 10:01
Reimplementation of List::Util for running on perl 5.10
#!/usr/bin/env perl
package ListUtil;
# Reimplementation of List::Util for running on perl 5.10
use strict;
use warnings;
use Exporter 'import';
@ListUtil::EXPORT_OK = qw(pairgrep pairmap pairkeys pairvalues);
sub pairgrep(&@) {
my $code = shift;
@bdw
bdw / cmp_n.nqp
Created July 7, 2019 21:17
floating points nqp
#!/usr/bin/env nqp
if (0.125 < 0.126) {
nqp::say("OK");
} else {
nqp::die("NOT OK");
}
@bdw
bdw / genius.py
Last active June 18, 2019 23:35
Genius - a roman daemon. This is a python context manager which tries to ensure it is the only process identified by a pidfile.
import os
import fcntl
import signal
import time
import contextlib
class Genius(object):
'''
A genius is basically a roman daemon. It differs from python-daemon
in the following ways:
From b0cf91cf7bc32fc20f73f4abc463d952c86983a3 Mon Sep 17 00:00:00 2001
From: Bart Wiegmans <bartwiegmans@gmail.com>
Date: Fri, 17 May 2019 12:45:13 +0200
Subject: [PATCH] [Vector] Implement MVM_VECTOR_CONTAINS with memmem
This should be more flexible (arbitrary sized items) and hopefully
faster because memmem is fairly optimized. And allows the use as an
expression.
---
build/Makefile.in | 1 +

Linking Perl 6 Compiler and Programs

Description

Currently, starting a Perl 6 programs means loading a shell script that starts a MoarVM, that loads the rakudo compiler (as bytecode) and libraries (also bytecode), before loading the user script and compiling that. This adds significantly to the startup time of perl6

#!/usr/bin/env nqp
sub foo(int64 $x) {
my int16 $y := $x;
my int64 $z := $y;
return $z;
}
my int $i := 0;
while ($i++ < 100_000) {
@bdw
bdw / shift.nqp
Created October 6, 2018 19:32
shift test
#!/usr/bin/env nqp
sub shifter(int $x, int $y) {
nqp::abs_i(nqp::bitshiftl_i($x, $y));
}
my int $i := 0;
while ($i++ < 1_000_000) {
my $x := shifter(10,3);
if (shifter(10,3) != 80) {
@bdw
bdw / spesh-log.txt
Created October 5, 2018 09:04
INLINE_END ends up on prepargs
Specialization of 'repository-version' (cuid: 15072)
Before:
Spesh of 'repository-version' (cuid: 15072, file: SETTING::src/core/CompUnit/Repository/Installation.pm6:129)
BB 0 (0x7fffec65a388):
line: 129 (pc 0)
Instructions:
no_op
Successors: 1