Skip to content

Instantly share code, notes, and snippets.

Avatar

Spongman Spongman

View GitHub Profile
View wsl1-reset.ps1
# 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"
@Spongman
Spongman / clearcrl.bat
Created Jun 22, 2019
clear local IIS Certificate Revocation List
View clearcrl.bat
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\*
View OpenSimplexNoise.js
"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;
View nature-of-code.txt
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:
View findRoots.js
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;
View index.html
<!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;
@Spongman
Spongman / Utils.cs
Last active Jun 6, 2017
HackerRank utils
View Utils.cs
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);
View foo.html
<select multiple="multiple">
<option value="a" selected="selected">One</option>
<option value="b" selected="selected">Two</option>
</select>
@Spongman
Spongman / sine.c
Created Apr 12, 2017
intesine generation without FPU or lookup tables
View sine.c
#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;