Skip to content

Instantly share code, notes, and snippets.

View franchb's full-sized avatar
🎯
Focusing

Eliah Rusin franchb

🎯
Focusing
View GitHub Profile
@franchb
franchb / domains_typos.py
Created August 30, 2018 07:44
Check typos in domain names based on Levenshtein distance
import pandas as pd
import Levenshtein as lev
import numpy as np
white_domains = [
'gmail.com',
'yahoo.com',
'icloud.com',
'mail.ru',
'yandex.ru',

Install PostgreSQL 10 on Ubuntu

This is a quick guide to install PostgreSQL 10 - tested on Ubuntu 16.04 but likely can be used for Ubuntu 14.04 and 17.04 as well, with one minor modification detailed below.

(Optional) Uninstall other versions of postgres

To make life simple, remove all other versions of Postgres. Obviously not required, but again, makes life simple.

dpkg -l | grep postgres
@franchb
franchb / go-chromeless-init.go
Created April 2, 2018 09:42
Go chromeless init
/* // create context
ctxt, cancel := context.WithCancel(context.Background())
defer cancel()
var options chromedp.Option
options = chromedp.WithRunnerOptions(
runner.HeadlessPathPort(pathBrowser, 9222),
runner.UserDataDir("D:\\TEMP"),
runner.Flag("headless", true),
runner.Flag("disable-gpu", true),
@franchb
franchb / deadlock-go
Created March 24, 2018 15:10
middleware deadlock go
package main
import (
"log"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-redis/redis"
"github.com/ulule/limiter"
mgin "github.com/ulule/limiter/drivers/middleware/gin"
@franchb
franchb / useragents2018.txt
Last active May 13, 2018 19:59
Actual User-Agent strings (April 2018 useragent)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36 OPR/51.0.2830.55
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/64.0.3282.167 Chrome/64.0.3282.167 Safari/537.36
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:59.0) Gecko/20100101 Firefox/59.0
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like G
Create HADOOP_HOME environment variable pointing to your installation folder selected above.
Without admin:
$env:HADOOP_HOME = "D:\Tools\Hadoop"
With admin:
[Environment]::SetEnvironmentVariable("HADOOP_HOME", "D:\Tools\Hadoop", "Machine")
Add Hadoop bin folder to your Windows Path variable as %HADOOP_HOME%\bin.
@franchb
franchb / gist:f5551a1cd7394800df236c0843d89b59
Created March 14, 2018 11:47
PowerShell csv fast view
Import-Csv -Delimiter ‰ an_bizinvest_for_test.csv |Out-GridView
@franchb
franchb / sdev-calc.php
Created March 14, 2018 10:28
Standart deviation for in-system calculation
$this->addFunction('stats_standard_deviation',
function(array $a, $sample = false) {
$n = count($a);
if ($n === 0) {
return 0;
}
if ($sample && $n === 1) {
return 0;
}
$mean = array_sum($a) / $n;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@franchb
franchb / pandas_chunks.py
Created March 5, 2018 13:25
chunks pandas
chunksize = 500
chunks = []
for chunk in pd.read_csv('pizza.csv', chunksize=chunksize):
# Do stuff...
chunks.append(chunk)
df = pd.concat(chunks, axis=0)