Skip to content

Instantly share code, notes, and snippets.

View christiannwamba's full-sized avatar

Christian Nwamba christiannwamba

  • AWS
  • Lagos, Nigeria
View GitHub Profile
@christiannwamba
christiannwamba / jsbin.lojexi.js
Last active July 26, 2016 10:26 — forked from anonymous/index.html
Addy's Mediator Pattern example JS Bin// source http://jsbin.com/lojexi
console.clear();
var mediator = (function(){
// Storage for our topics/events
var channels = {};
// Subscribe to an event, supply a callback to be executed
// when that event is broadcast
var subscribe = function(channel, fn){
if (!channels[channel]) channels[channel] = [];
@christiannwamba
christiannwamba / jsbin.gupusu.js
Created July 26, 2016 10:26 — forked from anonymous/index.html
Addy's Observer Pattern example JS Bin// source http://jsbin.com/gupusu
console.clear();
/*!
* Pub/Sub implementation
* http://addyosmani.com/
* Licensed under the GPL
*/
var pubsubz = {};
(function (q) {
@christiannwamba
christiannwamba / gist:c374e0337f3b20a9aa6d82a50cdcb6a2
Created September 22, 2016 00:53 — forked from axoplasm/gist:bdda3922fa43b2ef25d8
Ditching Compass and Sass for LibSass

I had a large client framework extending my personal boilerplate that was taking upwards of 10seconds to compile with standard Ruby Sass. This framework had minimal dependencies:

I used Bundler to manage Ruby dependencies and ran tasks with Grunt — mainly compiling Sass via grunt-contrib-compass, and previewing with live-reload. Simple stuff.

But 10seconds was an unacceptable performance hit for me. I typically keep my monitor split in half (using Spectacle ), with a browser on one half and MacVim on the other. With Live Reload running I get a nearly realtime preview of my work … except for that one client framework, where I was gettin

@christiannwamba
christiannwamba / flatten-array.js
Last active September 28, 2016 21:11
Flatten nested array with recurssion
// Demo: http://jsbin.com/qaxurogowe/edit?html,js,console,output
// Recursive function
// which will continue to
// iterate through nested array until flattened
function flatten() {
// A control variable
// to hold flattened array
var flat = [];
// Begin a loop
for (var i = 0; i < arguments.length; i++) {
@christiannwamba
christiannwamba / ngrxintro.md
Created October 15, 2016 09:53 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

#Comprehensive Introduction to @ngrx/store By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

asyncOperation(function cb(valResolvedFromAsync) {
console.log(valResolvedFromAsync);
});
var ds = require('deepstream.io-client-js')
var data = require('./data.json');
var client = ds('APP-URL').login()
client.rpc.provide( 'price-chart', ( request, response ) => {
console.log(data);
response.send( formattedData( data.bpi ) );
});
{
"bpi": {
"2017-01-01": 997.6888,
"2017-01-02": 1018.05,
"2017-01-03": 1030.8175,
"2017-01-04": 1129.87,
"2017-01-05": 1005.815,
"2017-01-06": 895.67,
"2017-01-07": 905.17,
}
<html>
<head></head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/canvasjs/1.7.0/canvasjs.min.js"></script>
<script src="https://code.deepstreamhub.com/js/2.x/deepstream.min.js"></script>
<script>
var client = deepstream('wss://154.deepstreamhub.com?apiKey=430ca16b-b7f1-40e4-bf08-dca693e913df')
// Login
client.login()
<html>
<head></head>
<body>
<div id = "chartContainer" style = "height: 300px; width: 100%;" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/canvasjs/1.7.0/canvasjs.min.js"></script>
<script src="https://code.deepstreamhub.com/js/2.x/deepstream.min.js"></script>
<script>
// Script here
</script>
</body>