Skip to content

Instantly share code, notes, and snippets.

@npretto
npretto / Slice9.hx
Last active December 29, 2015 03:29
9path/slice9 class for flambe
package tools;
import flambe.display.ImageSprite;
import flambe.display.Texture;
import flambe.System;
/**
* ...
* @author lordkryss
*/
type direction = Up | Right | Down | Left;;
type position = Pos of int * int * direction;;
let point_of (Pos(x,y,dir)) = (x,y);;
let p = Pos(3,4,Up);;
point_of p;;
@npretto
npretto / MacroTools.hx
Last active August 29, 2015 14:12
MacroTools
package;
import haxe.macro.Context;
import haxe.macro.Expr;
import sys.FileSystem;
using sys.io.File;
@npretto
npretto / parse-logs.js
Created November 14, 2017 13:24
node parse-logs.js file-di-log.txt > parsed.csv
var path = process.argv[2];
console.log(`reading file ${path}`)
console.log(`Date, Memory`)
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream(path)
});
var regexp = /(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).*Memory : (\d*)MB/g;
@npretto
npretto / parseQueryString.js
Last active November 6, 2019 09:16
query string to object
queryString.split("&").map(string => string.split("=")).reduce((params,[key,value]) => ({...params, [key]:value}),{})
@npretto
npretto / start-haxe.js
Last active February 13, 2020 21:15
overcomplicated watch for "multi folder" haxe projects
const chokidar = require("chokidar");
const { spawn } = require("child_process");
const compilerPort = 6066;
// TODO:
// [ ] start compilation server
// [ ] use compilation server
// [ ] parse paths in stdout and add cwd so they can be clicked
// [ ] proper support for openfl / assets (run openfl build only when assets change)
@npretto
npretto / testID.code-snippets
Created February 20, 2020 15:52
vscode snippets for testID props
{
"testID interface props interface": {
"prefix": ["tii"], // [t]est [i]d [i]nterface
"body": ["testID?: string;"],
"description": "testID ts interface"
},
"testID prop forwarding": {
"prefix": ["tip"], // [t]est [i]d [p]rop
"body": ["testID={this.props.testID}"],
@npretto
npretto / figmastyles.js
Created April 9, 2020 12:44
get colors from figma and print them as ts code
// v this will probably change every figma deploy
const styles = [...document.querySelectorAll('.style_icon--styleIcon--3-PzQ')]
const colors = styles.map(style =>{
try {
const name = style.attributes['data-tooltip-style-name'].value.split(" ")[2]
const rgb = style.children[0].children[0].style.backgroundColor
@npretto
npretto / calibre-dark.css
Created May 31, 2020 12:14
calibre epub/ebook reader dark theme
body,
body * {
background-color: #1e1e1e !important;
color: #e1e1e1 !important;
}
h1,h2,h3,h4,h5,h6,h7 {
color: #9d5c63 !important;
}
@npretto
npretto / consolelogwithtypeof.code-snippets
Created June 16, 2020 12:00
console log with typeof
{
"console log with typeof": {
"prefix": ["clt"],
"body": ["console.log(\"$0\", typeof $0, $0)"],
"description": "console log with typeof"
}
}