Skip to content

Instantly share code, notes, and snippets.

@Spongman
Spongman / sine.c
Created April 12, 2017 06:32
intesine generation without FPU or lookup tables
#define BITS = 15
#define PERIOD 100
int main(void) {
//double dt = PI * 2 / PERIOD;
//const int32_t ds = (int) (sin(dt) * ((1<<BITS) - 1));
//const int32_t c2 = (int) (cos(dt) * 2.0 * ((1<<BITS) - 1));
const int32_t ds = 2057;
const int32_t c2 = 65404;
<select multiple="multiple">
<option value="a" selected="selected">One</option>
<option value="b" selected="selected">Two</option>
</select>
@Spongman
Spongman / Utils.cs
Last active June 6, 2017 06:25
HackerRank utils
using System.Linq;
public static class U {
public static string Join<T>(this IEnumerable<T> rg, string sep = " ") => string.Join(sep, rg.Select(o => o.ToString()));
public static int ReadInt() => int.Parse(Console.ReadLine());
public static IEnumerable<int> ParseInts() => Console.ReadLine().Split(' ').Select(int.Parse);
public static int[] ReadInts() => ParseInts().ToArray();
public static IEnumerable<long> ParseLongs() => Console.ReadLine().Split(' ').Select(long.Parse);
public static long[] ReadLongs() => ParseLongs().ToArray();
public static IEnumerable<T> Order<T>(this IEnumerable<T> @this) where T : IComparable<T> => @this.OrderBy((T t) => t);
public static IEnumerable<T> OrderDescending<T>(this IEnumerable<T> @this) where T : IComparable<T> => @this.OrderByDescending((T t) => t);
<!DOCTYPE html>
<html>
<body>
<canvas id="canvas" width="1080" height="1080"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');
gl.viewportWidth = canvas.width;
gl.viewportHeight = canvas.height;
window.fr = function(o) {
var m = new Map();
var rg = [{ pn: 'window', v: window, l: 0 }];
function add(pc) {
var p = pc.v;
var l = pc.l + 1;
for (var pn of Object.getOwnPropertyNames(p)) {
try {
var pd = Object.getOwnPropertyDescriptor(p, pn);
//if (pd.get) continue;
@Spongman
Spongman / nature-of-code.txt
Last active October 12, 2018 19:02
nature-of-code
Welcome
Hello! By browsing the table of contents on your left, you can read the entire text of this book online for free, licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
Start reading the introduction now!
If you like this book, please consider supporting it via the links below:
@Spongman
Spongman / OpenSimplexNoise.js
Last active May 23, 2022 09:35
OpenSimplex Noise Refactored for javascript (from https://gist.github.com/digitalshadow/134a3a02b67cecd72181)
"use strict";
const STRETCH_2D = (1 / Math.sqrt(2 + 1) - 1) / 2;
const STRETCH_3D = (1 / Math.sqrt(3 + 1) - 1) / 3;
const STRETCH_4D = (1 / Math.sqrt(4 + 1) - 1) / 4;
const SQUISH_2D = (Math.sqrt(2 + 1) - 1) / 2;
const SQUISH_3D = (Math.sqrt(3 + 1) - 1) / 3;
const SQUISH_4D = (Math.sqrt(4 + 1) - 1) / 4;
const NORM_2D = 1 / 47;
const NORM_3D = 1 / 103;
@Spongman
Spongman / clearcrl.bat
Created June 22, 2019 00:28
clear local IIS Certificate Revocation List
iisreset /stop /timeout:0
net stop w3svc /y
net stop http /y
net stop CertPropSvc /y
certutil -setreg chain\ChainCacheResyncFiletime @now
certutil -urlcache * delete
del /q /f /s /a:h C:\Windows\System32\config\systemprofile\AppData\LocalLow\Microsoft\CryptnetUrlCache\*
@Spongman
Spongman / wsl1-reset.ps1
Created February 11, 2021 02:18
reset WSL2 NIC
# the NAME of the WSL distro: `wsl.exe -l -v`
$distro = "centos7"
# the NAME of the Windows Network Interface: `powershell.exe Get-NetAdapter`
$iface = "LAN"
# static IP address for wsl interface
$address = "192.168.1.3/24"
$gateway = "192.168.1.1"
/// This is an automatic generated amalgamation of:
/// continuable version 4.0.0 (735697026b72a8f415d3443834cceeda9623780d)
/*
/~` _ _ _|_. _ _ |_ | _
\_,(_)| | | || ||_|(_||_)|(/_
https://github.com/Naios/continuable
v4.2.0