Skip to content

Instantly share code, notes, and snippets.

@svdmitrij
svdmitrij / elixir.yml
Created April 15, 2021 13:41
Github action for elixir
name: Elixir CI
on: push
jobs:
test:
runs-on: ubuntu-18.04
services:
postgres:
image: postgres:11
@svdmitrij
svdmitrij / docker-compose.yaml
Created February 23, 2021 19:21
Zabbix server with nginx and postgresql
version: '3.5'
services:
zabbix-server:
image: zabbix/zabbix-server-pgsql:centos-5.2-latest
ports:
- "10051:10051"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro
@svdmitrij
svdmitrij / gist:fd012e1e58e437937f60469ad95c236d
Created May 31, 2018 06:33
nginx reverse proxy for docker containers
### /etc/nginx/sites-enabled/default ###
server {
listen 80;
listen [::]:80;
server_name mysite.com;
include /etc/nginx/xtra/server.conf;
---
-
hosts: remote_host
gather_facts: no
name: "Testing synchronize"
vars:
start_time: "{{ lookup('pipe','date') }}"
test_files:
- test1
- test2
<?php
$ch = curl_init('https://www.howsmyssl.com/a/check');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data);
echo "<pre>TLS version: " . $json->tls_version . "</pre>\n";
@svdmitrij
svdmitrij / run_website.bat
Last active November 21, 2015 16:41
Run apache2 with php, mysql, redis on windows box. "Docker Toolbox" must be installed and mariadb container created (by hand in kitematic).
cd "C:\Program Files\Docker Toolbox\kitematic"
set name=games
set DOCKER_CERT_PATH=C:\Users\dmitry\.docker\machine\machines\default
set DOCKER_HOST=tcp://192.168.99.100:2376
set DOCKER_TLS_VERIFY=1
docker start mariadb
docker rm -f %name%-redis
docker rm -f %name%
docker run -d --name %name%-redis redis
docker run -d -p 80:80 --name %name% --link %name%-redis:redis
@svdmitrij
svdmitrij / fix_line_endings
Last active November 14, 2015 10:18
Fix line endings problem when work on windows and linux (when lot of messages The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in...)
#!/usr/bin/env bash
# https://help.github.com/articles/dealing-with-line-endings/#refreshing-a-repository-after-changing-line-endings
git add . -u
git commit -m "Saving files before refreshing line endings"
git rm --cached -r .
git reset --hard
git add .
git commit -m "Normalize all the line endings"
@svdmitrij
svdmitrij / pre-commit
Last active August 29, 2015 14:25
remove trailing spaces before commit
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@svdmitrij
svdmitrij / git_archive.sh
Last active December 13, 2018 13:21
Create archive from diff between two commits
#!/usr/bin/env bash
firstCommit=$1
secondCommit=$2
if [[ -z $firstCommit || -z secondCommit ]]; then
echo "Usage: $0 first_commit_sha second_commit_sha"
fi
git archive --format=tar.gz -o changes.tgz "$secondCommit" $(git diff --name-only "$firstCommit")
@svdmitrij
svdmitrij / sort_array_by_value.php
Last active August 29, 2015 14:14
Function sorting array of arrays by value one of fields
<?php
function sort_array_by_key($params)
{
$sort_orders = array('asc' => SORT_ASC, 'desc' => SORT_DESC);
$sort_order = $sort_orders[$params['order']];
$field = $params['key'];
$array = $params['array'];
$field_array = array();
foreach ($array as $key => $row)