Skip to content

Instantly share code, notes, and snippets.

View tinyraytracer.js
var m=600,w=[m,[0,-m,0],9,9,0,m,2,1,[0,0,3],9,0,0,m,3,1,[-2,1,4],0,9,0,9,4,1,[2,1,4],0,0,9,m,5],A=2,B=[8,[2,2,0]],D=Math,E=D.sqrt,F=D.max,G=0,H=document.getElementById("c"),I=H.getContext("2d"),J=I.getImageData(0,0,m,m),;H.width=H.height=m;function O(p,g){return p[0]*g[0]+p[1]*g[1]+p[2]*g[2]}function P(p,g,z){return[p[0]-g[0]*z,p[1]-g[1]*z,p[2]-g[2]*z]}function Q(p,g,z,C){t=m;for(v=q=0;r=w[q++];q+=6)if(j=P(p,w[q],1),a=2*O(g,g),b=-2*O(j,g),d=E(b*b-2*a*(O(j,j)-r*r)))for(e=2;e--;d=-d)f=(b-d)/a,z<f&&f<C&&f<t&&(v=q,t=f);return v}function R(p,g,z,C){if(!(s=Q(p,g,z,m)))return 0;N=P(X=P(p,g,-t),w[s],1);n=O(N,N);i=A;for(l=0;u=B[l++];)k=O(N,L=P(B[l++],X,1)),i+=u*!Q(X,L,1/m,1)*(F(0,k/E(O(L,L)*n))+F(0,D.pow(O(M=P(L,N,2*k/n),g)/E(O(M,M)*O(g,g)),w[s+4])));p=w[s+c]*i*2.8;z=w[s+5]/9;return C--?R(X,P(g,N,2*O(N,g)/n),1/m,C)*z+p*(1-z):p}for(y=h=m/2;y-- >-h;)for(x=-h;x++<h;){for(c=0;4>++c;)K[G++]=R([0,1,0],[x/m,y/m,1],1,2);K[G++]=255}I.putImageData(J,0,0);
smcl / gist:ebce87271f9d6fb9b74735a2e11ff050
Last active Mar 10, 2020
Transcript of Biden's gun debate with an Trump supporter about gun control
View gist:ebce87271f9d6fb9b74735a2e11ff050
Biden: You're full of shit. Now there is ... shush! I support the second amendment. The second amendment is like right now if you yell "Fire!" that's not free speech. From the very beginning I had a shotgun, I have a 20 gauge, a 12 gauge, my sons hunt, guess what ... you're not allowed to own any weapons. I'm not taking your gun away. At all. You need a hundred rounds you ...
Guy: You really did though, when you said you'd take our guns away
Biden: I did not say that. That's not t... I did not say that
Guy: It was a viral video!
smcl / Bernie vs Pete
Last active Feb 26, 2020
Transcript of Pete trying to talk over Bernie
View Bernie vs Pete
Let us be clear. Do we think heathcare for all, Pete, is some kind of radical, communist idea? Do we think raising the minimum wage to a living wage [is]? Do we think building the millions of units of affordable housing that we need [is]? Do we think raising taxes on billionaires is a radical idea? Do we think criminal justice reform is a radical idea? Do we think immigration reform ... the truth is, Pete, that the American people support my agenda. That is why I am beating Trump in virtually every poll that is done. And that is why I will defeat him
I'm glad you brought this up. Let's talk about this. I'm happy to respond to the question because this is really important. This is really important. If you're gonna ask that rhetorical question, let's go behind the [inaudible] for example. Let's talk about this. Let's talk about what's radical about that plan. Senator, please. Senator. The things you just named are things we favour
smcl / .Xresources
Created Aug 12, 2019
.Xresources with xterm using solarized (from and nicely sized mononoki font
View .Xresources
XTerm*faceName: mononoki
xterm*faceSize: 12
xterm*termName: xterm-color
xterm*eightBitInput: false
*.vt100.metaSendsEscape: true
! special
xterm*foreground: #586e75
smcl / shoppinglist.txt
Created Jun 27, 2019
shopping stuff for chata
View shoppinglist.txt
- Pom beeears + chipsy
- something to have with coffe?
Lunch Saturday (carbonara)
- Slanina (a big chunky piece of it)
- Pasta (we have, I think)
Dinner Saturday (pork + pepper/cucumber salad)
- Veprova kotleta x (a few, a couple each?)
smcl / rev.j
Last active Mar 27, 2018
Reversing a string or array in J
View rev.j
NB. first attempt, took me a whole hour
sub1 =: 1 & (-~)
subtractindices =: ((# sub1) @: #)
forwardindices =: i. @: #
revindices =: (subindices - forwardindices)
revarray =: (({~) revindices)
NB. alternative implementation, I realised you could give a -ve number to "i."
revindices2 =: (i. @: - @: #)
revarray2 =: ({~) revindices2
import sys
upto = int(sys.argv[1])
stringsForModulus = {
3: "fizz",
5: "buzz",
7: "bazz"
smcl / dobryden.ino
Created May 23, 2017
quick demo of iso 8859-2 chars on arduino/ssd1306 using adafruit graphics library
View dobryden.ino
#include <stdint.h>
#include <gfxfont.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
char msg[32] = { // can't be bothered counting
0x44, 0x6f, 0x62, 0x72, 0xfd, 0x20, 0x64, 0x65, 0x6e, 0x2c, 0x20, 0x6a, 0x61, 0x6b, 0x20, 0x73, 0x65, 0x20, 0x6d, 0xe1, 0xb9, 0x3f,
View glcdfont.c
// Slightly updated 5x7 font for ISO8859-2
#ifndef FONT5X7_H
#define FONT5X7_H
#ifdef __AVR__
#include <avr/io.h>
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
smcl / euler.fsx
Created Apr 26, 2017
some useful Project Euler functions
View euler.fsx
let pair_multiply s1 s2 =
[ for x in s1 do
for y in s2 do
yield (x,y) ]
let enumerate (a:'a[]) =
Array.mapi (fun i x -> (i,x)) a
let pandigital (n:int) =
let a = string(n).ToCharArray()
You can’t perform that action at this time.