Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
Unicorns engineering!

Dmitriy Paunin paunin

🦄
Unicorns engineering!
View GitHub Profile
@paunin
paunin / organize.sh
Last active Feb 28, 2020
Organizing exported from *.photoslibrary pictures
View organize.sh
#!env bash
#https://gist.github.com/paunin/e4f9f01a1cfcfc99828b75d4fd29ac96
# Export files from apple *.photoslibrary (File->Export Unmodified Original) with options "Subfolder Format = Moment Name"
# Run the script against the folder where the images were exported.
# Subfolders will be renamed from format `{MOMENT_NAME}, d Month YYYY` to `YYYY.mm.dd[{MOMENT_NAME}]`
# example: `Da Lat - Phường 8 - Tỉnh Lâm Đồng, 3 May 2016` => 2016.05.03[Da Lat - Phường 8 - Tỉnh Lâm Đồng]
DIR=$1
if [[ "$DIR" == "" ]]; then
echo "Error: please pass \$1 for directory to organize! "
View docker-compose-test.sh
#!/bin/bash
DOCKER_COMPOSE_FILES='docker-compose1.yml,docker-compose2.yml'
DOCKER_COMPOSE_UP_MODE=1 #1|0
DOCKER_COMPOSE_UP_LOG_FILE='/tmp/log.txt'
DOCKER_COMPOSE_BUILD_OPTIONS="" #any options for `docker-compose build`
DOCKER_COMPOSE_UP_OPTIONS="" #any options for `docker-compose up`
DOCKER_COMPOSE_RUN_OPTIONS="" #any options for `docker-compose run`
TEST_CONTAINERS="application1=/test.sh,application2=/test2.sh"
##### get port remover #####
View WeekIntervalScheduler.php
<?php
/**
* Class WeekTimestamp
*/
final class WeekTimestamp
{
const SECONDS_IN_MINUTE = 60;
const SECONDS_IN_HOUR = self::SECONDS_IN_MINUTE * 60;
const SECONDS_IN_DAY = self::SECONDS_IN_HOUR * 24;
View env-to-export.sh
SED_EXPR='s/^\([A-Z0-9_]*\)=\(.*\)$/export \1="\2"/g'
printenv | sed "$SED_EXPR" > $ENV_FILE
@paunin
paunin / config-changer.sh
Last active Dec 29, 2016
Simple config(.conf or .ini) changer
View config-changer.sh
#CONFIGS= #in format variable1:value1[,variable2:value2[,...]]
#CONFIG_FILE= #path to file
echo "
#------------------------------------------------------------------------------
# AUTOGENERATED
#------------------------------------------------------------------------------
" >> $CONFIG_FILE
@paunin
paunin / coverage-checker.php
Last active Dec 12, 2015
phpunit-covergae-checker.php
View coverage-checker.php
#!/usr/bin/env php
<?php
// http://ocramius.github.io/blog/automated-code-coverage-check-for-github-pull-requests-with-travis/
$inputFile = $argv[1];
$percentage = min(100, max(0, (int) $argv[2]));
if (!file_exists($inputFile)) {
throw new InvalidArgumentException('Invalid input file provided');
}
if (!$percentage) {
throw new InvalidArgumentException('An integer checked percentage must be given as second parameter');
@paunin
paunin / Compare.php
Last active Aug 29, 2015
Comarer 2 files
View Compare.php
<?php
namespace Compare;
/**
* нужно написать программу которая сравнивает два текстовых файла (терабайтных)
* и выводит в третий файл строки, которые есть в первом, но нет во втором.
*
* To run this utility just run `php ./Compare.php input_file1.txt input_file2.txt output_file.txt`
*/
class Compare
@paunin
paunin / callgraph.php
Last active Sep 28, 2018
xhprof usages
View callgraph.php
<?php
require_once(__DIR__.'/vendor/XhProf/xhprof_html/callgraph.php');
View frontend-app_angtest.html
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script src="https://code.angularjs.org/1.2.26/angular-route.js"></script>
<script src="app.js"></script>
</head>
<body ng-app="app2">
@paunin
paunin / prepare-commit-msg.sh
Last active Aug 29, 2015
git hook prepare-commit-msg
View prepare-commit-msg.sh
#!/bin/sh
# @author paunin
# @url http://paunin.com
# @require jq[http://stedolan.github.io/jq/]
# @require curl
RM_KEY=""
RM_URL=""