This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float circle(vec2 point, vec2 center, float r) | |
{ | |
return distance(point, center) - r; | |
} | |
float hollowCircle(vec2 point, vec2 center, float r1, float r2) | |
{ | |
float med = (r1+r2)/2.; | |
return abs(distance(point, center) - med) - r2 + med; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original http://micmicc.hinnerup.net/2014/01/BezierDistanceGlow/BezierDistanceGlow.htm | |
#define EPSILON 0.000000001 | |
#define MAX 9999999. | |
#define PI 3.14159265358979 | |
//Find roots using Cardano's method. http://en.wikipedia.org/wiki/Cubic_function#Cardano.27s_method | |
int findRoots(float a, float b, float c, float d, out float r[3]) | |
{ | |
vec3 vS = vec3(-1.0,-1.0,-1.0); | |
if (abs(a) > EPSILON) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; imperative style | |
(define-syntax (-> x) | |
(let* ((sym (gensym)) | |
(arg (cdr (syntax-e x))) | |
(lines (map (λ (f) | |
(if (identifier? f) | |
#`(set! #,sym (#,f #,sym)) | |
#`(set! #,sym (#,@f #,sym)))) | |
(cdr arg)))) | |
#`(let ((#,sym #,(car arg))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ df -h | grep ^/ | |
/dev/disk/by-uuid/4b64ab28-407d-44ae-8524-b6ee15240f65 660G 615G 12G 99% / | |
/dev/sdb1 3.6T 3.6T 41G 99% /mnt2 | |
/dev/sdc1 3.6T 3.6T 32G 100% /mnt3 | |
/dev/sdd1 3.7T 1.6T 2.1T 44% /mnt4 | |
/dev/sdb1 3.6T 3.6T 41G 99% /home/ftp/data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// License=WTFPLv2 | |
function exportStrokes(glyph) { | |
var glArr = strokesToGlArray(glyph), | |
r = []; | |
for (var i = 0; i*4 < glArr.length; i ++) { | |
r.push('glyph[' + i + '] = vec4(' | |
+ glArr.slice(i*4,i*4+4).join(',') + ');'); | |
} | |
return r.join('\n'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const teens = @[ | |
"zero", "one", "two", "three", "four", | |
"five", "six", "seven", "eight", "nine", | |
"ten", "eleven", "twelve", "thirteen", "fourteen", | |
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen"] | |
const tens = @[ | |
"zeroty", "onety", "twenty", "thirty", "fourty", | |
"fifty", "sixty", "seventy", "eighty", "ninety"] | |
const hundred = "hundred" | |
const anudo = "and" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N_NIMCALL(NI64, gcd_92056)(NI64 ia, NI64 ib) { | |
NI64 result; | |
NI64 a; | |
NI64 b; | |
nimfr("gcd", "p005.nim") | |
{ result = 0; | |
nimln(3, "p005.nim"); | |
a = ia; | |
nimln(4, "p005.nim"); | |
b = ib; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const combine = (...arrays) | |
=> [].concat(...arrays); | |
const compact = arr | |
=> arr.filter(el => el); | |
const contains = (() => Array.prototype.includes | |
? (arr, value) => arr.includes(value) | |
: (arr, value) => arr.some(el => el === value) | |
)(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cl hmh_transpose.c /nologo /O2 && hmh_transpose.exe | |
#include <stdio.h> | |
typedef unsigned __int64 uint64; | |
#if defined(_WIN32) | |
#include <windows.h> | |
uint64 timer_frequency() | |
{ | |
uint64 freq; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// License=WTFPL2 | |
$('#content').on('dblclick', '.editable:not(.cellEditing)', function () { | |
var target = $(this), | |
input = $('<input type=text>').val(target.text()), | |
cancelBtn = $('<button>').text('Cancel'), | |
originalValue = target.text(), | |
done = false, | |
enterFn = function (e) { | |
if (done) return; | |
if (e.which == 13) { |