Skip to content

Instantly share code, notes, and snippets.

@emmanuel
emmanuel / file.sql
Created June 2, 2011 07:54
Closure Table operations SQL fragments
-- Retrieve descendants
-- ====================
-- retrieve descendants of #4
SELECT c.*
FROM Comments AS c
JOIN TreePaths AS t ON c.comment_id = t.descendant
WHERE t.ancestor = 4;
-- Retrieve ancestors

fml

The function manipulation language

"I just implemented Conway's Game of Life in two lines of code. #fml"

pad = x flip[stitch] 0, stitch 0, flip[cat] 0, cat 0
life = pad, neighborhoods[3 3], [ravel, [sum in?: [x @ 4, + 3; 3]]]/2
@ik5
ik5 / dynamic_method.pas
Created June 18, 2012 21:17
How dynamically execute a method in Object Pascal Class
{$mode objfpc}{$M+}
program test;
type
TMyClass = class
procedure SayHi;
end;
procedure TMyClass.SayHi;
begin
@tangentstorm
tangentstorm / likstromsnat.hs
Last active October 9, 2015 02:08
a little electronics problem
{-
| a dumb little circuit simulator in haskell
| by tangentstorm, 2012/08/22
|
| This basically just calculates values using Ohm's law.
| it (probably?) only works for simple circuits where there
| is a single path from the power source to each node, and
| from each node back to the power source.
|
| many thanks to quicksilver and Axman6 on #haskell for advice
@koo5
koo5 / source.txt
Created November 22, 2012 02:59
"The Amazing Interactive Turing Machine" by "J.D. Clemens"
"The Amazing Interactive Turing Machine" by "J.D. Clemens"
Section 1 - Bibliographic Data
The story headline is "An Interactive Waste of Time".
The story genre is "Other".
The story description is "You have almost reached the end of your shift. All that remains is to clean one final room, the control room for that weird contraption being built by the scientists here. Carrying your usual equipment, you open the door and step into... The Amazing Interactive Turing Machine!"
Release along with source text and a website.
@tangentstorm
tangentstorm / FORLOOP.rx
Last active December 11, 2015 11:18
Talk about "build one to throw away"
## OBERON SYNTAX TO COMPILE:
FOR x := start TO goal BY step DO
block
END;
## StringTemplate ( generating retro code ):
for_stmt(id, beg, end, step, block) ::= <<
( FOR ) <id>
@tangentstorm
tangentstorm / objpas-lexer.txt
Created February 27, 2013 19:35
Lexer DFA for object pascal
[[a[nd
|rray
|s
|sm]
|b[egin]
|c[ase
|lass
|onst[
|ructor]]
|d[e[structor
@alexaltair
alexaltair / Today's Learning.md
Last active December 18, 2015 17:38
An exploration of infinite lists.

The first thing that really surprised me today was the flexibility of Ruby's shovel operator, <<. A student in the class had tried the following:

a = [0]
a << a

What do you think a is now? I was sure it would be [0, [0]]. But lo and behold, Ruby sparkles;

a = [0]
a &lt;&lt; a
type Message struct {
type string
midiData [3]byte
sysexData[255]byte
sysexLen int
}
func NewBoard() *Board {
b := &Board{}
// Start the message loops
@tangentstorm
tangentstorm / something4thy.js
Created August 2, 2013 04:22
something 4thy this way comes...
var b4 = (new function() { var EOF='\0',self = {
d:[], a:[], // data and auxiliary/return stack
defs:[],core:[],scope:[], // dictionary
base:10, // numbers
cp:-1, ch:'\x01',ibuf:[],wd:'', // lexer state
compiling:false,state:[],target:[], // compiler state
def : function (k,v){
var res=self.defs.length; self.defs.push(v); self.scope[0].push([k,res]); return res },