Skip to content

Instantly share code, notes, and snippets.

View n1k0's full-sized avatar
✏️
writing a github status

Nicolas Perriault n1k0

✏️
writing a github status
View GitHub Profile
@n1k0
n1k0 / batch.js
Last active September 1, 2016 13:21
Quick kinto-http batch sample data creation script
var opts = {headers: {Authorization: "Basic " + require("btoa")("test:test")}};
var c = new (require("kinto-http"))("http://0.0.0.0:8888/v1", opts);
var schema = {"type": "object", "properties": {"n": {"type": "number"}}};
var displayFields = ["n"];
c.createBucket("buck")
.then(() => c.bucket("buck").createCollection("coll", {
data: {schema, displayFields}
}))
.then(() => {
@n1k0
n1k0 / series.md
Last active August 14, 2018 20:02 — forked from twidi/series.md
series a voir
Title Seen Rating ★☆
24 ★★☆☆☆
Ash vs Evil Dead ?
Bates Motel ★★★☆☆
Battlestar Galactica ?
Better Call Saul ★★★★★
Black Mirror ★★★★★
Black Sails ?
Breaking Bad ★★★★★
@n1k0
n1k0 / index.html
Created January 18, 2016 08:01
Firefox service worker bug with ZERO WIDTH JOINER char (0x200D)
<!DOCTYPE html>
<html><meta charset="utf-8"></head>
<body>
<script>
window.navigator.serviceWorker.register("worker.js", {scope: "/"})
.then(reg => console.log("registered", reg))
.catch(err => console.error("service worker error", err))
</script>
</body>
</html>
@n1k0
n1k0 / nuts.js
Created August 29, 2015 07:22
nuts.js
function add(){var a,v,n,f;a=[].slice.call(arguments),v=a[0]||0;if(a.length){n=a.slice(1).reduce(function(s,x){return s+x},v),f=add.bind(0,n);f.valueOf=function(){return n};return f}return v}
function test(a, b) {
if (a == b) {
console.log('OK');
} else {
console.log(a + ' != ' + b);
}
}
@n1k0
n1k0 / pre-commit
Created July 7, 2015 13:07
This git pre-commit hook checks for .only remaining in js mocha test files and prevent commiting if any.
#!/bin/sh
# This checks for .only remaining in js mocha test files and prevent
# commiting if any.
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
@n1k0
n1k0 / index.js
Last active August 29, 2015 14:16
requirebin sketch
var Dexie = require("dexie");
var db = new Dexie("articles2");
db.version(1).stores({articles: "id++,title,archived"});
db.open();
db.on("error", function(err) {
console.error(err);
});
db.articles.add({title: "plop", archived: "true"}).catch(console.error.bind(console)).then(function(id) {
console.log(id);
@n1k0
n1k0 / index.js
Created February 20, 2015 15:14
requirebin sketch
var client = require("rest").wrap(require("rest/interceptor/jsonp"));
client({path: 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0', params: { q: 'javascript' } }).then(function (response) {
console.log(response);
});
@n1k0
n1k0 / index.js
Last active August 29, 2015 14:15
requirebin sketch
var client = require("rest/client/jsonp");
client({
path: 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0',
params: { q: 'javascript' }
}).then(function(response) {
console.log("success", response);
}).catch(function(response) {
console.error("errored", response);
});
@n1k0
n1k0 / flux.md
Last active August 29, 2015 14:14

Flux target API

This is a draft, WiP README Driven Development Wishlist for a Flux API. Don't judge, contribute.

Stores

Definition

@n1k0
n1k0 / flux.md
Last active August 29, 2015 14:07

Basically Flux

While trying to explain Flux to a friend using words, I realized that a diagram's worth a thousand of them, and went with this.

              +---------------------+               
              |                     |               
              |     Dispatcher      |               
          +-->|          +---------------+
          |   +----------|----------+    |