Skip to content

Instantly share code, notes, and snippets.

@francescoagati
francescoagati / macroreplace.hx
Last active August 29, 2015 14:22
replace ugly experiment
import haxe.macro.Context;
import haxe.macro.Expr;
using haxe.macro.ExprTools;
using haxe.macro.MacroStringTools;
using StringTools;
class Test {
static function replace(e:Expr,symbol:String) {
@francescoagati
francescoagati / main.hx
Last active August 29, 2015 14:21
async flow programming with setTimeout and requestAnimationFrame in haxe with continuation and tink_lang short lambda and inline
import js.Browser;
@:build(com.dongxiguo.continuation.Continuation.cpsByMeta(":async"))
@:tink class AsyncFlow {
static inline function sleep(n:Int,next:Void->Void) untyped setTimeout(next,n);
static inline function rq(fn:Void->Void,next:Void->Void) {
Browser.window.requestAnimationFrame(function(b) {
fn();
next();
@francescoagati
francescoagati / logo.js
Created January 9, 2015 00:06
panel-custom-logo
JSONPANEL(function() {
return {
initialize: function(element) {
var logo = veespo.get.custom().panel.logo;
html = "";
html += '<div id="logo" style="background-image: url('+logo+');position: absolute;top: 5px;margin-left: auto;width: 100%;height: 216px;z-index: -1;background-repeat: no-repeat;margin-right: auto;background-position: 50% 50%;"></div>';
@francescoagati
francescoagati / panel.js
Last active August 29, 2015 14:13
panel-embed.ly
/*
The widget use jsonp for loading the code of the panel.
The object panel consist of 2 methods:
initialize:
initialize the panel. The unique parameter is the reference to the dom elememnt of the panel. This method is used to start the parts of the panel (dependencies,render,...)
render:
called for every vote.
This method has 2 params:
element: the DOM element of the panel
response: a javascript object with the properties:
@francescoagati
francescoagati / Test.hx
Last active August 29, 2015 14:12
wrapping NodeList around abstract iterable with enum Select
using Lambda;
import js.html.*;
enum Select {
cssClass(className:String);
tag(tagName:String);
query(selector:String);
}
@:forward
@francescoagati
francescoagati / base-panel-logger.js
Last active August 29, 2015 14:07
base-panel-logger.js
/*
The widget use jsonp for loading the code of the panel.
The object panel consist of 2 methods:
initialize:
initialize the panel. The unique parameter is the reference to the dom elememnt of the panel. This method is used to start the parts of the panel (dependencies,render,...)
render:
called for every vote.
This method has 2 params:
element: the DOM element of the panel
response: a javascript object with the properties:
@francescoagati
francescoagati / index.html
Created September 29, 2014 00:58
A Pen by francesco agati.
<div id="counter1">0</div>
<div id="counter2">0</div>
<div id="counter3">0</div>
@francescoagati
francescoagati / index.html
Last active August 29, 2015 14:07
A Pen by francesco agati.
<div id="counter1"></div>
<span id="counter2"></span>
<span id="incr">[+]</span>
@francescoagati
francescoagati / script.livescript
Created September 2, 2014 23:53
A Pen by francesco agati.
lib = do
sum: ([a,b], callback) -> callback a + b
square: (a) -> a * a
stream = (worker) -> (message,...params) -> Bacon.from-promise worker[message](params)
stream-pool = (workers) ->
cnt = 0
max = workers.length - 1
@francescoagati
francescoagati / index.html
Last active August 29, 2015 14:05
subtreee element re-rendering with mercury
<div id="list"></div>