Skip to content

Instantly share code, notes, and snippets.

View devendrasr's full-sized avatar
💭
building DataOS®

Devendra Singh devendrasr

💭
building DataOS®
View GitHub Profile
@devendrasr
devendrasr / econnreset-fix
Last active August 18, 2016 12:25
Solution to econnreset while using a http client for google snap to road api
var https = require('https');
//Setting max sockets did the thing for me
https.globalAgent.maxSockets = 99999999999;
https.request.timeout = 60000;
var options = { //setting options..host,port,path etc..
host: 'roads.googleapis.com',
//timeout: 60000,
port: 443,
path: '/v1/snapToRoads?path=' + trackString + '&interpolate=true&key=' + key,
@devendrasr
devendrasr / econnreset-fix-with-request-module
Created April 13, 2016 07:11
Fixed the econnreset issue for the request module while calling google snap to road api
var key = 'YOUR-KEY';
//Setting maxSockets to fix econnreset issue
var separateReqPool = {maxSockets: 9999999};
var url = 'https://roads.googleapis.com/v1/snapToRoads?key='+key+'&interpolate=true&path=' + trackString;
request.get({
url: url, json: true, pool: separateReqPool
}, function (err, r, b) {
console.log(err, b);
});
@devendrasr
devendrasr / stuns
Created August 7, 2016 17:08 — forked from yetithefoot/stuns
STUN+TURN servers list
{url:'stun:stun01.sipphone.com'},
{url:'stun:stun.ekiga.net'},
{url:'stun:stun.fwdnet.net'},
{url:'stun:stun.ideasip.com'},
{url:'stun:stun.iptel.org'},
{url:'stun:stun.rixtelecom.se'},
{url:'stun:stun.schlund.de'},
{url:'stun:stun.l.google.com:19302'},
{url:'stun:stun1.l.google.com:19302'},
{url:'stun:stun2.l.google.com:19302'},
@devendrasr
devendrasr / HelloWorld.java
Created October 18, 2016 07:32 — forked from lolzballs/HelloWorld.java
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@devendrasr
devendrasr / log.go
Created December 19, 2016 18:09 — forked from mbrevoort/log.go
Adding caller function, filename and line number to logrus log entries
package utils
import (
"runtime"
"github.com/Sirupsen/logrus"
)
// DecorateRuntimeContext appends line, file and function context to the logger
func DecorateRuntimeContext(logger *logrus.Entry) *logrus.Entry {
@devendrasr
devendrasr / binary_safe_to_binary_string.go
Last active January 19, 2017 19:16
Convert - Redis binary safe string to binary string
//Usage - toBinaryString("\xd4!")) ==> 110101000010000100100000
func toBinaryString(str string) string {
bitstring := ""
for i := 0; i < len(str); i++ {
for bit := 7; bit >= 0; bit-- {
set := (str[i]>>uint(bit))&1 == 1
if set {
bitstring += "1"
} else {
@devendrasr
devendrasr / pretty_json.sh
Created February 26, 2017 17:30
Add alias for pretty print json in zsh or bash
# Add alias for zsh shell
echo "alias json='python -mjson.tool'" >> ~/.zshrc
# Add alias to bash shell
echo "alias json='python -mjson.tool'" >> ~/.bashrc
curl -v -F "@file=template-document-hx.doc" host:port/path/to/server
@devendrasr
devendrasr / error_shell-init
Last active September 27, 2018 05:31
Error while starting kafka/zookeeper
➜ dist kafka-topics --list --zookeeper localhost:2181
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Error occurred during initialization of VM
java.lang.Error: Properties init: Could not determine current working directory.
at java.lang.System.initProperties(Native Method)
at java.lang.System.initializeSystemClass(System.java:1166)
@devendrasr
devendrasr / spark_streaming_context_error
Created September 27, 2018 09:04
Error while creating streaming context in spark
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'