Skip to content

Instantly share code, notes, and snippets.

@m1el
m1el / circle.glsl
Last active August 29, 2015 14:17
playing with sdf
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;
}
// 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)
; 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)))
$ 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
// 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');
}
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"
@m1el
m1el / p005.c
Last active August 29, 2015 14:20
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;
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)
)();
// 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;
@m1el
m1el / celledit.js
Last active August 29, 2015 14:23
cell editing example with jQuery
// 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) {