Skip to content

Instantly share code, notes, and snippets.

@ldd
ldd / day2.js
Created December 4, 2017 14:21
Advent of code - day 2
// day 2
const day2part1 = s => s
.split("\n")
.map(el=> {
const row = el.split(/\s/);
return Math.max(...row) - Math.min(...row);
})
.reduce((p,n)=>p+n,0)
const day2part2 = s => s
@ldd
ldd / rev.js
Last active November 5, 2017 03:55
reverse unicode strings
var rSymbolMarks = /(<%= allExceptCombiningMarks %>)(<%= combiningMarks %>+)/g;
var rSurrogatePair = /([\uD800-\uDBFF])([\uDC00-\uDFFF])/g;
var reverse = s => s
.replace(rSymbolMarks, ($0, $1, $2) => `${reverse($2)}${$1}`)
.replace(rSurrogatePair, '$2$1')
.split('')
.reverse()
.join('')
var fn = function(){};
module.exports = {
Body: fn,
Spring: fn,
Material: fn,
ContactMaterial: fn,
DistanceConstraint: fn,
GearConstraint: fn,
LockConstraint: fn,
PrismaticConstraint: fn,
/* jshint plusplus:false */
/* jshint quotmark:false */
compositor = (function(){
var VERTEX_SIZE = 2;
var COLOR_SIZE = 4;
var TEXTURE_SIZE = 1;
var REGION_SIZE = 2;
var ELEMENT_SIZE = VERTEX_SIZE + COLOR_SIZE + TEXTURE_SIZE + REGION_SIZE;
var ELEMENT_OFFSET = ELEMENT_SIZE * Float32Array.BYTES_PER_ELEMENT;
@ldd
ldd / tiledtip.md
Last active January 23, 2017 07:24
using TIled from a non-interactive command line

This took some time to find, but this link should clarify the problem.

At least in MAC OSX, you need to do the following:

  1. create a script in /usr/local/bin/ and call it Tiled.

  2. add the following to it

#!/bin/bash
 exec "#{target}" "$@"
@ldd
ldd / Slider.js
Created January 18, 2017 21:15
Vertical Slider for Slick UI (Phaser)
SlickUI.namespace('Element');
/**
* Create a Slider to control defined values
*
* @author Richard Snijders <richard@fizz.nl>
* @param x
* @param y
* @param size
* @param value

preparations

  • install imagemagick
  • download and unzip assets

step-by-step guide

STEP 1: Finding the dimensions of the image

{
"universities":{
"mcgill":{
"key": "mcgill",
"title": "McGill University",
"courseCodes":{
"COMP424":{
"title": "COMP 424: AI",
"metadata": {
"textbooks":[
@ldd
ldd / github.js
Last active January 14, 2016 06:18
github API for javascript using webpack
/*!
* @overview Github.js
*
* @copyright (c) 2013 Michael Aufreiter, Development Seed
* Github.js is freely distributable.
*
* @license Licensed under BSD-3-Clause-Clear
*
* For all details and documentation:
* http://substance.io/michael/github
@ldd
ldd / github.js
Created January 14, 2016 06:14
github API for javascript using webpack
/*!
* @overview Github.js
*
* @copyright (c) 2013 Michael Aufreiter, Development Seed
* Github.js is freely distributable.
*
* @license Licensed under BSD-3-Clause-Clear
*
* For all details and documentation:
* http://substance.io/michael/github