Skip to content

Instantly share code, notes, and snippets.

View okovalov's full-sized avatar
🏠
Working from home

Oleksandr Kovalov okovalov

🏠
Working from home
View GitHub Profile
@okovalov
okovalov / pre-commit
Last active October 6, 2016 14:55 — forked from CamdenSegal/pre-commit
Run phpunit pre-commit stop commit if failed.
#!/usr/bin/php
<?php
## SETUP
$isPhpCsPass = false;
$isPhpMdPass = false;
$isPhpUnitPass = false;
## PHPCS
@okovalov
okovalov / sample.js
Created September 9, 2016 17:39 — forked from chrisabrams/sample.js
Bluebird promise chain example
Promise = require('bluebird')
var A = function() {
return new Promise(function(resolve, reject) {
var result = 'A is done'
console.log(result)
resolve(result);
})
Hi guys. Recently I had a situation when a certain directory had a few more sub-directories, and
I needed to perform an identical list of actions for each of those sub-directories and doing that
manually by changing the current directory and repeatedly executing same commands was quite annoying
so I decided to spend half an hour and create a bash script for that purpose.
A particular example of the situation I had was having several virtual machines located accordingly
in ~/Boxes/serverOne ~/Boxes/serverTwo ~/Boxes/serverThree (I was testing ansible and was recreating and destroying vms).
This script asks for the confirmation as well.
#!/bin/bash
if [ -z "$1" ]
then
echo "No destination path is given"
exit 1
fi
if [ -z "$2" ]
then
from __future__ import with_statement
from fabric.api import local, env, settings, abort, run, cd
from fabric.contrib.console import confirm
import time
# Please create this directory on your production server
code_dir='/var/www/deploy-stage'
# Please make sure this directory exists and contains uploaded files
# most of the cases it is a good idea to keep your uploads apart from your source code
@okovalov
okovalov / gist:1207185e1d93567f8470e41f9405ad26
Created September 8, 2016 16:55 — forked from robertfyffe/gist:8315921
HTML: Starting Template
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title></title>
<link rel="stylehsheet" href="">
</head>
<body>
</body>
To be able to use Fabric for deploy you must have some things done:
- you need to be able to ssh to the server where the deployemnt is meant to be done.
- your Python version should match a certain required one
- you must have `pip` installed
- you must have `virtualenv` installed
- you must have `fabric` installed inside your virtual environment (please read about virtual env below)
Note about SSH: Basically Fabric uses ssh to connect to the sever so before you even
start with Fabbric please make sure your computer (user) public key is added to the
server's authorized hosts and you are able to ssh to the server without prompting
Following these instructions you would get three virtual machines , whereas one would be a server (ansible machine)
from where ansible would install software into two remaining virtual machines (destination servers).
Prerequsets (installed on a host machine):
- virtual box
- vagrant
List of software which will be installed on the destination servers (basic list, some dependencies will be installed as well):
- git
@okovalov
okovalov / gist:7a233858653e69b64bf4d5c23adb3f60
Created September 1, 2016 20:20 — forked from sgergely/gist:3793166
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
@okovalov
okovalov / ant-composer.xml
Created August 22, 2016 17:03 — forked from cpliakas/ant-composer.xml
Apache Ant tagets for Composer commands.
<?xml version="1.0" encoding="UTF-8"?>
<project name="Composer Targets" default="build">
<property name="builddir" value="${basedir}/build"/>
<property name="composer" value="${builddir}/composer.phar"/>
<target name="php-check">
<condition property="php" value="php">
<not>
<isset property="${php}"/>