Skip to content

Instantly share code, notes, and snippets.

View porfirioribeiro's full-sized avatar

Porfirio porfirioribeiro

View GitHub Profile
@porfirioribeiro
porfirioribeiro / Main.hx
Created June 10, 2013 19:12
Haxe TypeCheck in JavaScript with macros
package ;
using TypeCheck;
/**
* @author Porfirio
*/
class Main {
public function new() {}
static function main() {
var m = new Main();
@porfirioribeiro
porfirioribeiro / Generate.hx
Last active August 29, 2015 14:04
Advanced Custom JS generator.
package ;
import haxe.macro.Compiler;
import haxe.macro.Context;
import haxe.macro.Type;
import haxe.macro.Expr;
import haxe.macro.JSGenApi;
using haxe.macro.Tools;
using Lambda;
using StringTools;
@porfirioribeiro
porfirioribeiro / .block
Created September 16, 2017 14:03
fresh block
license: mit
@porfirioribeiro
porfirioribeiro / Composition.md
Created January 6, 2020 23:04
Preact Composition API

Preact Composition API

  • Toughts and doubts
  • Reactivity
  • Current implementation
  • Component based implementation

Toughts and doubts

  • displayName
@porfirioribeiro
porfirioribeiro / index.d.ts
Last active January 24, 2020 20:46
preact-composition
import { PreactContext, JSX, Component } from 'preact';
export * from './store';
type FC<P> = (props: P) => JSX.Element;
type createComponentFN<P> = (c: Component<P>) => FC<P>;
/**
* Wraps a FunctionalComponent to be handled with the composition api
* @param fn
*/
const skywatchRE = /SKYWATCH_(PL_PS|S2_MS)_(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})/;
const entries = [];
for await (const dirEntry of Deno.readDir(".")) {
const match = dirEntry.name.match(skywatchRE);
if (match) {
const sat = match[1];
const date = `${match[2]}-${match[3]}-${match[4]}T${match[5]}-${match[6]}`;
const renamed = `${date}_SKYWATCH_${sat}.tif`;
function getOrSet<K, V>(map: Map<K, V>, key: K, defaultValue: () => V): V {
const value = map.get(key);
if (value == null) {
const answer = defaultValue();
map.set(key, answer);
return answer;
} else {
return value;
}
}