Skip to content

Instantly share code, notes, and snippets.

/**
* Basic Array class, similar to std::array.
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style License (C) 2020
*/
#ifndef __Array_h
#define __Array_h
let offset = 20000;
let chunk_size = 10000;
// File handle:
let mut handle = BufReader::new(File::open("data.bin").await?);
// Set cursor to needed chunk:
let mut chunk_stream = handle
.bytes()
.skip(offset)
@DmitrySoshnikov
DmitrySoshnikov / writing-a-mark-sweep-garbage-collector.cpp
Created March 15, 2020 08:35
Writing a Mark-Sweep Garbage Collector
/**
* Writing a Mark-Sweep Garbage Collector in C++.
*
* This is a source code for the Lecture 9 from the
* Essentials of Garbage Collectors course:
*
* http://dmitrysoshnikov.com/courses/essentials-of-garbage-collectors/
*
* See full details in:
*
@DmitrySoshnikov
DmitrySoshnikov / GIF-Screencast-OSX.md
Created January 30, 2020 07:37 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@DmitrySoshnikov
DmitrySoshnikov / sierpinski-triangle.html
Created December 2, 2019 06:04
Sierpiński triangle in JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Sierpiński triangle</title>
</head>
<body>
<canvas id="area" width="600" height="600"></canvas>
<script type="text/javascript">
// Sierpiński_triangle:
/**
* -------------------------------------------
* Thread-safe vs. Non-thread-safe. Mutex.
* -------------------------------------------
*
* Some resources (like global `cout` stream) have to be guarded
* in order to be thread-safe.
*
* The simplest way to guard is to use a mutex:
*
/**
* Filter object properties.
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style license, 2019
*/
const filterProps = (
[p1, p2, p3],
{
@DmitrySoshnikov
DmitrySoshnikov / async-iterators-example.js
Created November 14, 2018 23:35
async-iterators-example.js
/**
* Async iterators simple example.
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style License, 2018
*/
async function* streamChunks() {
yield genChunk(1);
yield genChunk(2);
/**
* Educational "Free-list" memory allocator.
*
* Maintains explicit list of free memory blocks, reuses blocks on free.
* Implements "first-fit" strategy. Uses pre-allocated heap of 64 bytes,
* with 32-bit machine word size.
*
* TODO:
*
* - Implement "best-fit" strategy
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial
; on http://skilldrick.github.io/easy6502/ that I created as an exercise for myself
; to learn a little bit about assembly. I **think** I understood everything, but I may
; also be completely wrong :-)