Skip to content

Instantly share code, notes, and snippets.

View haxscramper's full-sized avatar

haxscramper haxscramper

View GitHub Profile
@haxscramper
haxscramper / oidarray.py
Created November 7, 2023 19:52
Structured description of types declared in the oidarray.h
TU(records=[],
enums=[Enum(fields=[EnumField(name='GIT_FEATURE_THREADS', value=''),
EnumField(name='GIT_FEATURE_HTTPS', value=''),
EnumField(name='GIT_FEATURE_SSH', value=''),
EnumField(name='GIT_FEATURE_NSEC', value='')],
name='',
base=QualType(name='', spaces=[], parameters=[], is_const=False, is_ref=False, is_pointer=False, is_function_pointer=False, is_method_pointer=False, is_namespace=False, dbg_origin=''),
doc=''),
Enum(fields=[EnumField(name='GIT_OPT_GET_MWINDOW_SIZE', value=''),
EnumField(name='GIT_OPT_SET_MWINDOW_SIZE', value=''),
@haxscramper
haxscramper / generate_graph.py
Last active September 1, 2022 07:35
Nimskull roadmap planning immediate
#!/usr/bin/env python
import yaml
import textwrap
from typing import *
def indent(text, amount, ch=" "):
padding = amount * ch
return "".join(padding + line for line in text.splitlines(True))

Cleaning up existing tests

There are many ideas of what we could change or where to go next, but those are often poorly thought out. The sheer volume of what we don't know about the existing system, good or bad, is so large we're working in the dark. This is a blindspot induced by the current state of the code base.

What we do know, with great certainty, is that we need tests that not only test things but also:

  • teach the reader
  • are a useful reasoning tools
  • remember decisions of the past
  • help uncover lost ideas
  • shine a light on dark corners and issues
@haxscramper
haxscramper / nim-fusion.md
Last active February 19, 2021 15:07
nim-fusion.md

Nim fusion

Starting from this version you can run nim fusion to install or update the fusion package - an extension to the nim stdlib with some additional modules.

Currently, the following modules are present:

Base C++ class cppbase.cpp

#pragma once

#include <stdio.h>

struct CppBase {
  virtual void baseMethod(int arg) {
    printf("arg from nim - %d -\n", arg);
@haxscramper
haxscramper / matching.org
Last active February 24, 2021 06:06
Getting started with pattern matching article

Pattern matching in nim

Introduction

New pattern matcing library introduces support for two very useful concepts: pattern matching and object destructuring.

@haxscramper
haxscramper / htppserve.nim
Last active May 12, 2021 12:04
Nim emscripten hello world
import asynchttpserver, asyncdispatch, os
proc handler(req: Request) {.async.} =
echo "request for path ", req.url.path
let cwd = getCurrentDir()
let file = cwd / req.url.path
if fileExists(file):
await req.respond(Http200, file.readFile())
else:
@haxscramper
haxscramper / nim-features-you-didn-t-know-and-don-t-need-to.org
Last active December 4, 2020 22:09
Nim features you didn't know and don't need to

Nim features you didn’t know and don’t need to

Can put basically anything as identifier

Technically this is just function call using method call syntax - × is treated as regular identifier (like someFunction) and it is perfectly legal to call obj .someFunction arg. So a .× b is not really different in that regard.

proc ×(a, b: set[char]): seq[(char, char)] =
  for aIt in a:
    for bIt in b: