Skip to content

Instantly share code, notes, and snippets.

View doron2402's full-sized avatar

Doron Segal doron2402

View GitHub Profile
@doron2402
doron2402 / links.txt
Created March 27, 2020 02:25
gRPC useful resources
@doron2402
doron2402 / promises_example.go
Created January 19, 2020 23:14
Promises implementation using Go (Golang)
package main
import (
"errors"
"fmt"
)
type Promise struct {
successChannel chan interface{}
failureChannel chan error
@doron2402
doron2402 / main.go
Last active May 3, 2019 23:44
communicating between golang and python via http binary data
package main
import (
"crypto/rand"
"encoding/binary"
"log"
"net/http"
)
// GenerateUint64 - generate a random uint64
@doron2402
doron2402 / async.py
Created April 28, 2019 20:49
python asyncio vs sync code
#!/usr/bin/env python3
import asyncio
import time
async def count():
print("One")
await asyncio.sleep(1)
print("Two")
@doron2402
doron2402 / http_server_with_nsq_py_3.7
Created April 28, 2019 01:06
Python 3.7 nsq + web server
import asyncio
from aiohttp import web
from asyncnsq import create_reader
from asyncnsq.utils import get_logger
# Handle request
async def handle_echo(reader, writer):
data = await reader.read(100)
message = data.decode()
addr = writer.get_extra_info('peername')
@doron2402
doron2402 / simple-upload-server.js
Last active April 25, 2018 19:04
Simple upload server using single dependecy
'use strict';
/**
For full repo go to:
https://github.com/doron2402/simple-upload-files
**/
const http = require('http');
const uploaderRoute = require('./routes/uploader');
const formRoute = require('./routes/form');
const notFoundRoute = require('./routes/notFound');
@doron2402
doron2402 / person_example.go
Last active March 24, 2018 19:13
Golang prototype
package main
import "fmt"
type person struct {
firstName string
lastName string
age float32
id int
}
@doron2402
doron2402 / vodka_shots_tip.r
Last active October 29, 2017 16:14
Polynomial Regression - Predict tip after X number of vodka shots
# Polynomial Regression
# Number Of Vodka Shots Vs Tip
dataset = read.csv('./shots_tip.csv')
# Let's fit the data to a Linear Regression Model
linear_regressor = lm(formula = Tip ~ NumberOfShots,
data = dataset)
@doron2402
doron2402 / shots_tip.csv
Created October 29, 2017 02:40
Number of Vodka shots VS Tip
NumberOfShots Tip
1 2
2 3
4 5
5 9
6 14
7 18
8 25
9 42
10 100
@doron2402
doron2402 / Tip_prediction_multiple_linear_regression.r
Last active October 28, 2017 05:13
Multiple Linear Regression Predict Tip
# Multiple Linear Regression
# Importing the dataset
dataset = read.csv('tip.csv')
# Encoding categorical data, in this case country
dataset$Country = factor(dataset$Country,
levels = c('USA', 'England', 'France', 'Israel', 'Italy'),
labels = c(1, 2, 3, 4, 5))