Skip to content

Instantly share code, notes, and snippets.

View juliandescottes's full-sized avatar

Julian Descottes juliandescottes

View GitHub Profile
@juliandescottes
juliandescottes / gist:5967554
Last active April 26, 2024 23:02
aria:Template vs html:Template
// html
{@html:Template {
id: "fareFamilies",
type:"div",
classpath: "my.path.Template"
}/}
// aria
{@aria:Template {
id : "fareFamilies",
defaultTemplate : "my.path.Template"
@juliandescottes
juliandescottes / gist:26d9cd26394c41b60be9
Created January 20, 2016 20:51
Regexp : fix indentation
(\n(?: {2})+) ([^\s])
$1$2
function screenshot(win) {
let canvas = win.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
let width = win.innerWidth;
let height = win.innerHeight;
canvas.mozOpaque = true;
canvas.width = width;
canvas.height = height;
let ctx = canvas.getContext("2d");
ctx.drawWindow(win, win.scrollX, win.scrollY, width, height, "#fff");
info("Screenshot:" + canvas.toDataURL());
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests if Copy as cURL works.
*/
const EXPECTED_POSIX_RESULT = [
@juliandescottes
juliandescottes / randomColors.js
Last active April 26, 2024 23:01
Fill current sprite with random colors
var rand = function (base) {
base = base || 1;
return (Math.random() * base) | 0;
};
var pad = function (str) {
if (str.length == 1) {
return "0" + str;
}
return str;
@juliandescottes
juliandescottes / gist:169f3a57e1441542565b
Last active April 26, 2024 23:01
Devtools file loading
╔═════════════════════════════════════════════════════════════════════════════════╗
║ How to load/import a file in Firefox Devtools ? ║
╚═════════════════════════════════════════════════════════════════════════════════╝
╔════════════════════════╗
║ SYNC FILE LOADING ║
╚════════════════════════╝
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┌───────────────────────────────┐
function* testYield() {
console.log("#1");
yield new Promise(r => setTimeout(r, 2000));
console.log("#2");
yield new Promise(r => setTimeout(r, 2000));
console.log("#3");
return;
@juliandescottes
juliandescottes / decode_and_recover.js
Created January 14, 2017 00:58
Recovery code for piskel files with weird encoding issues.
decodePiskelFile : function (rawPiskel, onSuccess, onError) {
try {
var serializedPiskel = JSON.parse(rawPiskel);
var piskel = serializedPiskel.piskel;
pskl.utils.serialization.Deserializer.deserialize(serializedPiskel, function (piskel) {
onSuccess(piskel);
});
} catch (e) {
var layers = [];
var isInLayer = false;
@juliandescottes
juliandescottes / export_to_unit8_t_rotate.js
Last active April 26, 2024 23:00
Piskel Feature request: Add unit8_t version to "Export as C file" for single color images #606
var export_to_unit8_t_rot = function () {
var HTML_NEW_LINE = '
';
var width = pskl.app.piskelController.getWidth();
var height = pskl.app.piskelController.getHeight();
var frameCount = pskl.app.piskelController.getFrameCount();
if (frameCount > 1) {
console.error('This export only supports one frame');
}