Skip to content

Instantly share code, notes, and snippets.

View saippuakauppias's full-sized avatar
🤔
/dev/random

Denis Veselov saippuakauppias

🤔
/dev/random
View GitHub Profile
@saippuakauppias
saippuakauppias / app.py
Created November 16, 2020 20:22
Code Review Test Case
"""
$ pip install flask sqlalchemy psycopg2-binary
$ FLASK_ENV=development FLASK_APP=app.py flask run
"""
import random
from flask import Flask, abort, request, views
from sqlalchemy import Column, MetaData, String, Table, create_engine, select
from string import ascii_letters
from typing import Optional
@saippuakauppias
saippuakauppias / redis_bench_hset-set.py
Last active August 9, 2020 08:33
Testing storage of millions of keys in Redis
#! /usr/bin/env python
"""
Original: https://gist.github.com/mikeyk/1329319
https://instagram-engineering.com/storing-hundreds-of-millions-of-simple-key-value-pairs-in-redis-1091ae80f74c
➜ time python benchmarks/redis_hset_set.py normal
Set: 79.34 sec
Size: 92.6 MB
Get: 73.74 sec
<?php
function is_https() {
// dont use `filter_input(INPUT_SERVER, '...')`:
// https://github.com/xwp/stream/issues/254
$https = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : '';
if (!empty($https)) {
$https = strtolower($https);
if ($https == 'on') {
return true;
cd /var
find . -type d |
while
read line
do
echo "$( find "$line" -maxdepth 1 | wc -l) $line"
done |
sort -rn | less
@saippuakauppias
saippuakauppias / ydsk.py
Created January 6, 2020 10:18
Yandex.Disk upload file example
import argparse
import yadisk # https://pypi.org/project/yadisk/
def check_auth(y):
if y.check_token():
print("Token valid")
else:
raise Exception('Token invalid!')
@saippuakauppias
saippuakauppias / ngrok.yml
Created November 29, 2019 12:12
TensorBoard + ngrok tunnel: access to tf logs from anywhere
authtoken: <copy key from https://dashboard.ngrok.com/auth>
log_level: error
log: stderr
@saippuakauppias
saippuakauppias / ubuntu-php7-install.sh
Created November 20, 2019 16:32
Ubuntu 14.04 PHP7 (Install from Source)
#!/usr/bin/env bash
# removed copy from https://gist.github.com/jaswrks/d4fc3d3808001c7836fa
# Author: Jason Caldwell (@jaswrks)
sudo -i;
apt-get update;
apt-get install --yes \
@saippuakauppias
saippuakauppias / patch-brew-lmdb.rb
Last active November 13, 2019 17:34
Fix 'MDB_MAP_FULL: Environment mapsize limit reached' in macOS homebrew LMDB installation [PHP7]
16a17,18
> patch :DATA
>
28a31,55
>
> __END__
> diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c
> index 692feaa..809ab9e 100644
> --- a/libraries/liblmdb/mdb.c
> +++ b/libraries/liblmdb/mdb.c
@saippuakauppias
saippuakauppias / Build PHP7 in brew.md
Last active November 30, 2022 22:09
Build PHP7 with lmdb support (or another needed) on MacOS in Homebrew

This method is suitable for compiling PHP from the source code not only for LMDB, but also through it you can perform any kind of configuration before installation.

Install lmdb

Unfortunately, it is currently not possible to change the database size and it is fixed at a size of 1MB (this restriction is defined in the library itself). To get around this, you need to patch the library itself before installation. Look here as: https://gist.github.com/saippuakauppias/95b6f7b139b3d117b7dac4aeead9f5b4

Proper way (not worked)

Build php7 from sources

ARG UBUNTU_VERSION=16.04
FROM nvidia/cuda:9.0-base-ubuntu${UBUNTU_VERSION}
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cuda-command-line-tools-9-0 \
cuda-cublas-dev-9-0 \
cuda-cudart-dev-9-0 \
cuda-cufft-dev-9-0 \
cuda-curand-dev-9-0 \