Skip to content

Instantly share code, notes, and snippets.

@flaki
flaki / native-promise-deferred.js
Created June 7, 2014 15:18
Deferred objects tooling based on the native ES6 Promise implementation
/*
* Extends native promises with deferred objects.
* Deferreds return an object that has a <promise>, which could be resolved via
* the included <resolve> and <reject> calls.
*/
if (Promise && !("deferred" in Promise)) Promise.deferred = function() {
var fResolve,
fReject,
P = new Promise(function(resolve, reject) {
fResolve = resolve;
@flaki
flaki / keybase.md
Created October 6, 2014 14:08
keybase.md

Keybase proof

I hereby claim:

  • I am flaki on github.
  • I am flaki (https://keybase.io/flaki) on keybase.
  • I have a public key whose fingerprint is 456C 501F 75FD 8D54 8C3A 12CD 6303 E8B6 1C62 C3CE

To claim this, I am signing this object:

@flaki
flaki / iojs_es6.md
Last active August 29, 2015 14:13
# io.js 1.0.0 (beta) is OUT — a beginners' guide to io.js and ES6

io.js 1.0.0 (beta) is OUT — a beginners' guide to io.js and ES6

actually, it is more like 1.0.1, but heck! :)

So what is this “io.js” ?

TL;DR: io.js is a [fork] of [node.js].

A bit more in-depth, please?

A few core maintainers of node.js got fed up with the slow updates of node.js, the infinite beta state of 0.11 and that 0.12 was basically coming for two years now, and decided to create their own fork of the server-side JavaScript runtime, called it io.js and released it today.
Read the Q&A for more background!

@flaki
flaki / hacks-rust-intro.md
Last active August 29, 2015 14:20
Rust 1.0.0 release introductory article for Hacks v5

Diving into Rust for the first time

A computer program may crash or hang due to a wide variety of reasons. Memory access violations/segmentation faults are most of the time rooted in unsafe memory handling, while hangs and unpredictable behavior could sometimes be attributed to concurrent, unsynced or out-of-sync access to memory.

Rust is a new programming language,

@flaki
flaki / init.coffee
Created July 18, 2015 14:36
Atom on Windows and Hungarian keyboard layout AltGr+<key> keybinding fix - add this to your init.coffee
# Your init script
# Fixes AltGr problems on Hungarian keyboard layouts in Windows
# for characters [ (AltGr+F), < (AltGr+M), \ (AltGr+Q) and { (AltGr+B)
atom.keymaps.keyBindings = atom.keymaps.keyBindings.filter((binding, i) ->
['ctrl-alt-f','ctrl-alt-q','ctrl-alt-b','ctrl-alt-m'].indexOf(binding.keystrokes) == - 1
)
@flaki
flaki / accel.js
Created September 8, 2015 05:52
T2 Rust Example
var spawn = require('child_process').spawn;
var child = spawn('accel_rs', [], {});
// Use standard out...
child.stdout.on('data', function(data) {
console.log(data.toString());
});
// ... OR use a domain socket
var net = require('net');
@flaki
flaki / nored.html
Created September 30, 2015 10:06
SVG Filter removing the red channel
body {
background:black;
}
p.target {
color: white;
margin: 0;
display: inline-block;
width: 16em;
}
p.target span {
@flaki
flaki / halloweend.ino
Created November 1, 2015 01:33
Spooky version of the Arduboy rund.ino game (https://github.com/flaki/arduino-rund-ino)
#include <SPI.h>
#include "Arduboy.h"
#include <EEPROM.h>
#include <avr/pgmspace.h>
Arduboy arduboy;
// frame counter
unsigned int frame = 0;
@flaki
flaki / formerreps.js
Last active January 8, 2016 11:17
Check Rep status (active/former) in reps.mozilla.org dashboard
if (window.location.toString() === "https://reps.mozilla.org/dashboard/") {
[].forEach.call(
document.querySelectorAll('#dashboard-mentorship-block [href*="/u/"]'),
function(a) {
console.log("Checking "+a.href+" ... ");
var r = new XMLHttpRequest();
r.open("GET", a.href);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;
var former = r.responseText.match(/Former Rep/);
@flaki
flaki / FirefoxEmoji.md
Last active January 8, 2016 21:12
Enabling FirefoxEmoji emoticons and the Firefox OS Emoji keyboard

Firefox OS Emoji 101

How to enable the built-in emoji keyboard?

  • Go to Settings ➡️ Keyboards ➡️ Select Keyboards:
  • Tick ✅ Emoji in the Built-in Keyboard group
  • Use the "change layout" button on the keyboard to switch between layouts, or
  • Long-press on the layout-change button and select "Emoji" to enable

If the option is not available, make sure you are on latest master, or if you are Foxfooding, set the nightly-latest update channel