Skip to content

Instantly share code, notes, and snippets.

@tangentstorm
tangentstorm / likstromsnat.hs
Last active Oct 9, 2015
a little electronics problem
View likstromsnat.hs
{-
| 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
@tangentstorm
tangentstorm / gist:3814556
Created Oct 1, 2012
python generator example
View gist:3814556
"""
This program generates the following table:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
@tangentstorm
tangentstorm / gist:3814598
Created Oct 1, 2012
when generators share their state
View gist:3814598
"""
This program generates the following table:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
It shows what happens when two generators share the same state.
Contrast with: https://gist.github.com/3814556
"""
@tangentstorm
tangentstorm / gist:4045219
Created Nov 9, 2012
imap regexp example for timg
View gist:4045219
>>> import re
>>> data = ['2 (X-GM-THRID 1391221299548167514 X-GM-MSGID 1391221299548167514 UID 6)']
>>> re.search('X-GM-THRID (?P<X_GM_THRID>\d+) X-GM-MSGID (?P<X_GM_MSGID>\d+)', data[0]).groupdict()
{'X_GM_THRID': '1391221299548167514', 'X_GM_MSGID': '1391221299548167514'}
@tangentstorm
tangentstorm / refs.pas
Created Nov 15, 2012
freepascal reference testing experiment
View refs.pas
{ freepascal reference experiment
--------------------------------------------------------
Kaco_ / Phavel suggested the following problem
in #fpc on 11/15/2012:
layout2:tgui_layout;
layou1:=tgui_layout.init (..);
layout2:=layout1;
@tangentstorm
tangentstorm / caseclass.pas
Created Nov 22, 2012
structured unions with RECORD ... CASE in free pascal
View caseclass.pas
{$mode objfpc}
unit caseclass;
interface uses classes;
type
kinds = ( kINT, kSYM, kSTR, kREF, kNUL, kOBJ );
RNode = record case kind : kinds of // valid pascal code
kINT : ( int : integer );
View gist:4224192
michal@proton:~/ver/fpc/compiler$ make clean cycle
/bin/sh: Syntax error: "(" unexpected
/bin/rm -f ppcross ppc ppc1.exe ppc2.exe ppc3.exe ./msg2inc.exe pp1.wpo pp2.wpo
/bin/rm -f ppc386.exe ppc68k.exe ppcx64.exe ppcppc.exe ppcsparc.exe ppcppc64.exe ppcarm.exe ppcmips.exe ppcmipsel.exe ppcjvm.exe ppc.exe ppcwpo1.exe ppcwpo2.exe
/bin/rm -rf units
/bin/rm -f *.o *.ppu *.rst *.s *.a *.so *.ppl
/bin/rm -rf *.sl
/bin/rm -f fpcmade.* Package.fpc ppas.sh script.res link.res
/bin/rm -f *_ppas.bat
make tempclean ppc3.exe
View gist:4224472
$ cat system.pas
unit system;
interface
procedure test;
implementation
procedure test;
var t: longint;
begin
begin t:=1; end;
View compiled code running in retro
Retro 11.5
ok ( ---------------------------------- )
ok ( runtime library )
ok ( ---------------------------------- )
ok : odd? mod 2 1 = ;
ok ( ---------------------------------- )
ok ( generated code )
ok ( ---------------------------------- )
ok variables| i |
@tangentstorm
tangentstorm / gist:4250692
Created Dec 10, 2012
floating point exception in retro.c
View gist:4250692
michal@proton:~/vrx$ ./retro --with recurse.rx
Retro 11.5
ok ( ---------------------------------- )
ok ( runtime library )
ok ( ---------------------------------- )
ok : odd? mod 2 1 = ;
ok ( ---------------------------------- )
ok ( generated code )
ok ( ---------------------------------- )
You can’t perform that action at this time.