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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@saippuakauppias
saippuakauppias / share.js
Created September 1, 2015 10:43
Share text or link in vk (vkontakte, vk.com), fb (facebook, facebook.com), tw (twitter, twitter.com)
/********************************************************************
*
* Share social http://habrahabr.ru/post/156185/
*
*********************************************************************/
function Share(purl, ptitle, pimg, text) {
'use strict';
this.purl = purl;
this.ptitle = ptitle;
@saippuakauppias
saippuakauppias / gist:89b9acce52328d0fc635
Last active January 15, 2020 21:41
create video from one image (short file size, long video) [ffmpeg]
ffmpeg -loop 1 -i image.jpg -c:v libx264 -preset ultrafast -t 360 -crf 1 -vf "fps=1,scale=640:480" video.mp4
# -i image.jpg
# image file
# -t 360
# video time
# video.mp4
# result video file
@saippuakauppias
saippuakauppias / getUserRealIP.php
Created October 12, 2015 00:07
Определить реальный IP-адрес пользователя, выкинуть прокси и взять настоящий IP (если это возможно).
if (!function_exists('getUserRealIP')) {
function getUserRealIP() {
$realIP = null;
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
if(strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ".")>0 && strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ",")>=0) {
$forwardedIPArray = explode(",", $_SERVER['HTTP_X_FORWARDED_FOR']);
$realIP = trim($forwardedIPArray[0]);
} elseif (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ".")>0 && strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ",")===false) {
$realIP = trim($_SERVER['HTTP_X_FORWARDED_FOR']);
}
@saippuakauppias
saippuakauppias / find_unused_css_selectors.php
Last active January 5, 2022 12:56
Beautify & Tidy cloned html template
<?php
$html_content = get_content_by_pattern(__DIR__ . '/template/index_beautify.htm*');
//$html_content .= get_content_by_pattern(__DIR__ . '/template/errors/*.twig');
$css_content = get_content_by_pattern(__DIR__ . '/template/index_files/tidy.max.cs*');
$html_content = preg_replace('#\{\{[^\}]+\}\}#iUs', '', $html_content);
$html_content = preg_replace('#\{%[^\}%]+%\}#iUs', '', $html_content);
preg_match_all('#class=["\']{1}([^"\']+)["\']{1}#iUs', $html_content, $matches);
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 \
@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

@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 / 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 / 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