This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 } } }, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/kataras/iris" | |
"github.com/kataras/iris/middleware/logger" | |
"github.com/kataras/iris/middleware/recover" | |
) | |
func main() { | |
app := iris.New() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/* | |
* Highly scalable Express server | |
* Purely for example purposes, until I start the blog properly! | |
*/ | |
const cluster = require('cluster'); | |
if (cluster.isMaster) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/kataras/iris" | |
"github.com/kataras/iris/middleware/logger" | |
"github.com/kataras/iris/middleware/recover" | |
mgo "gopkg.in/mgo.v2" | |
"gopkg.in/mgo.v2/bson" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
) | |
// Make a new ToDo type that is a typed collection of fields | |
// (Title and Status), both of which are of type string | |
type ToDo struct { | |
Title, Status string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
) | |
// Make a new ToDo type that is a typed collection of fields | |
// (Title and Status), both of which are of type string | |
type ToDo struct { | |
Title, Status string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
task := new(Task) | |
// Publish the receivers methods | |
err := rpc.Register(task) | |
if err != nil { | |
log.Fatal("Format of service Task isn't correct. ", err) | |
} | |
// Register a HTTP handler | |
rpc.HandleHTTP() | |
// Listen to TPC connections on port 1234 |
OlderNewer