1. curl --silent > ~/getssl ; chmod 700 ~/getssl
  2. ~/getssl -c
  3. openssl genrsa 4096 > ~/.getssl/account.key
  4. openssl dhparam -out ~/.getssl/dhparam.pem 4096
  5. mkdir -p /var/www/
  6. echo "CA=\"\"
    RELOAD_CMD=\"service apache2 restart\"
    " > ~/.getssl/
  7. Apache configuration:

    SSLEngine on

    SSLCertificateFile /root/.getssl/
    SSLCertificateKeyFile /root/.getssl/
    SSLCertificateChainFile /root/.getssl/

    SSLOpenSSLConfCmd DHParameters “/root/.getssl/dhparam.pem”

    header set Strict-Transport-Security “max-age=31536000;”
    header set Content-Security-Policy-Report-Only “default-src https:; script-src https: ‘unsafe-eval’ ‘unsafe-inline’; style-src https: ‘unsafe-inline’; img-src https: data:; font-src https: data:; report-uri /csp-report”

  8. -OR- NGINX configuration:

    ssl on;

    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_session_cache shared:SSL:50m;
    ssl_prefer_server_ciphers on;

    ssl_dhparam /root/.getssl/dhparam.pem;

    ssl_certificate /root/.getssl/;
    ssl_certificate_key /root/.getssl/;

    add_header Strict-Transport-Security “max-age=31536000;”;
    add_header Content-Security-Policy-Report-Only “default-src https:; script-src https: ‘unsafe-eval’ ‘unsafe-inline’; style-src https: ‘unsafe-inline’; img-src https: data:; font-src https: data:; report-uri /csp-report”;

  9. ~/getssl

In cron (crontab -e) (Why?):
23 5 * * * /root/getssl -u -a -q
Continue reading

Share Button


git add . — adds everything to index
git commit -am "Comment" — makes commit of all changes with specific comment. (New files are NOT auto added!)
git checkout -- path/to/file — undoes uncommitted changes to specific file
git checkout -- . — same as above for full repository
git diff-tree --no-commit-id --name-only -r abcdef — lists names of files for a specific commit
git log -p filename — lists changes history for specific filename (provide . filename to see changes for whole project)
git diff — lists unstaged changes
git diff --cached — lists staged changes
git reset path/to/file — removes file from “Changes to be committed”
git clean -f — removes all unstaged files
git checkout changes -- /php/code.php — retrieves /php/code.php file from changes branch


git checkout -b new-branch — creates new branch with name “new-branch” and switches to it
git merge master — merges into current branch from branch with name “master”. Optional --no-commit can be passed in order not to commit after merge (In case you need some more changes for example)
git log new-branch..master — lists all commits on branch “master” which are not in branch “new-branch”
git branch -d branch-name — deletes branch


git remote add another git@localhost:/git/repo.git — creates new another remote
git remote rm origin — removes origin remote
git remote rename origin new-origin — renames origin remote to new-origin
git remote set-url origin git@localhost:/git/repo.git — changes url associated with origin remote


git stash list — list all stashes
git stash — stashes uncommitted changes
git stash save "Stash message" — stashes uncommitted changes with specific message
git stash save --keep-index "Stash not indexed" — same as above, but will only stash not added to index changes (Changes not staged for commit)
git stash pop — applies stashed changes (And removes stash state from stash list)
git stash apply — same as above, but doesn’t remove stash state from stash list
git stash clear — clear all stash states from stash list
git stash drop stash@\{0\} — deletes stash with stash@{0} name (From git stash list). Don’t forget to escape curly brackets!
git stash show -p stash@\{0\} — describes stash changes (Output similar to git diff)


git config --list — list all config values
git config config-key value — sets “value” as value for config key “config-key”
git config --unset config-key — deletes config key “config-key” and its value
git --edit — edit config as text document
--global option can be used for all config commands in order to access global config (Not current repository only)

Share Button

Users & groups

cat /etc/passwd – list system users
cat /etc/group – list system user groups
useradd user – create new user
passwd user – edit user password (Skip username to edit your own password)
usermod -g group user – changes user’s primary group
usermod -a -G group user – add existing user to secondary group


tar -zcf archive.tar.gz dir1/ dir2/subdir file.txt – create new archive with name archive.tar.gz, include dir1/, dir2/subdir, file.txt directories & files
tar -xf archive.tar.gz -C extract/to/dir – extract files from archive.tar.gz to extract/to/dir (Omit destination path & -C option to extract to same directory)


zip -r dir1/ dir/subdir file.txt – create new archive with name, include dir1/, dir2/subdir, file.txt directories & files
unzip -d extract/to/dir – extract files from to extract/to/dir (Omit destination path & -d option to extract to same directory)


dpkg --list | grep php – list installed packages, optionally filter by name with grep
apt-cache search kde – search for packages available to install
apt-get install firefox – install package
apt-get remove --purge skype – uninstall package and all of its configuration files (To retain configuration files, skip --purge option)
apt-get autoremove – remove all orphaned, not used packages (Packages, which were used as components for other packages, now all removed)


lsblk – list all devices (Including CD-Roms, USB flashes etc.) and mount points (If mounted)
mount /dev/sdb /mnt – mounts /dev/sdb/ device to /mnt path (Path must exist)
umount /dev/sdb – unmounts device


ps aux | grep nginx – list all running processes, optionally filter by name (Process name, command will be filtered) with grep
kill 123 – kill process with PID 123 (PID can be retrieved with ps aux)
pkill nginx – kill process by name


mysqldump --host=localhost --user=db_user --password=db_password db_name | gzip > db.sql.gz – creates dump of db_name database, logging in with provided credentials and gzips it to db.sql.gz file
zcat db.sql.gz | mysql --host=localhost --user=db_user --password=db_password db_name – imports gzipped database dump to db_name database

Share Button

Написал небольшой класс для работы с API сервиса

Пример использования

Для работы необходим XMLRPC клиент с (Прямая ссылка на

require '';
require 'AllPositions.php';

$apiKey = 'db124ffafb324aefb2352';//Ваш ключ API (Можно узнать здесь:

$api = new xf3\AllPositions($apiKey);
//Теперь у объекта $api можно вызвать любой метод API, вызовем get_project

$projectID = 8472097423;//ID проекта
$project = $api->get_project($projectID);

if ($project === null) {//При ошибке любая функция возвращает null
    echo 'API error occured: ' . $api->lastError();//Возвращает последнее сообщение ошибки
} else {
    echo 'Project name: "' . $project['name'] . '"';

Описание функций и возвращаемых значений можно найти на странице справки API

Для подключения через Composer, добавьте в require:
"xf3/allpositionsru": "dev-master"

Проект на github

Скачать .zip архив

Share Button

Very common situation when you have some long-running Php script that exceeds Php’s max_execution_time directive. The easiest way to overcome this limit is to increase it’s value:

In your .php script file:

< ?php 

ini_set('max_execution_time', 950);//950 seconds


set_time_limit(800);//800 seconds

Or in php.ini file:

max_execution_time=300;300 seconds

Note that in later example this limit will be used for EVERY script.

But the problem is that not always you have access to php.ini file (E.g. when using shared hosting) or overwriting of max_execution_time is not allowed for scripts.

In this case, possible solution is to divide script execution into parts limited by time execution (Like you can limit query results in MySql with help of LIMIT 20, 30 or similar).

I wrote a small class which makes code division a very simple thing.
Continue reading

Share Button