Skip to content

Instantly share code, notes, and snippets.

View wingrime's full-sized avatar

Alexsey Shestacov wingrime

View GitHub Profile
@wingrime
wingrime / SimpleHTTPServerWithUpload.py
Created July 20, 2021 11:29 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
## For blog.example.com subdomain
server {
listen 80;
listen [::]:80;
root /var/www/blog.example.com;
index index.html;
server_name blog.example.com;
}
## For fakenews.com domain
traefik:
image: traefik:latest
command: --docker
ports:
- "80:80" 6
- "443:443"
labels:
- "traefik.enable=true"
- "traefik.backend=dashboard"
- "traefik.frontend.rule=Host:traefik-gitea.mydomain.com"
version: "2"
services:
gitea-app:
image: gitea/gitea:latest
container_name: gitea-app
environment:
- USER_UID=1000
- USER_GID=1000
- ROOT_URL=http://gitea:3000
@wingrime
wingrime / backoff.cs
Created May 27, 2019 08:59
C# exponential backoff
public static class Retry
{
public static async Task<T> DoAsync<T>(Func<Task<T>> action,
Func<T, bool> validateResult = null,
int maxRetries = 10, int maxDelayMilliseconds = 2000, int delayMilliseconds = 200)
{
var backoff = new ExponentialBackoff(delayMilliseconds, maxDelayMilliseconds);
var exceptions = new List<Exception>();
@wingrime
wingrime / rand-pass.bash
Last active January 4, 2019 11:55
Password random
#1
openssl rand -base64 32
#2
date | md5sum
upstream django_app {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name demo.gatos.io;
access_log /var/log/nginx/app.log;
@wingrime
wingrime / linux-trafic.bash
Created November 21, 2018 09:26
linux trafic monitor
function humanValue()
{
h=( '' K M G T P )
i=1; v=$(( $1 * 8 ))
while [ $v -gt $(( 1 << 10 * i )) ]; do let i++; done;
echo -n "$(( $v >> 10 * --i )) ${h[i]}b/s";
}
ifaces=$(ip addr | grep -E "^[0-9]:" | cut -d" " -f2 | tr -d \:)
declare -A RX2 TX2;
while sleep 1;
@wingrime
wingrime / yeti_rank.py
Created June 22, 2018 12:42
Catboost with yeti-rank
import mmh3
import pandas as pd
def get_positive_hash(x):
s = " ".join(get_unique_tokens(x))
return mmh3.hash(s) % 2**31
df['group_id'] = df['query_string'].apply(get_positive_hash )
query_groups = df.groupby("group_id")
@wingrime
wingrime / sql-mongo_comparison.md
Created April 8, 2018 20:23 — forked from aponxi/sql-mongo_comparison.md
MongoDb Cheat Sheets

SQL to MongoDB Mapping Chart

SQL to MongoDB Mapping Chart

In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.

Executables

The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.