Skip to content

Instantly share code, notes, and snippets.

View akaDPR's full-sized avatar
🤓
Building awesome stuff

MYTHiN akaDPR

🤓
Building awesome stuff
View GitHub Profile
@akaDPR
akaDPR / challenge-ramda.js
Last active October 24, 2021 17:19
Challenge 1
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.
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
*/
func (h *hub) run(db *gorm.DB) {
for {
fmt.Println("totalUsers", totalUsers)
select {
case s := <-h.register:
/*anon function to defer */
func() {
@akaDPR
akaDPR / max_locks_per_transaction.txt
Created February 20, 2020 06:40
Increase max_locks_per_transaction - postgres
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;
@akaDPR
akaDPR / file.json
Created February 13, 2020 10:36
elastic search - Mapping for search in e-commerce search-boxes
/* Used NodeJS Client for ElasticSearch */
/* ---- A simple mapping for Products and ProductURL ---- */
{
"properties": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete",
"search_analyzer": "autocomplete_search"
@akaDPR
akaDPR / main.go
Created December 31, 2019 06:23
Unmarshal JSON without defining struct In golang
package main
import (
"fmt"
"encoding/json"
)
func main() {
samjson := `{"name":"mytheen"}`
@akaDPR
akaDPR / Dockerfile
Created December 27, 2019 10:21
Dockerfile golang with dep tool
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
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"time"
"github.com/jinzhu/gorm"
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'));
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);