Skip to content

Instantly share code, notes, and snippets.

View littlefuntik's full-sized avatar

Hryhorii Furletov littlefuntik

View GitHub Profile
@littlefuntik
littlefuntik / results.txt
Last active December 13, 2016 21:33
Tests UNIQUE index (char(80) and sha256 => int)
>>> Start test (1000 records)
Test time: 0.15334296226501 seconds, 0.37MB
Table: test
Rows: 1000
Data_length: 0.02 MB
Index_length: 0.02 MB
Table: test_sha256
Rows: 1000
Data_length: 0.02 MB
Index_length: 0.02 MB
@littlefuntik
littlefuntik / zoneinfo.tree.output
Created January 30, 2017 19:49
linux zoneinfo file system (alpine: "tree -a /usr/share/zoneinfo/")
├── Africa
│   ├── Abidjan
│   ├── Accra
│   ├── Addis_Ababa
│   ├── Algiers
│   ├── Asmara
│   ├── Asmera
│   ├── Bamako
│   ├── Bangui
│   ├── Banjul
@littlefuntik
littlefuntik / Dockerfile
Last active November 15, 2023 07:16
alpine linux -- make install -- php-fpm 7.1.1 + geoip-1.1.1 + xdebug-2.5.0
## Container console commands (Windows: PowerShell)
# docker build --no-cache -t php:7.1
# docker run --name test-php -v "${PWD}:/var/www:rw" -p "9001:9000" -d php:7.1
# docker exec -ti php:7.1 /bin/sh
# docker rm test-php --force
# docker rmi php:7.1
FROM alpine
RUN \
addgroup -g 82 -S www-data && adduser -u 82 -D -S -G www-data www-data && \
<?php
/*
file "uk.ini" content:
[section1]
value1={{.REPLACE1}}
[section2]
value0={{.REPLACE2}}
test=test
@littlefuntik
littlefuntik / env_docker_container.sh
Last active March 14, 2023 23:47
Get runned docker container initial environments variables.
#!/bin/sh
DOCKER_CONTAINER_NAME_OR_ID="$1"
if [[ ! $DOCKER_CONTAINER_NAME_OR_ID ]]; then
echo "First argument must be RUNNED(!) docker container name or ID."
exit 1
fi
docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' $DOCKER_CONTAINER_NAME_OR_ID

Устанавливаем консольную утилиту под названием jq для парсинга JSON строк.

sudo apt-get install -y jq
# ключ -y означает, что нам не придется отвечать на вопросы - авто-соглашение, interactive=no

Выполним в консоли скрипт для установки нужных нам переменных окружения для работы с Google AdWords API.

@littlefuntik
littlefuntik / combo.php
Last active December 7, 2017 13:27
Combinatorics: permutations + right to left; product. Like python itertools.
<?php
namespace combo;
use InvalidArgumentException;
use OutOfBoundsException;
function py_range($start, $stop = null, $step = null)
{
if (null === $stop) {
@littlefuntik
littlefuntik / example.php
Last active October 30, 2017 16:50
Python function permutations in PHP language.
<?php
require 'permutations.php';
$timeStart = microtime(true);
$memoryStart = memory_get_usage();
$i = 0;
foreach (permutations(range(1, 3), 2) as $combo) {
@littlefuntik
littlefuntik / redis_flush_db.php
Last active March 14, 2023 23:47
FLUSH DB Redis simple PHP (stream socket client)
<?php
// config
$redis_host = getenv('REDIS_HOST') ?: '127.0.0.1';
$redis_port = getenv('REDIS_PORT') ?: '6379';
$redis_db = getenv('REDIS_DB_NAME') ?: '0';
// init
$redis_server = sprintf('%s:%d', $redis_host, $redis_port);
$redis_create_request = function ($args) {
/**
* @return {XMLHttpRequest|ActiveXObject}
*/
function request(options, callback) {
"use strict";
var method, url, headers, body, type, timeout, xhttp;
if (typeof options === "string") {
options = {"url": options};