Skip to content

Instantly share code, notes, and snippets.

@OmisNomis
OmisNomis / redis-example.go
Created December 27, 2018 12:39 — forked from pohzipohzi/redis-example.go
Examples from redigo
// this is a file that puts together all redigo examples for convenience
// (see https://godoc.org/github.com/gomodule/redigo/redis#pkg-examples)
//
// start by ensuring that redis is running on port 6379 (`redis-server`)
// uncomment the main method as needed, and run the script (`go run main.go`)
package main
import (
"fmt"
"github.com/gomodule/redigo/redis"
@OmisNomis
OmisNomis / GoRPCTutorial6.go
Created April 19, 2018 09:06
GO RPC Tutorial
package main
import (
"log"
"net/rpc"
)
type ToDo struct {
Title, Status string
}
@OmisNomis
OmisNomis / GoRPCTutorial5.go
Created April 19, 2018 08:40
Go RPC Tutorial
finishApp := ToDo{"Finish App", "Started"}
makeDinner := ToDo{"Make Dinner", "Not Started"}
walkDog := ToDo{"Walk the dog", "Not Started"}
task.MakeToDo(finishApp, &reply)
task.MakeToDo(makeDinner, &reply)
task.MakeToDo(walkDog, &reply)
task.DeleteToDo(makeDinner, &reply)
task.MakeToDo(makeDinner, &reply)
task.GetToDo("Finish App", &reply)
task.GetToDo("Finish Application", &reply)
@OmisNomis
OmisNomis / GoRPCTutorial4.go
Created April 19, 2018 08:33
Go RPC Tutorial
package main
import (
"log"
"net/rpc"
)
type ToDo struct {
Title, Status string
}
@OmisNomis
OmisNomis / GoRPCTutorial3.go
Created April 19, 2018 08:24
Go RPC Tutorial
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
@OmisNomis
OmisNomis / GoRPCTutorial2.go
Created April 19, 2018 07:57
Go RPC Tutorial
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
@OmisNomis
OmisNomis / GoRPCTutorial1.go
Last active April 18, 2018 14:34
Go RPC Tutorial
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
@OmisNomis
OmisNomis / goTutorial3.go
Last active April 15, 2018 17:16
Go Tutorial Series
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"
)
@OmisNomis
OmisNomis / expressCluster1.js
Created April 12, 2018 10:14
Express application with Node Clustering
'use strict';
/*
* Highly scalable Express server
* Purely for example purposes, until I start the blog properly!
*/
const cluster = require('cluster');
if (cluster.isMaster) {
@OmisNomis
OmisNomis / goTutorial2.go
Created April 9, 2018 11:26
Go Tutorial Series
package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/middleware/logger"
"github.com/kataras/iris/middleware/recover"
)
func main() {
app := iris.New()