Skip to content

Instantly share code, notes, and snippets.

View dmkuznetsov's full-sized avatar
🦌

Dmitry Kuznetsov dmkuznetsov

🦌
View GitHub Profile
#!/usr/bin/env php
<?php
$paths = [
'masterlocal' => '/www/master.local/project/master/app',
'crm.local' => '/www/crm.local/project/master/app'
];
foreach ($paths as $projectName => $appDir) {
$appDir = rtrim($appDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
@dmkuznetsov
dmkuznetsov / selectel.php
Created March 14, 2015 14:58
Selectel flysystem
<?php
use OpenCloud\OpenStack;
use League\Flysystem\Filesystem;
use League\Flysystem\Rackspace\RackspaceAdapter;
$client = new OpenStack('https://auth.selcdn.ru', [
'username' => '...',
'password' => '...'
]);
@dmkuznetsov
dmkuznetsov / thumb.php
Last active February 3, 2024 00:03
Thumbnails on the fly with cache from local and remote images
<?php
/**
* @description
* Thumbnails on the fly with cache from local and remote images
*
* Parameters:
* image absolute path of local image starting with "/" (e.g. /images/toast.jpg)
* width width of final image in pixels (e.g. 700)
* height height of final image in pixels (e.g. 700)
* nocache (optional) does not read image from the cache
@dmkuznetsov
dmkuznetsov / JSONP.js
Created November 17, 2015 13:30 — forked from icodeforlove/JSONP.js
simple JSONP support
/**
* simple JSONP support
*
* JSONP.get('https://api.github.com/gists/1431613', function (data) { console.log(data); });
* JSONP.get('https://api.github.com/gists/1431613', {}, function (data) { console.log(data); });
*
* gist: https://gist.github.com/gists/1431613
*/
var JSONP = (function (document) {
var requests = 0,
@dmkuznetsov
dmkuznetsov / .bash_profile
Last active November 21, 2018 07:38
.bash_profile
# ~/.bashrc: executed by bash(1) for non-login shells. see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# unset this because of nasty OS X bug with annoying message:
# "dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid"
# this is not correct, but Apple is too lazy to fix this
unset DYLD_LIBRARY_PATH
#!/bin/bash
# Daniel Verner
# CarrotPlant LLC
# 2011
# Backup each mysql databases into a different file, rather than one big file
# Optionally files can be gzipped (dbname.gz)
#
# Usage: dump_all_databases [ -u username -o output_dir -z ]
#
# -u username to connect mysql server
#!/bin/bash
#
# Yandex.Disk backup script v1.0 by Sergey Lukonin (neblog.info)
#
# # # # # # # # # # НАСТРОЙКИ БЕКАПА MYSQL # # # # # # # # # #
# Сервер БД
MYSQL_SERVER=mysql.some-server.ru
# Юзер, под которым будем делать бекап доступных баз, руту mysql обычно доступны все БД, отдельному пользователю обычно доступна БД конкретного проекта
#/bin/bash
cd /test_last/
if lsof -Pi :7772 -sTCP:LISTEN -t >/dev/nul; then
echo "Working"
else
echo "Not working.Starting..."
python3 bot.py
fi
<?php
//$retentionByMonth = [100, 20, 25, 20]; // 3
$retentionByMonth = [100, 80, 75, 72, 70]; // 4
//$usersByMonth = array_fill(0, 12 * 10, 4000);
$usersByMonth = array_fill(0, 12 * 10, 1000);
$fill = $retentionByMonth[count($retentionByMonth) - 1];
for ($i = 0, $c = count($usersByMonth) - count($retentionByMonth); $i < $c; $i++) {
$retentionByMonth[] = $fill;
@dmkuznetsov
dmkuznetsov / avatimer.php
Last active July 18, 2019 18:20
Avatimer - change your telegram's profile photo (see https://blog.kuznetsov.io/post/186361320788/avatimer)
<?php
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
$telegram = new \danog\MadelineProto\API('session.madeline');
$telegram->start();