Skip to content

Instantly share code, notes, and snippets.

View deeravenger's full-sized avatar
🦌

Dmitry Kuznetsov deeravenger

🦌
View GitHub Profile
@deeravenger
deeravenger / timelimit.sh
Last active February 12, 2020 07:45
Контроль времени выполнения скрипта
#!/bin/bash
#
# The Bash shell script executes a command with a time-out.
# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal
# is blocked, then the subsequent SIGKILL (9) terminates it.
#
# Based on the Bash documentation example.
# Hello Chet,
# please find attached a "little easier" :-) to comprehend
@deeravenger
deeravenger / 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();
<?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;
#/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
#!/bin/bash
#
# Yandex.Disk backup script v1.0 by Sergey Lukonin (neblog.info)
#
# # # # # # # # # # НАСТРОЙКИ БЕКАПА MYSQL # # # # # # # # # #
# Сервер БД
MYSQL_SERVER=mysql.some-server.ru
# Юзер, под которым будем делать бекап доступных баз, руту mysql обычно доступны все БД, отдельному пользователю обычно доступна БД конкретного проекта
#!/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
@deeravenger
deeravenger / .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
@deeravenger
deeravenger / 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,
@deeravenger
deeravenger / 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
@deeravenger
deeravenger / 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' => '...'
]);