Skip to content

Instantly share code, notes, and snippets.

View haxscramper's full-sized avatar

haxscramper haxscramper

View GitHub Profile
@haxscramper
haxscramper / languages-and-vms.md
Last active March 16, 2024 19:45
languages-and-vms
@haxscramper
haxscramper / register.nim
Last active October 18, 2020 18:22
Nim custom compiler pass
import std/[os, strformat]
import Nim / compiler /
[ idents, options, modulegraphs, passes, lineinfos, sem, pathutils, ast,
astalgo, modules, condsyms, passaux
]
let file = "/tmp/ee.nim"
file.writeFile("""
proc test*(arg: int) = echo arg
@haxscramper
haxscramper / nimble-rebuild.fish
Created August 28, 2020 08:33
Automatically rebuild nimble tests when file changes
#!/usr/bin/env fish
function find-match-in-parent-dir -a "find_match"
set -l path "$PWD"
while [ '/' != "$path" ]
find "$path" -maxdepth 1 -mindepth 1 -name "$find_match"
set path (readlink -f "$path/..")
end
end
@haxscramper
haxscramper / identifier_stats.nim
Created August 6, 2020 14:13
Get stats for used identifier styles in nim source code
import times, stats, strformat, os, strutils
import compiler/[parser, llstream, idents, options, pathutils, astalgo, ast]
var pars: TParser
let cache: IdentCache = newIdentCache()
let config: ConfigRef = newConfigRef()
proc parsefile(file: string): PNode =
openParser(
@haxscramper
haxscramper / compiler_parser.nim
Created August 2, 2020 13:01
Parse nim code at runtime
import times, stats
import compiler/[parser, llstream, idents, options, pathutils, astalgo]
var pars: TParser
let cache: IdentCache = newIdentCache()
let config: ConfigRef = newConfigRef()
var parseTime: RunningStat
@haxscramper
haxscramper / qucsdigi.sh
Created March 26, 2020 14:54
Use `ghdl` instead of `freehdl` in the qucs digital simulation
#! /bin/sh
#
# qucsdigi - wrapper script for digital simulation
#
# Copyright (C) 2005 Michael Margraf <michael.margraf@alumni.tu-berlin.de>
# Copyright (C) 2005, 2006, 2008, 2009 Stefan Jahn <stefan@lkcc.org>
# Copyright (C) 2005 Raimund Jacob <raimi@lkcc.org>
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@haxscramper
haxscramper / ast_to_dot.nim
Last active August 14, 2019 12:56
Generate graphivs graph of nim ast
import macros, tables, strformat, strutils, sequtils
import strutils
proc truncate(value: string, length = 9, ellipsis = "..."): string =
if value.len > length:
value[0..length - 1] & ellipsis
else:
value
@haxscramper
haxscramper / create_usb_gadget.sh
Created May 4, 2019 10:45
Log files for stack exchange question
err_file=$HOME/usb_setup_err
echo "Time: $(date -Ins)" >> $err_file
echo 'Running setup script' >> $err_file
{
##= Create usb gadget
cd /sys/kernel/config/usb_gadget/
mkdir -p hax_usb
@haxscramper
haxscramper / init.vim
Created February 2, 2019 13:04
My vim config
set autowrite
set ignorecase
set incsearch
set mouse=a
set nocompatible
set number
set showcmd
set showmatch
set showmode
set smartcase
@haxscramper
haxscramper / linux_setup.md
Last active February 2, 2019 15:19
How to build qt + graphicsmagick + boost on windows/linux
  • Install qt

To build on debian you need to execute

sudo apt-get install qt5-default git curl make g++ libboost-dev libgraphicsmagick-dev graphicsmagick-libmagick-dev-compat
qmake with-magick.pro
make