Skip to content

Instantly share code, notes, and snippets.

@fantasywind
fantasywind / equalizer.js
Last active August 25, 2016 21:19
Javascript Audio Frequency Based Equalizer
// Sample of setting
// const setting = {
// left: [
// [50, 0],
// [1000, 0],
// [2000, 0],
// [4000, 0],
// [8000, 0],
// [12000, 0],
// [15000, 0],
@OlegIlyenko
OlegIlyenko / Event-stream based GraphQL subscriptions.md
Last active February 24, 2024 04:41
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

{
"swagger": 2,
"info": {
"title": "天品時光膠囊 API",
"description": "Tianping Time capsule API",
"version": "1.0.0"
},
"host": "tianping.test.rytass.com",
"schemes": [
"http"
@kopipejst
kopipejst / migrate.js
Created August 24, 2014 01:07
loopback create build-in models tables
/**
* loopback: create build-in models tables
*
* put migrate.js file in server folder
* run `node migrate.js`
* @type {[type]}
*/
var app = require('./server');
var dataSource = app.dataSources.db;
require "formula"
class Mongodb < Formula
homepage "http://www.mongodb.org/"
url "http://downloads.mongodb.org/src/mongodb-src-r2.6.3.tar.gz"
sha1 "226ab45e3a2e4d4a749271f1bce393ea8358d3dd"
bottle do
sha1 "d573717ca7c67455680a6823de210c940faf9ac6" => :mavericks
sha1 "f7d2a0711e3ac09fd61bcb243360c1a07fb83233" => :mountain_lion
@staltz
staltz / introrx.md
Last active April 29, 2024 09:25
The introduction to Reactive Programming you've been missing
@mildred
mildred / howto_nat_traversal.md
Last active December 9, 2023 06:59
How To TCP NAT Traversal using Node.js and a STUN Server

How To TCP NAT Traversal using Node.js and a STUN Server

With the scarecity of IPv4 addresses, and IPv6 still not available at large, NAT traversal is becoming a necessity. Especially with the generalisation of Carrier-grade NATs that you can find on mobile connections. Even with IPv6 you may suffer NAT66. Imagine your mobile device that gets only a single Ipv6 address, and you want to share it on your computer.

The solution might be in a decentralized protocol for address attribution such

Array.prototype.filter = Array.prototype.filter
|| function (fn) {
var item;
var clone = this.slice();
var done = {};
clone.push(done);
while ((item = clone.shift()) !== done) {
if (fn(item)) clone.push(item);
}
return clone;
@fantasywind
fantasywind / Gruntfile.js for yo angular with jade and stylus
Last active August 29, 2015 13:56
Please install contrib first: npm install grunt-contrib-jade -D;npm install grunt-contrib-stylus -D;npm install;
// Generated on 2014-02-05 using generator-angular 0.7.1
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"