Skip to content

Instantly share code, notes, and snippets.

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCkB8ZzeCZxUCY51wgGRdplk2NckN/V6OA5BviIveHmPBIxEssmKcPLzOfobgVaEhccqe4tdikVOvxCFzb0NXPw1GZYZ2ORYE9gFadfBwVgMOl1Zl2tdbj+VDM9E19Fc7PoFpLrdwa2AHix81rp6JLe01uZytgXuiKaIC/VweBCiXKGDYbVi8OdClNeSomV4wq/y1om4VN6lvx7H1H18GXMEIvHFlsojXwAWcT2eekc3Ofu8U2+T30jD9gSc7q+K3dqqIubF6mwYSIxcYLrT3HSZlNfToiHuZ/opiW1UjGkQMWrSIroRol/sEoXEgZhRt3ypT3iiWvUDWlW22NwLlwb+sJq6QzCTPMpgCj8WKBbpLl9IUC/k44GAeTA1LNwbXX8Wpp66EdwHtUr+HlS5/b2QENv8DDOGgD1Kgs7FrBhtvPCvlbd6K8pCrgjF8H9yh2mEeQ+3WqIarFJyiMeHCNpDnL6X6xqaNx6CDmiaHRFDm24fhjNQaHx5iMrX8I/qe0= antonijn@adb-desktop
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCMFwA6CSrK730OMOJhhuuMV5uHHTwcDALQj2iKbADzGX/zc0nsJ6ZU8lHnzMhgK2IaBGuMWrE6hxUPPLRciMbbiXiHy5ai8x4ffbLl8bUqlUVfANuA0HBMndXTxFokTw/Op8sFlBwYiwzOjkO3qHPo/Cqg5NC3GkwjnyQId8yNPMNljDZR9HZr0IkdWhaSdpjIsASpomWKcyyYfFfWGDQv/OrqpAmEJh4QN6yZI8Y4aDWtc8FvQDSCUjaElE2uzBmINJC6S9slFhCMA93QmmtgpyOZQ8HQlPe7m31DtSsBE1sAfoMC6cGN+FDIZJIdua8A5z0eZYnCPOrwztH63i6Eqa+Rn26JLFXKhgN+cYF3ZtBxDEg3cHhe9WRcP/bgxLPMbonc3/dlBhZ2chQ/Zug1D7G6y2
@antonijn
antonijn / init.vim
Created October 5, 2022 08:08
My Neovim config
call plug#begin()
Plug 'tomasr/molokai'
Plug 'itchyny/lightline.vim'
call plug#end()
filetype plugin on
set mouse=a
@antonijn
antonijn / .bashrc
Created October 5, 2022 08:06
My bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:$HOME/code/tools/text-tools/bin" ]]
then
@antonijn
antonijn / unicode.c
Last active September 30, 2022 01:13
UTF-8 to UTF-32 converter in C
#include "unicode.h"
#include <stdint.h>
#include <stddef.h>
int is_valid_char(uint32_t ch)
{
return ch < 0xd800 || ch > 0xdfff;
}
int is_combo_char(uint32_t ch)
@antonijn
antonijn / main.c
Created January 3, 2021 15:37
cheax C++ API concept
#include <cheax.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int result;
CHEAX *c = cheax_init();
@antonijn
antonijn / utf8.aqua
Last active March 22, 2020 23:04
UTF-8 decoder
private static int getch(byte[] buf, ref int idx)
{
byte nxt = buf[idx++];
byte mask;
int remunits;
if ((nxt & 0x80) == 0) {
mask = 0;
remunits = 0;
} else {
byte lead = 0xC0;
%code requires {
#include "types.h"
#include <stddef.h>
#include <stdio.h>
}
%code {
int yylex();
void yyerror(ASTFileElement **f, const char *msg);
}
@antonijn
antonijn / CTokens.pm6
Created August 2, 2017 10:16
Perl 6 version of `spt` program (CTokens.pm6 should be in lib dir relative to the main spt file)
use v6;
unit module CTokens;
grammar CTokens::Token is export {
token TOP {
[
<preproc> |
<comment> |
<line-comment> |

Typical Usage of groc

The example presented here shows how one would use groc to create an internationalized die-roll application:

$ roll
You rolled a one
$ roll
@antonijn
antonijn / path.c
Last active April 10, 2017 18:54
PATH interpreter
#include<stdio.h>
#define b ;break;case
#define w (c=getc(f))
int c,x=1,y,u,r=1;char m[30000],*s=m;int main(int i,char**j){FILE*f=fopen(j[1],"r");while(w-'$'){++x;y+=c=='\n'?x=1:0;}for(;;){switch w{case'#':return fclose(f);b'\\':i=u;u=-r;r=-i;b'/':i=u;u=r;r=i;b'}':s++b'{':s--b',':*s=getchar()b'.':putchar(*s)b'^':u=*s?(r=0)+1:u;b'<':r=*s?(u=0)-1:r;b'v':u=*s?(r=0)-1:u;b'>':r=*s?(u=0)+1:r;b'+':++*s;b'-':--*s;b'!':x+=r;y-=u;}x+=r;y-=u;rewind(f);for(i=0;i<y;i+=w=='\n');for(i=0;i<x;++i)w;}}