Skip to content

Instantly share code, notes, and snippets.

@spiiin
spiiin / gist:961974938919cc9233bacf0bb5c71cd1
Created January 14, 2023 20:35
dascript_rtti_annotation_example.das
options rtti=true
require rtti
require strings
require daslib/strings_boost
class V2
x : float
y : float
class V3: V2
@spiiin
spiiin / bf_macro
Last active November 11, 2022 05:23
module brainfuck_macro shared public
require ast
require strings public
require fio public
require daslib/defer
require daslib/ast_boost
require daslib/templates_boost
require daslib/strings_boost
require daslib/apply
@spiiin
spiiin / bf.das
Last active November 9, 2022 16:53
//options log_nodes=true
require strings
require fio
//require brainfuck_mandelbrot
[sideeffects]
def read_char_from_input()
var s = ""
while length(s) <= 0
require daslib/coroutines
require daslib/jobque_boost
require fio
typedef
ValueOrReady = variant<value:int; ready:bool>
struct Answer
value:int
def work_in_thread(var channel: Channel?)
module macro_test
require ast
require daslib/ast_boost
require daslib/templates
require daslib/templates_boost
require daslib/functional
// reduce value, any invokable
def private reduce_while_any(it:iterator<auto(TT)>;functor; condition)
require daslib/apply
require daslib/algorithm
typedef Field = int4[4]
typedef FieldPathInfo = tuple<field:Field; fieldFrom:Field; rate:int>
//4
var source = [[Field int4(1,2,2,1); int4(3,4,4,3); int4(3,4,4,3); int4(2,4,4,2) ]]
var target = [[Field int4(4,3,4,2); int4(3,1,2,4); int4(4,2,4,3); int4(2,4,3,1) ]]
@spiiin
spiiin / james_bond_jr_dascript.das
Last active June 24, 2022 15:59
james bond jr problem
require daslib/apply
require daslib/algorithm
typedef FieldPathInfo = tuple<field:int[16]; fieldFrom:int[16]; rate:int>
//4
var source=[[int[16] 1;2;2;1; 3;4;4;3; 3;4;4;3; 2;4;4;2]]
var target=[[int[16] 4;3;4;2; 3;1;2;4; 4;2;4;3; 2;4;3;1]]
var zeros = [[int[16] 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0]]
@spiiin
spiiin / eng_to_rus.txt
Created September 21, 2021 23:53
lovell eng-to-rus
существительные
absence - отсутствие, недостаток
abundance - избыток, изобилие
acclaim - приветствие, одобрение, признание
accord - соглашение, договор, собственное желание
accusation - обвинение
acquaintance - знакомство, знакомый
acquisition - получение, сбор
admission - допуск, признание, принятие, допущение
adoration - обожание
@spiiin
spiiin / parse_clang_dump-record-layouts.py
Created June 9, 2021 20:21
Parse Clang dump-record-layouts output
import os
import tkinter as tk
from tkinter import ttk
import itertools
root=tk.Tk()
frame = tk.Frame(root)
tree=ttk.Treeview(frame, show='tree')
ybar=tk.Scrollbar(frame, orient=tk.VERTICAL, command=tree.yview)
tree.configure(yscroll=ybar.set)
@spiiin
spiiin / dwex_get_class_padding.py
Created June 9, 2021 19:35
dwex_get_class_padding
def calc_padding(size, roundFactor):
return ((size - 1) // roundFactor + 1) * roundFactor
#for 64-bits archs
def calc_padding_8(size):
return calc_padding(size, 8)
def print_class_padding(class_die):
virtual_ancestors = OrderedDict()
virtual_ancestors_proccessed = set()
class_size_without_padding = 0 # sum of member sizes