Skip to content

Instantly share code, notes, and snippets.

View dekrain's full-sized avatar

Dawid Kraiński dekrain

  • Poland
View GitHub Profile
@dekrain
dekrain / attrvm.cs
Last active September 15, 2022 20:14
CLI Custom Attribute Virtual Machine: The best worst idea I had in 3 months
// Released under GNU GPLv3 license
// https://www.gnu.org/licenses/gpl-3.0.en.html
// (©) Copyright DeKrain 2022
// The example program is located near the end of this file
AttrVM.Executor.CompileAndRunMainProgram(@"MainProgram.Program");
#region VM Implementation
namespace AttrVM {
using System;
@dekrain
dekrain / counters.cpp
Created May 4, 2022 21:34
Awful little counter management program
/** %pmake **/
/* { "target": "counters", "c++ver": "c++17" } */
/*
Entry with _ means unimplemented, + means implemented.
Controls:
+ ArrowDown = next entry
+ ArrowUp = previous entry
+ ArrowRight = increase counter
@dekrain
dekrain / gorbitsa.clang.cpp
Created October 27, 2020 21:25
Gorbitsa compile-time interpreter. Based on @qookei 's version
/*
* compile with: g++ gorbitsa.cpp -o gorbitsa -ftemplate-depth=99999999 -std=c++2a
* Tested with GCC 10.1, does *not* work with Clang 10
* Editor's note: not anymore ;)
*/
#include <iostream>
#include <string_view>
#include <cctype>
#include <array>
@dekrain
dekrain / snek.js
Created September 8, 2020 20:26
Snek baest gaem!
/** Snek gaem
* To use (vscode):
* - open devtools
* - inspect a line of code in editor in devtools
* - enter command `var snek_parent_node = $0.parentElement;` This will select the correct parent/anchor
* - copy and paste this entire file into console & enter
* Controls:
* - Arrow keys - change direction
* - Escape - halt the snek
* - To exit, "Reload window" in command palette
@dekrain
dekrain / advanced fizzbuzz.cpp
Created September 2, 2020 17:32
Fizzbuzz, but _advanced_
#include <iostream>
#include <tuple>
template <size_t N>
struct FizzBase {
char const* msg;
bool fizz(int x) const {
if (x % N == 0)
return (std::cout << msg), true;
@dekrain
dekrain / find_root.py
Last active July 7, 2018 19:00
Python algorithm to find roots of complex function
# Python 3
# This algorithm tries to find a complex solution to the complex function
# Example:
# find_root((lambda n: n**2 + 1), ComplexRect(-2+2j, 2-2j))
# -> [-1j, 1j]
import math
def complex2polar(n):
@dekrain
dekrain / fourier.c
Created February 26, 2018 21:00
A try to implement Fourier Transform in C programming language
#define float_t _std__float_t
#include <stddef.h>
#include <math.h>
#include <stdio.h>
#undef float_t
#define PI trig(atan2)(0, -1)
#define trig(f) f // Uses trigonometric function for float precision of float_t
#define fm "%f" // Format for type float_t (printf)
@dekrain
dekrain / New Snap! OS changelog.md
Last active December 12, 2016 21:18
Changelog of my New Snap! OS

Prelease

0.1

16.12.10

0.1.0:

  • Basic functionality
  • Basic morphs
  • Basic FPS system
  • FPS monitor & mouse down detector

0.1.1:

@dekrain
dekrain / snap-query.js
Created November 30, 2016 19:48
Snap! query!
/** @fileoverview
* This file ISN'T part of Snap!. It's only plug-in made by ~DeKrain
*/
var exts = ['#'];
function $s(query,
wrld /* optional */
) {
var ext = query[0], world = wrld || window.world, result, allchilds;
@dekrain
dekrain / blockfactory.js
Created October 1, 2016 20:00
Snap! Block Factory!!!
// A Block Factory for Snap! by (C) ~DK
// Based on morphic.js and Snap!
// Needs: morphic.js, widgets.js, blocks.js, objects.js, gui.js
/*global Morph DialogBoxMorph BlockMorph CommandBlockMorph ReporterBlockMorph AlignmentMorph SpriteMorph ToggleButtonMorph IDE_Morph*/
var BlockFactoryMorph;
// BlockFactoryMorph inherits from DialogBoxMorph