Skip to content

Instantly share code, notes, and snippets.

View sgnl's full-sized avatar
🍪
Do you agree to share your cookies?

Ray Farias sgnl

🍪
Do you agree to share your cookies?
  • Hawaii
View GitHub Profile
@sgnl
sgnl / server.js
Created February 11, 2016 01:52
Simple example of sessions in Express with 'Express-Session' package
'use strict';
const Express = require('express');
const Server = Express();
const BodyParser = require('body-parser');
const Session = require('express-session');
Server.use(BodyParser.json());
@sgnl
sgnl / README.md
Last active February 9, 2016 04:45
Kanban Angular

Kanbangular

"The Kanban technique emerged in the late 1940s as Toyota’s reimagined approach to manufacturing and engineering. ... The system’s highly visual nature allowed teams to communicate more easily on what work needed to be done and when. It also standardized cues and refined processes, which helped to reduce waste and maximize value." - via LeanKit.com

Goal

Create a 3 column Kanban board:

  • using AngularJS to build the client
  • using ExpressJS to build the server
  • using a SQL database to store your data.
  • implement stretch goals.
@sgnl
sgnl / middleware-validator.js
Created January 20, 2016 03:54
dynamic key validator example
'use strict';
module.exports = ( (validationArgs) => {
return (req, res, next) => {
var result = validationArgs.every( key => req.hasOwnProperty(key) ) ?
console.log('everything is okay')
: console.log('BAD')
};
});
@sgnl
sgnl / README.md
Created January 19, 2016 19:24
Building a payload validation middleware (featuring Currying functions in Javascript)

.

@sgnl
sgnl / README.md
Last active July 16, 2016 00:40
Articles, Products and Express - Oh my!
@sgnl
sgnl / fix.md
Last active January 15, 2016 01:15
Fixing "All my values are strings"

in server.js file

server.use(bodyParser.urlencoded({ extended: true})); // remove this line
server.use(bodyParser.json({ type: 'application/json' })); //replace with this line

in Postman:

image

@sgnl
sgnl / README.md
Last active January 14, 2016 01:12
Extend Buzz Word Bingo

Adding Middleware to Buzz Word Bingo

Now that you have the endpoints built let's (you) build some validations for the data coming over.

Your middleware will check if the request's body contains the required keys and also make sure that the values at those keys have values and are of the expected Data-type.

Example: POST /buzzword => { "buzzWord": String, "points": Number }

A POST request to the resource /buzzword should have two keys: buzzWord and points. Also be sure that the value stored at each key is of the right data type. e.g. buzzWord key should contain a value of String data type. points key should contain a value of Number data type.

@sgnl
sgnl / express-todo-api.md
Last active July 13, 2017 07:20
Buzz Word Bingo API Exercise (no database edition)

Buzz Word Bingo

About the game

Before a meeting the players are asked to enter words with point values. A player can enter a total of 5 words at most. Once a meeting starts if a word that the player previously entered is heard during a meeting that player can mark that word and score the points increasing their score. Each time the player scores a new word the total increases by the point value.

Welcome to Team Buzz™

Our game has been getting a lot of traction and we need to rebuild the API server with NodeJS to handle all the connections, we need you to create the server using ExpressJS. Our CTO will provide you with the specs below.

@sgnl
sgnl / client.js
Created January 9, 2016 21:51
Process & Net client starter pack
const Net = require('net');
// Server is actually this client
const Server = Net.connect({host: 'localhost', port: 6969}, function() {
process.stdin.setEncoding('utf8');
Server.setEncoding('utf8');
process.stdout.write('SGNL: ');
process.stdin.on('data', function(data) {
Server.write(data);
@sgnl
sgnl / 0-avoiding-this.js
Created January 9, 2016 04:10
Module Pattern - How to avoid using `this` and When you need to use `this`
module.exports = (function() {
var name = 'Ray';
var age = 32;
function doSomethingGreat() {
console.log(name);
console.log(age);
anotherGreatness();
}