Skip to content

Instantly share code, notes, and snippets.

@ddlsmurf
ddlsmurf / MSC.hs
Last active May 22, 2021 11:34
MSCGen adaptation of dot plugin for gitit - http://www.mcternan.me.uk/mscgen #tool
module MSC (plugin) where
-- This plugin allows you to include a http://www.mcternan.me.uk/mscgen/ diagram
-- in a page like this:
--
-- ~~~ {.msc name="diagram1"}
-- msc {
-- # MSC for some fictional process
-- hscale = "1";
-- a,b,c;
@ddlsmurf
ddlsmurf / data.json
Last active May 22, 2021 11:33
code exercise - render tree #exercise
{"a":{"b":{"c":{"ca":{"caa":true}},"d":true},"e":{"f":true},"g":true},"h":true}
@ddlsmurf
ddlsmurf / console output
Last active May 22, 2021 11:31
Example for C users of how classes and virtual lookup tables can work. Proper memory and error management left out. #tutorial #oop
basic debug on object of type 'base', data: 0xdeadbeef
basic debug on object of type 'pointer', data: 0xdeadbeef
int debug (type 'int') value: '123'
No method 'sayHi' in 'int'
string debug (type 'string') value: 'hi guys'
Howdidledidoo 'string'
@ddlsmurf
ddlsmurf / this_in_javascript.md
Last active May 22, 2021 11:29
what's `this` in javascript #tutorial

this

Function declarations

There are two (mostly) equivalent ways to define a function:

function Add(a, b) { return a + b };

var Add = function(a, b) { return a + b };
@ddlsmurf
ddlsmurf / pretty_json.coffee
Last active May 22, 2021 11:28
This is a very hastily cobbled together JSON prettifyer that doesn't bug me about input validity as long as unambiguous. Also it warns about a few validity issues (not all). #tool
{ Transform } = require('stream')
EOL = "\n"
Utils =
spaces: (num) -> if num <= 0 then '' else (new Array(num + 1)).join(" ")
ljust: (str, len) -> str + Utils.spaces(len - str.length)
streamToString: (stream, cb) ->
len = 0
buffer = []
stream
.on('end', -> cb(null, Buffer.concat(buffer, len)))
@ddlsmurf
ddlsmurf / output.txt
Last active May 22, 2021 11:27
YAML succinct tutorial #tutorial #yaml
# Example with basic types
---
hash:
  string: some text
  number: 12345
  array_of_bool: [on, off, true, false, yes, no]
  ruby symbol: :symbol
  array:
    - item one
    - item two
@ddlsmurf
ddlsmurf / README.md
Created February 19, 2011 00:03
WIP: Illustrations of Nimrod language semantic use cases

WIP: Illustrations of Nimrod language semantic use cases

toString = Object::toString
hasOwnProperty = Object::hasOwnProperty
propertyIsEnumerable = Object::propertyIsEnumerable
### @return `undefined|null|boolean|string|symbol|number|NaN|array|arguments|date|object|function` ###
(val) ->
switch type = typeof val
when 'undefined', 'string', 'boolean', 'symbol'
return type
when 'number'
return (if Number.isNaN(val) || (val in [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY]) then 'NaN' else type)