Skip to content

Instantly share code, notes, and snippets.

View Sonique's full-sized avatar

Vitaly Larchenkov Sonique

View GitHub Profile
@Sonique
Sonique / git-post-receive-master-to-production-hook.sh
Last active August 29, 2015 14:03
Put files from master branch to production folder
#!/bin/bash
echo "================================="
echo "Post-receive script: START"
WORK_TREE="/site/folder"
GIT_DIR="/home/git/repos/site.git"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ $branch == "master" ]; then
echo "Branch determined as master."
@Sonique
Sonique / simple_timer.java
Last active August 29, 2015 14:13
Simple Java code execution timer
// Basic
long start = System.currentTimeMillis();

long end = System.currentTimeMillis();
// Stopwatch
Stopwatch stopwatch = new Stopwatch();
double time = stopwatch.elapsedTime();
// #java #timer #stopwatch
@Sonique
Sonique / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# Script dir for script relative path
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
@Sonique
Sonique / shri.js
Last active August 29, 2015 14:26 — forked from verkholantsev/shri.js
/**
* Реализация API, не изменяйте ее
* @param {string} url
* @param {function} callback
*/
function getData(url, callback) {
var RESPONSES = {
'/countries': [
{name: 'Cameroon', continent: 'Africa'},
{name :'Fiji Islands', continent: 'Oceania'},
@Sonique
Sonique / mysqldump.bash
Last active December 21, 2015 06:58
MySQL backup from command line
mysqldump -u mysqluser -p mysqldatabase | gzip > db_backup.sql.gz
// #mysql #bash #terminal
@Sonique
Sonique / Laravel Resource.xml
Last active December 21, 2015 14:08 — forked from JeffreyWay/snippet.xml
Laravel Resource - Sublime Text 2 Snippet
<snippet>
<content><![CDATA[
// ${1/(.)/\u\1/}s Resource
Route::get('${1}s', array('as' => '${1}s', 'uses' => '${1}s@index'));
Route::get('${1}s/(:any)', array('as' => '${1}', 'uses' => '${1}s@show'));
Route::get('${1}s/new', array('as' => 'new_${1}', 'uses' => '${1}s@new'));
Route::get('${1}s/(:any)/edit', array('as' => 'edit_${1}', 'uses' => '${1}s@edit'));
Route::post('${1}s', '${1}s@create');
Route::put('${1}s/(:any)', '${1}s@update');
Route::delete('${1}s/(:any)', '${1}s@destroy');
@Sonique
Sonique / find_string_in_files.bash
Last active December 21, 2015 16:28
Find string in files
find . -name "*.txt" -exec grep -il "Word" {} \;
// #linux #bash
@Sonique
Sonique / Download via scp
Last active December 22, 2015 05:49
Download via SCP
scp server:~/remote/somefile.txt .
@Sonique
Sonique / gist:7e65abcae021027beabf
Created June 22, 2014 03:20
Laravel .gitignore extended
# System
.DS_Store
Thumbs.db
.Trashes
._*
Icon
.AppleDouble
.LSOverride
# Editors