Skip to content

Instantly share code, notes, and snippets.

ZIRCON (Vird edition)

General language features

Requiring another file

use :base # .zr is assumed
use :base, :extensions, :extensions-optional # if no file is found, but folder is present, loads all .zr files from the folder
use-all # loads all .zr files in current folder
@vird
vird / gist:7653947
Created November 26, 2013 05:44
compiles into this
// Generated by IcedCoffeeScript 1.6.3-g
(function() {
var i, iced, next, opt, __iced_deferrals, __iced_k, __iced_k_noop,
_this = this;
iced = require('iced-coffee-script').iced;
__iced_k = __iced_k_noop = function() {};
opt = {
@vird
vird / gist:7653962
Created November 26, 2013 05:45
iced code
opt=
block_start : 0
block_end : 10
console.log "start"
for i in [opt.block_start .. opt.block_end]
console.log i
await setTimeout (defer next), 0
console.log "end"
@vird
vird / _notes.txt
Last active August 29, 2015 14:01
Replacement for connect static serve. More performance less features
I spent some time for building solution for me. I think it will be useful for someone.
Usage notes
Note 1. It's iced coffee script, not regular coffee script
Note 2. It need some setup
npm install connect ect connect-route iced-coffee-script mime
mkdir public
put some file in public/favicon.ico
mkdir views
put some file in views/index.ect
for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) {
if (method == "rotate") {
setproto[method] = (function (methodname) {
return function () {
var arg = arguments;
if (arg.length == 1) { // only deg is present, cx and cy are missing
var bbox = this.getBBox();
arg = [arg[0], (bbox.x+bbox.x2)/2, (bbox.y+bbox.y2)/2];
}
return this.forEach(function (el) {
// replace in .attr functions (there are two .attr functions)
for (var key in params) {
eve("raphael.attr." + key + "." + this.id, this, params[key]);
}
// with
var numericParams = {
r:1,rx:1,ry:1,x:1,y:1,cx:1,cy:1,width:1,height:1
};
for (var key in params) {
if (numericParams[key]) {
name = rgx(/[a-z]+/i).then (s)-> s.toLowerCase()
char = rgx /[^"&]/i
quoted = seq(txt('"'), rep(char), txt('"')).then (r)-> r[1].join ''
attr = seq(name, txt('='), quoted).then (r)-> name: r[0], value: r[2]
wsp = rgx /\s+/
attrs = rep(attr, wsp).then (r)->
m = {}
r.forEach(a -> (m[a.name] = a.value))
var adapter;
adapter = {};
adapter.destroy = function() {
var _i, _len, _ref, adapter;
_ref = [1, 2, 3];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
adapter = _ref[_i];
adapter = null;
@vird
vird / failed message
Created September 9, 2014 15:09
seems primus+engine.io can't utf8
4{"switch":"pongРУССКИЙ"}
@vird
vird / output_for_engine_io
Created September 10, 2014 11:10
primus+engine.io can't recive UTF-8
websocket
Connection Close Frame (Opcode 8) 2 14:10:04
Connection Close Frame (Opcode 8, mask) 0 14:10:04
4{"switch":"pong±"} 20 14:10:04
4{"switch":"crash_my_connection"} 33 14:10:04
4{"switch":"pongРУССКИЙ"} 32 14:10:02
4{"switch":"Make me can't parse"} 33 14:10:02
4{"switch":"pong"} 18 14:10:00
4{"switch":"ping"} 18 14:10:00