Skip to content

Instantly share code, notes, and snippets.

@maxtaco
maxtaco / postal.iced
Created July 20, 2014 01:26
Adapter to use jQuery's ajax with IcedCoffeeScript
#-----------------------------------
# Like postal, but returns like request() on node.
$.postal = ({ url, params, dataType, ok_http_status_codes, ok_json_status_codes, ok_empty_body}, cb) ->
headers = {}
if (t = window.csrf_token)? and t.length
headers["X-CSRF-Token"] = t
ok_http_status_codes or= [ 200 ]
ok_json_status_codes or= [ 'OK' ]
@maxtaco
maxtaco / p3skb.iced
Created August 5, 2014 12:43
How to decode and decrypt P3SKB format into Standard PGP blocks
{unpack,pack} = require 'purepack'
{createHash} = require 'crypto'
{decrypt} = require 'triplesec'
assert = require 'assert'
{encode} = require('pgp-utils').armor
key = """hKRib2R5gqRwcml2gqRkYXRhxRgEHJTX3gAAAAOsc5gaUOoq7pdC2Co5YVQXH49bzq2YEAxmjlmGDysfrRbToJD41vpfCsWh1MC0fxV/+LopyzZqssbCuCiDOG5ZZqCHxqYZdTRZFD0WW1CQAOeiu8W7AOKSnaTaPKtrCxw01wpQqO0BXuFK+D91taE4voFQOdlQeynLut1YZvgYsW6DXln5zDECrxy2MZNYP8CqaTRVfr1WTXeloBsF+8sMx/6soVfmTSa+R66c/CZO0tLB5vfGTlfI5wWM+18umjp+0CNXVvTPOCcCmqVinoKGZoi/VqWgokK4Ku4WRRbfwlQVUi5CZFa/FEqJd2AWiUYWdP+X1In6uNG70jSO+PXaYBYBlEMuEbS8cq/3CWe4T/wP3ktYE8aZg1VKO6+jUbrAehK+EBzKe8OMFu+JOhN0XYepO9BzAs1DmHb7/23mzf/sgDyqRQQXOUcIFA3STULaJnXyHSamOh21hBTOVfBU/vSSCIjX8WIKxWBuRPEgMZ7X4INH3LF79RiTaxTHdorIxuc9g2bklSvF4pbiva2NqbPPtUwWKMbjff+Vp3fKCFxGhUqqXXjy2aippsvDn43+WJ93rsgE1DpLGc0tghZejmwUFopyJ1n23JIKqKArjSpOAJBM5wv1u0qV94uBNPP1pHGEvdukz3NNL11rwHRyoHY7ShdF//uwjI0Xqo7u2FvMatXUNWgcx2URWQpft6PfbGLvyjXdO893dhWn5Ig7Ee3Dg2wvSHfHWXU6V0BdrFv0rMZva9b4ecZsNd+61QHGkCw8Ga6yG0wqp+9Qe/zDlUQkV+/gKocoU6VEoUL9xw8
@maxtaco
maxtaco / ICS_in_ES6.md
Last active November 16, 2016 00:32
IcedCoffeeScript ES6 Implementation

ES6 IcedCoffeeScript Implementation

It's been a real challenge to continuously merge my IcedCoffeeScript branch with the CoffeeScript mainline. The more progress Jeremy and the team make in master, the harder a time I have in the branch. The core issue here is the the iced transform is quite deep. It's doing a CPS translation of the entire abstract syntax tree, rendering the emitted code all but unrecognizable if iced features are at play.

Whenever ES6 is ready for primetime, yield and generators can do all of this heavy lifting, meaning the ICS patch can much simpler. Here's an example that I hand-coded. The input is the first file input.iced, which does basic ICS loops and if/else control flow exercises. The hypothetical output

@maxtaco
maxtaco / kbRPC.coffee
Last active September 4, 2015 00:55
KB wrapper w/ session awareness on top of regular RPC
##
## Extremely rough & hacky pseudocode, but I guarantee we can get something
## like this to work. I believe this is the interface you wanted, but
## we can easily implement it on top of the interface we have.
##
class KbClient extends Client
# construct with a KbTransport below....
@maxtaco
maxtaco / p3skb.iced
Last active September 8, 2015 01:46
Some worked p3skb examples
{KeyManager} = require 'kbpgp'
{make_esc} = require 'iced-error'
passphrase = "foxtrot bananas"
main = (cb) ->
esc = make_esc cb
# generate, sign and lock...
@maxtaco
maxtaco / foo.avdl
Last active October 7, 2015 00:54
New RPC/Go interface idea.
@namespace("foo.1")
protocol bar {
A myfunc(b B, c C);
}
type Wrapper struct {
fd int
}
func open(s string) *Wrapper {
return &Wrapper{ openPipe(s); }
}
func (w *Wrapper) Close() {
Close(w.fd)
@namespace("foo.1")
protocol bar {
enum BoopType {
NONE_0,
BURN_1,
BILLY_2,
TILLY_3
}
@namespace("shit.1")
protocol bar {
enum Types {
NONE_0,
BOZO_1,
BIPPY_2,
AGGLE_3,
FLAGGLE_4
@maxtaco
maxtaco / input.avdl
Last active May 25, 2017 03:45
A blurpy demo
record Cat {
map<Blurp,Noozle> bird;
map<Noozle> bee;
map<Blurp,array<Noozle>> birds;
map<Blurp,int> pickles;
map<string,int> penny;
map<int,string> pa;
array<map<Blurp,array<Noozle>>> wow;
}