Skip to content

Instantly share code, notes, and snippets.

View dvschultz's full-sized avatar

Derrick Schultz (he/him) dvschultz

View GitHub Profile
@donpark
donpark / perlincanvas.js
Created February 11, 2012 04:45
Rendering Perlin Noise Fast to HTML5 Canvas
/* Following canvas-based Perlin generation code originates from
* iron_wallaby's code at: http://www.ozoneasylum.com/30982
*/
function randomNoise(canvas, x, y, width, height, alpha) {
x = x || 0;
y = y || 0;
width = width || canvas.width;
height = height || canvas.height;
alpha = alpha || 255;
var g = canvas.getContext("2d"),
import re
import json
import numpy as np
from BeautifulSoup import BeautifulStoneSoup as Stone
f = open('new-basemap-borders-01.svg')
svg = f.read()
f.close()
soup = Stone(svg)
@NickBarreto
NickBarreto / iBooks popups which degrade nicely in other devices
Last active September 3, 2024 10:37
How to create popup footnotes in iBooks which degrade well for other EPUB3 readers
The only requirements for popup footnotes in iBooks are:
* Ebook has to be an EPUB3
* epub:type "noteref" and "footnote"
So you can link to a totally separate document, as you normally would for endnotes,
but include the attributes so the <a> link behaves differently in iBooks, instead triggering the popup.
Original reference link would look something like this (in a file called ch001.html):
<a epub:type="noteref" href="footnote.html#note1">1</a></div>
@th0ma5w
th0ma5w / easing.py
Created March 31, 2014 01:32
Easing Equations in Python (orig by Robert Penner)
# ported from http://www.gizma.com/easing/
# by http://th0ma5w.github.io
#
# untested :P
import math
linearTween = lambda t, b, c, d : c*t/d + b
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active November 20, 2025 17:46
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@tonyhschu
tonyhschu / ZeroOneToString.js
Created January 29, 2016 03:05
Mapping [0,1] to a hex color.
var c = function(n) {
var string = '';
n = Math.floor(n * Math.pow(256, 3));
for (var i = 5; i >= 0; i--) {
string += (Math.floor(n / Math.pow(16, i)) % 16).toString(16);
}
return '#' + string;
}
from PIL import Image
import numpy as np
import pyprind
import random
import os
import pygame
from collections import defaultdict, Counter
class MarkovChain(object):
@genekogan
genekogan / scrapeImages.py
Created February 22, 2017 11:49
scraping full size images from Google Images
from bs4 import BeautifulSoup
import requests
import re
import urllib2
import os
import argparse
import sys
import json
# adapted from http://stackoverflow.com/questions/20716842/python-download-images-from-google-image-search
@victor-shepardson
victor-shepardson / pytorch-glumpy.md
Last active January 22, 2025 20:55
using pycuda and glumpy to draw pytorch GPU tensors to the screen without copying to host memory
@daz
daz / generate-silence.sh
Created October 23, 2017 07:25
Generate a silent AAC audio with ffmpeg
ffmpeg -f lavfi -i anullsrc=r=11025:cl=mono -t <number of seconds> -acodec aac out.m4a