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
R.compose(R.flip(R.prepend)(acc), R.sum,R.map(R.add(1)))([x,...acc]) | |
R.reduce => R.compose(/*[15,0]*/ R.flip(R.prepend)(acc), /*[15]*/ R.sum, /*[14, 1]*/ R.map(R.add(1)))([13, ...0]) | |
R.reduce => R.compose(/*[46,15,0]*/ R.flip(R.prepend)(acc), /*[46]*/ R.sum, /*[29,16,1]*/ R.map(R.add(1)))([28, ...15,0]) | |
/* | |
[46,15,0] | |
R.reduce - a higher-order function that will return a single value from an array. |
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
router.HandleFunc("/ws/{rname}", func(w http.ResponseWriter, r *http.Request) { | |
defer r.Body.Close() | |
/* | |
Authenticate user with custom-headers | |
After authentication , Get the action from client | |
*/ |
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 (h *hub) run(db *gorm.DB) { | |
for { | |
fmt.Println("totalUsers", totalUsers) | |
select { | |
case s := <-h.register: | |
/*anon function to defer */ | |
func() { |
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
1) port-forward your postgres instance to localhost | |
2) psql -U admin -h localhost -p 6432 -d <db-name> | |
In the above command , I port-forwaded the postgres micro-service to localhost port 6432 | |
3) Once you enterd to psql terminal , | |
4) <db-name>#= SHOW max_locks_per_transaction; | |
5) <db-name>#= ALTER SYSTEM SET max_locks_per_transaction = 1024; |
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
/* Used NodeJS Client for ElasticSearch */ | |
/* ---- A simple mapping for Products and ProductURL ---- */ | |
{ | |
"properties": { | |
"autocomplete": { | |
"type": "text", | |
"analyzer": "autocomplete", | |
"search_analyzer": "autocomplete_search" |
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" | |
"encoding/json" | |
) | |
func main() { | |
samjson := `{"name":"mytheen"}` |
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
FROM golang:1.9.6-alpine3.7 | |
WORKDIR /go/src/golang-chat | |
ADD . /go/src/golang-chat/ | |
RUN apk add --no-cache git | |
RUN go get -u github.com/golang/dep/cmd/dep |
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 ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"log" | |
"time" | |
"github.com/jinzhu/gorm" |
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
var express = require('express'); | |
var http = require('http') | |
var mongojs = require('mongojs'); | |
var ObjectID = mongojs.ObjectID; | |
var db = mongojs(process.env.MONGO_URL || 'mongodb://localhost:27017/local'); | |
var archeive = mongojs(process.env.MONGO_URL || 'mongodb://localhost:27017/admin'); | |
var app = express(); | |
var server = http.Server(app); | |
const chatLimit = 5; | |
server.listen(3004, () => console.log('listening on *:3004')); |
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
var express = require('express'); | |
var http = require('http') | |
var socketio = require('socket.io'); | |
var mongojs = require('mongojs'); | |
var ObjectID = mongojs.ObjectID; | |
var db = mongojs(process.env.MONGO_URL || 'mongodb://localhost:27017/local'); | |
var backup = mongojs(process.env.MONGO_URL || 'mongodb://localhost:27017/backup'); | |
var app = express(); | |
var server = http.Server(app); |
NewerOlder