Skip to content

Instantly share code, notes, and snippets.

import sys
import cv2
if len(sys.argv) != 3:
print("Usage: python comic_slicer.py input_file output_prefix")
sys.exit(1)
input_file = sys.argv[1]
output_prefix = sys.argv[2]
@typeswitch-dev
typeswitch-dev / daiyon.c
Last active January 2, 2026 17:03
第四 (Daiyon) — a Japanese & Forth inspired postfix language
#include <stdio.h>
#include <string.h>
#include <assert.h>
FILE *in; long M[1<<24]={0}, *D, *R, H=0x130000, IP=0, T;
long getu() { long t, h = getc(in); if (h < 0xC0) return h;
t = ((h&0x1F) << 6) | (getc(in) & 0x3F); if (h < 0xE0) return t;
t = ( t << 6) | (getc(in) & 0x3F); if (h < 0xF0) return t;
t = ( t << 6) | (getc(in) & 0x3F); return t & 0x1FFFFF; }
void putu(long c) { if (c < 0x80) { putchar(c); return; }
if (c < 0x7FF) { putchar(0xC0|(c>>6)); } else {
@dondragmer
dondragmer / CuteSort.hlsl
Created December 5, 2020 00:11
A very fast GPU sort for sorting values within a wavefront
Buffer<uint> Input;
RWBuffer<uint> Output;
//returns the index that this value should be moved to to sort the array
uint CuteSort(uint value, uint laneIndex)
{
uint smallerValuesMask = 0;
uint equalValuesMask = ~0;
//don't need to test every bit if your value is constrained to a smaller range
@chriskillpack
chriskillpack / gauss_seidel.go
Last active October 1, 2020 07:33
Solve a 2D Poisson equation problem using Gauss-Seidel
// Solve the Poisson equation for a 2D grid using the Gauss-Seidel method
// Gauss-Seidel method: https://en.wikipedia.org/wiki/Gauss–Seidel_method
// The problem used is Example 1 from https://my.ece.utah.edu/~ece6340/LECTURES/Feb1/Nagel%202012%20-%20Solving%20the%20Generalized%20Poisson%20Equation%20using%20FDM.pdf
// A 4x4 grid of electrical values
// - top boundary is Dirichlet boundary fixed at 1.0V
// - bottom boundary is Dirichlet boundary fixed at 0.0V
// - left & right boundaries are Neumann boundaries fixed at derivative 0.0V
package main
@JKrehl
JKrehl / circshift.jl
Last active March 3, 2017 23:11
an in-place circshift! implementation
using Base.Cartesian
function _bifurcated_loop(i, ex, reverse, splits=:splits, half=reverse)
if i == 0
ex
else
ix = Symbol("x_", i)
iy = Symbol("y_", i)
isize = :(size(dest, $i))
@nepsilon
nepsilon / auto-backup-your-configuration-files-with-vim.md
Last active October 22, 2024 22:10
Auto-backup your configuration files with Vim — First published in fullweb.io issue #71

Auto-backup your configuration files with Vim

Not using versioning on your configuration files and editing them with Vim?

Use Vim’s backup option to automatically keep a copy of past versions. To put in your ~/.vimrc:

"Turn on backup option
set backup
@mcnees
mcnees / graph paper.tex
Last active March 9, 2026 04:41
Make your own quadrille, graph, hex, etc paper! Uses the pgf/TikZ package for LaTeX, which should be part of any modern TeX installation.
%%-----------------------------------------------------------------------
%% Make your own quadrille, graph, hex, etc paper!
%% Uses the pgf/TikZ package for LaTeX, which should be part of
%% any modern TeX installation.
%% Email: mcnees@gmail.com
%% Twitter: @mcnees
%%-----------------------------------------------------------------------
\documentclass[11pt]{article}
@piotr-j
piotr-j / perlin.py
Created June 6, 2016 19:00 — forked from eevee/perlin.py
Perlin noise in Python
"""Perlin noise implementation."""
# Licensed under ISC
from itertools import product
import math
import random
def smoothstep(t):
"""Smooth curve with a zero derivative at 0 and 1, making it useful for
interpolating.
@max-mapper
max-mapper / 0.md
Last active May 12, 2025 13:51
JS hoisting by example

JavaScript function hoisting by example

Below are many examples of function hoisting behavior in JavaScript. Ones marked as works successfuly print 'hi!' without errors.

To play around with these examples (recommended) clone them with git and execute them with e.g. node a.js

Notes on hoisting

(I may be using incorrect terms below, please forgive me)

@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active February 14, 2026 13:18
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version