Skip to content

Instantly share code, notes, and snippets.

View svnlto's full-sized avatar
🦙

Sven Lito svnlto

🦙
View GitHub Profile
@svnlto
svnlto / feathersjs-dataloader.js
Created July 24, 2017 18:00 — forked from giautm/feathersjs-dataloader.js
Use facebook's dataloader to batch any Service get
'use strict';
const DataLoader = require('dataloader');
class Service {
constructor({ BaseService, options }) {
this.id = BaseService.id || 'id';
this.service = BaseService;
this.dataloader = new DataLoader(this._batchGet.bind(this), options);
@svnlto
svnlto / webhooks-with-hapi.js
Created August 27, 2016 10:19
Webhook receiver with hapi.js
/*
Webhook receivers should accept a request and immediately respond with HTTP 204 No Content before processing the request. Here's how to do this with hapi.js.
Start this server:
`node webhooks-with-hapi.js`
Then make a request:
`curl http://localhost:8000/webhook-receiver -v`
Note the correct behavior: HTTP response will be sent and connection closed before the webhook processing starts.
@svnlto
svnlto / README.md
Created February 18, 2016 13:40 — forked from yang-wei/README.md
ES6 destructing (and rest parameter)

We will first discussed how destructing and rest parameters can be used in ES6 - in arrays and objects. Then we will look at a few examples and also discuss some quiz.

arrays

var array = [1, 2, 3, 4];
var nestedArray = [1, 2, 3, 4, [7, 8, 9]];

var [a, b, c, d] = array;
console.log(a, b, c, d)
'use strict';
var React = require('react/addons');
var PureRenderMixin = React.addons.PureRenderMixin;
var MAX_LOADING_TASKS = 3;
var loadingQueue = [];
var loadingQueueDirty = false;
var loadingTasks = 0;
@svnlto
svnlto / 00_ha_dnscrypt_proxy_client_setup.markdown
Last active September 1, 2015 16:59
Highly-available dnscrypt-proxy client setup on OSX with DNSSEC.

Tested, works!

Install

git clone https://gist.github.com/svnlto/8c763425cdc4dce06f78 && cd 8c763425cdc4dce06f78 && sh install.sh && cd .. && rm -rf 8c763425cdc4dce06f78

Uninstall

git clone https://gist.github.com/svnlto/8c763425cdc4dce06f78 && cd 8c763425cdc4dce06f78 && sh uninstall.sh && cd .. && rm -rf 8c763425cdc4dce06f78

@svnlto
svnlto / 00-docker-registry-setup.md
Last active December 9, 2022 04:51 — forked from devpkiconix/00-docker-registry-setup.md
Docker registry setup on boot2docker

After this setup, all the images pushed to the registry will be available in ~/registry/data directory.

Steps:

  1. Install boot2docker. this will be our registry server
  2. Run boot2docker. This should mount user folder from host (e.g. /Users-> /Users). We will host the registry files in this tree, at: ~/registry/data
  3. Save its IP address, REGISTRY_HOST=$(boot2docker ip)
  4. Run registry. Note that this must be executed on the host machine for the shell to interpret ~ correctly.
@svnlto
svnlto / specs.js.coffee
Created June 13, 2012 17:23 — forked from doitian/specs.js.coffee
3 ways to test ajax requests or other asynchronouse lib based on jquery deferred
# The second way is recommended, which is flexible, and also work for non jQuery ajax library.
# Setup sinon sandbox
beforeEach ->
@sinon = sinon.sandbox.create()
afterEach ->
@sinon.restore()
@svnlto
svnlto / gist:1491564
Created December 17, 2011 22:11 — forked from ryanrolds/gist:1491554
svnlto
function request(callback) {
var http, options;
http = require("http");
options = {
host: "api.outofme.de",
port: 80,
path: "/graphics",
method: "GET"
};
@svnlto
svnlto / gist:1491562
Created December 17, 2011 22:10 — forked from ryanrolds/gist:1491554
svnlto
function request(callback) {
var http, options;
http = require("http");
options = {
host: "api.outofme.de",
port: 80,
path: "/graphics",
method: "GET"
};