Skip to content

Instantly share code, notes, and snippets.

View foo123's full-sized avatar

Nikos M. foo123

View GitHub Profile
macro to_str {
case { _ ($toks ...) } => {
return [makeValue(#{ $toks ... }.map(unwrapSyntax).join(''), #{ here })];
}
}
to_str(1 2 3 4)
// '1234'
@Yaffle
Yaffle / URLSearchParams.js
Last active December 2, 2015 11:56
http://url.spec.whatwg.org/ - thanks to Anne van Kesteren for the spec
"use strict";
function URLSearchParams(query) {
var data = [];
query = query.toString();
query = query.replace(/\+/g, " ");
var strings = query.split("&");
var l = strings.length;
var i = 0;
while (i < l) {
/**
* At least two points are needed to interpolate something.
* @class Lagrange polynomial interpolation.
* The computed interpolation polynomial will be reffered to as L(x).
* @example
* var l = new Lagrange(0, 0, 1, 1);
* var index = l.addPoint(0.5, 0.8);
* console.log(l.valueOf(0.1));
*
* l.changePoint(index, 0.5, 0.1);

Virtual DOM and diffing algorithm

There was a [great article][1] about how react implements it's virtual DOM. There are some really interesting ideas in there but they are deeply buried in the implementation of the React framework.

However, it's possible to implement just the virtual DOM and diff algorithm on it's own as a set of independent modules.

@Yaffle
Yaffle / timeZone.html
Created September 13, 2013 11:13
timeZone.html
<script>
var timeZoneIds = [
"Africa/Abidjan",
"Africa/Accra",
"Africa/Addis_Ababa",
"Africa/Algiers",
"Africa/Asmera",
"Africa/Bamako",
"Africa/Bangui",
@jeremypetrequin
jeremypetrequin / article.md
Last active December 25, 2016 08:06
How to convert a Flash/After Effects animation into a JSMovieclip animation

How to convert a Flash/After Effects animation into a JSMovieclip animation

Intro

JSMovieclip is a little javascript framework. It allows you to play, control... animations like a Movieclip object in AS3. It uses a sprite which contains all frames of the animation.

Purpose : We'll create a sprite to use with JSMovieclip, from a Flash animation, using TexturePacker

Requirement : We'll use Flash/After Effects, Texture Packer, and JSMovieclip script

@johan
johan / grep.js
Created May 9, 2013 21:49
Use grep to find direct/inherited properties of an object or function, or grep.own for direct properties only. (Great for Chrome 29's devtools' Script snippets panel.)
/* Examples:
Use grep with two arguments to find inherited or direct properties of an object:
> grep(document, 'get') // see all properties case insensitively matching *get*:
{ getCSSCanvasContext: function getCSSCanvasContext() { [native code] }
, getElementById: function getElementById() { [native code] }
, getElementsByClassName: function getElementsByClassName() { [native code] }
, getElementsByName: function getElementsByName() { [native code] }
, getElementsByTagName: function getElementsByTagName() { [native code] }
@lgersman
lgersman / README.md
Last active October 19, 2022 12:15
improved version of my d3.js selection frame example (https://gist.github.com/lgersman/5310854) supporting draggable/selectable nodes
  • Click into the drawing area to start the selection frame
  • move the mouse to resize the selection frame
  • Release the mouse button to resize the selection frame

new features :

  • circles are draggable
  • circles can be selected (multiple selections possible by pressing CTRL while clicking a circle)
  • the selection frame selects all circles within the frame (by pressing CTRL the selected circles will be appended to current selection)
  • multiple selected circles will be dragged simultaneous
@stoyan
stoyan / jsperf-bookmarklet.js
Last active April 29, 2023 14:58
bookmarklet to send a jsperf test to all webpagetest's IEs
(function(){
var key = localStorage.wpt_key;
if (!key) {
var prompt = window.__proto__.prompt;
key = prompt('Your WebPagetest API key, please?');
if (!key) {
return gameOver();
}
localStorage.wpt_key = key;
@garycourt
garycourt / Grep.js
Created November 22, 2012 20:16 — forked from nicdaCosta/Grep.js
Basic function that searches / filters any object or function and returns matched properties.
/*
Grep.js
Author : Nic da Costa ( @nic_daCosta ), Gary Court
Created : 2012/11/14
Version : 0.1.1
License : MIT, GPL licenses.
Overview:
Basic function that searches / filters any object or function and returns matched properties.
Main area of use would be for DevTools purposes, when needing to find a specific property but only part of