Skip to content

Instantly share code, notes, and snippets.

View kvz's full-sized avatar

Kevin van Zonneveld kvz

View GitHub Profile
@kvz
kvz / coffee-to-es6.md
Last active November 15, 2017 23:23
Going from CoffeeScript to ES6

These are the steps I took to change a modest project from CoffeeScript to ES6.

My ~2000LoC project took me around 6 hours to port, but I sunk 3 hours into a stupid mistake, and 2 into figuring out these steps, so with these steps & warnings at your disposal already, you should be able to do bigger projects in considerably less time.

Automatic tools only take you so far, there will be some manual fixing. Sometimes the generated code clearly doesn't look like a human wrote it, and sometimes there are bugs.

In this last case, when porting software trips over a particular bit of CoffeeScript, comment this bit out, and try transpiling the file again. If this is successfull, you'll see the commented CoffeeScript inside the JS, and you can port that bit yourself.

Okay let's dive right in!

@kvz
kvz / Makefile
Last active August 28, 2021 14:35
The only Makefile for Node.js projects you'll ever need - https://twitter.com/kvz/status/685853830425231361
# Licensed under MIT.
# Copyright (2016) by Kevin van Zonneveld https://twitter.com/kvz
#
# This Makefile offers convience shortcuts into any Node.js project that utilizes npm scripts.
# It functions as a wrapper around the actual listed in `package.json`
# So instead of typing:
#
# $ npm script build:assets
#
# you could just as well type:
"meta": {
"width": 500,
"height": 753,
"date_recorded": null,
"date_file_created": "2015/10/14 16:15:48",
"date_file_modified": "2015/11/18 13:28:12 GMT",
"title": "Terry%20Carkner",
"description": "Terry Carkner",
"location": null,
"aspect_ratio": "0.664",
#!/usr/bin/env bash
# Git Timetracker. Copyright Kevin van Zonneveld (kvz.io)
# License under MIT
#
# This file
#
# - can be run inside a git repository to get a list on what hours work took place (for billing)
# - takes 1 argument: since. It defaults to "2 months"
#
# Usage:
@kvz
kvz / gist:a566ba3be4a3faf7d6e6
Last active May 10, 2016 11:39
Proposal for (partial) template includes
{
include_template: "a", // <-- full template, used as a base
is_video: {
use: ":original",
robot: "/file/filter",
accepts: [
[
"${file.mime}",
"regex",
"video"
#!/usr/bin/env bash
# Transloadit API2. Copyright (c) 2015, Transloadit Ltd.
#
# This file
# - Reproduces the issue where resizing a certain jpg breaks
# the image on OSX & iOS, wheras the original dispays fine.
#
# Reported first by Richard Taylor in http://support.transloadit.com/discussions/questions/96479-image-conversion-problem
#
# Typically called as `./debug.sh [target.jpg]`
cd /tmp
wget -nc https://www.dropbox.com/s/04u5xws6fkvbkgb/Shred_Those_Pounds.mp4?dl=1 -O Shred_Those_Pounds.mp4
echo ""
echo ""
echo "--> Failure with '-sn -dn'"
ffmpeg-v2.2.3 \
-i ./Shred_Those_Pounds.mp4 \
-codec:a libfdk_aac \
"steps": {
"ipad": {
"robot" : "/video/encode",
"use" : [ ":original" ],
"preset": "ipad"
},
"webm": {
"robot" : "/video/encode",
"use" : [ ":original" ],
"preset": "webm"
@kvz
kvz / strace-identify-list-delegate.sh
Last active August 29, 2015 13:57
When I run `identify -list delegate` it shows my delegates, but then exits with "Aborted (core dumped)"
# I statically compiled Imagemagick.
# Converting works well so far.
# But when I run `identify -list delegate` it shows my delegates, but then exits with "Aborted (core dumped)".
# What could be wrong here?
$ strace -f identify -list delegate
execve("./target/bin/identify", ["identify", "-list", "delegate"], [/* 21 vars */]) = 0
brk(0) = 0x34e2000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8452cd8000