Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<title>Spirograph</title>
<style type="text/css">
* {
box-sizing: border-box;
margin: 0;
padding: 0;
@zhirzh
zhirzh / mit-scheme.sublime-build
Created January 28, 2017 18:24
Sublime build system for scheme (mit-scheme). For *nix platforms.
{
"shell_cmd": "cat \"$file_name\" | mit-scheme",
"selector": "source.scm"
}
<style>
* {
font-family: monospace;
box-sizing: border-box;
margin: 0;
padding: 0;
font-size: 52px;
color: silver;
user-select: none;
void _log(int);
void log123() {
_log(123);
}
@zhirzh
zhirzh / aggregate.js
Last active September 2, 2017 15:24
google doodles
const fs = require('fs');
const path = require('path');
const rawDirPath = path.join(__dirname, 'raw');
const allDoodlesPath = path.join(__dirname, 'doodles.all.json');
const allDoodles = fs
.readdirSync(rawDirPath)
.reduce((_allDoodles, fileName) => {
const filePath = path.join(rawDirPath, fileName);
@zhirzh
zhirzh / multiple-inheritance.js
Created February 8, 2018 15:59
Multiple Inheritance in JS
function inheritsObject(baseObject, superObject) {
Object.setPrototypeOf(baseObject, superObject);
}
function inheritsMultipleObjects(baseObject, superObjects) {
inheritsObject(
baseObject,
new Proxy({}, {
get(target, key, rec) {
+type ClearAction = {type: 'CLEAR'};
+type ResetAction = {type: 'RESET', text: 'Hello World'};
+type UpdateAction = {type: 'UPDATE', text: string};
+
+type Action =
+ | ClearAction
+ | ResetAction
+ | UpdateAction;
+
const CLEAR = 'CLEAR';
@zhirzh
zhirzh / app.js
Created March 27, 2018 09:21
Negative Indexing Multi Arrays in C/++
const cppCode = document.getElementById("cpp-template").innerHTML;
document.getElementById("cpp").innerHTML = cppCode.replace(/\s{2,}/g, "");
const app = new Vue({
el: "#app",
data: {
counterMode: false,
dimensionCount: { value: 2, prevValue: 2 },
# switch to python3
which python
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python{3,}
python --version
# install python-dev
sudo apt install -y python3-dev
# install pip
@zhirzh
zhirzh / eslint.log.js
Created February 20, 2019 09:01
flip eslint logs from rules-per-file pattern to files-per-rule pattern
const fs = require('fs')
const path = require('path')
const ESLING_LOG = path.join(__dirname, 'eslint.log')
const STATE = {
EMPTY: 'EMPTY',
FILE: 'FILE',
}