Skip to content

Instantly share code, notes, and snippets.

@root42
root42 / firework.bas
Created December 30, 2020 21:33
Let's Code MS-DOS 0x19: Fireworks in PowerBasic
$CPU 80286
$LIB EGA ON
$ERROR ALL OFF
$OPTIMIZE SPEED
$COMPILE EXE
defint A-Z
REM =================
REM Global variables
@root42
root42 / viospa.asm
Created November 11, 2021 11:07
Detect video card in MS DOS
;*********************************************************************;
;* V I O S P A *;
;*-------------------------------------------------------------------*;
;* Task : Creates a function for determining the type *;
;* of video card installed on a system. This *;
;* routine must be assembled into an OBJ file, *;
;* then linked to a Turbo Pascal program. *;
;*-------------------------------------------------------------------*;
;* Author : Michael Tischer *;
;* Developed on : 10/02/88 *;
@root42
root42 / KOCH.BAS
Last active November 19, 2022 17:15
Let's Code MS DOS 0x1E: Power BASIC Snowflake
DIM angle AS SHARED DOUBLE
DIM COL AS SHARED INTEGER
DIM SCALE AS SHARED DOUBLE
'-------------------------------------------------------------------
' Make a turn in the curve, given in degrees
'-------------------------------------------------------------------
SUB turn (degrees AS DOUBLE)
angle = angle + degrees*3.14159265/180
END SUB
@root42
root42 / glob_exec.py
Last active May 17, 2023 09:53
Python exec with file globbing
#!/usr/bin/env python
#
# Executes the given command line by applying file globbing to all
# arguments but the first one. Example:
#
# ./glob_exec.py ls '*.py'
#
# This is useful for shells like Windows cmd which doesn't have native
# file globbing.
#
@root42
root42 / last_index_of.hh
Last active August 25, 2023 14:26
C++ string last_index_of similar to Java lastIndexOf
template<typename T>
typename T::size_type
last_index_of(const T &s, const T &q)
{
typename T::size_type
pos = std::string::npos,
res = std::string::npos;
while( (pos = s.find(q, (pos == std::string::npos ? 0 : pos + q.size()))) != T::npos) {
res = pos;
}