Skip to content

Instantly share code, notes, and snippets.

@OmisNomis
OmisNomis / goTutorial1.go
Last active March 23, 2018 09:08
Go Tutorial Series
package main
import "fmt"
// The entry point for the application is the 'main' function in the 'main' package.
// The main function must take no arguments and return no values.
func main() {
fmt.Println("Hello World")
}
@OmisNomis
OmisNomis / server.js
Created March 22, 2018 12:41
Node Express example
'use strict';
const mongoose = require('mongoose');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const app = require('express')();
const port = 8000;
/** Mongoose Schema setup */
@OmisNomis
OmisNomis / Recursion-2.js
Created March 8, 2018 08:33
Recursion Function
const flattenObject = object => {
let obj = {};
Object.keys(object).forEach(key => {
if (typeof object[key] !== 'object') {
obj[key] = object[key];
} else {
obj = { ...obj, ...flattenObject(object[key]) };
}
});
return obj;
@OmisNomis
OmisNomis / Recursion-1.js
Last active March 8, 2018 13:29
Multi-dimensional Object
// Given this Object
const obj1 = {
one: 1,
two: 2,
three: { four: 4, five: { six: 6 } },
seven: 7,
eight: { nine: 9, ten: 10 },
eleven: { twelve: { thirteen: { fourteen: 14 } } },
};