Skip to content

Instantly share code, notes, and snippets.

View mamuz's full-sized avatar

Marco Muths mamuz

View GitHub Profile
@mamuz
mamuz / ssh-rsync.sh
Last active December 16, 2015 13:29
ssh rsync
rsync -aWHvz --delete -e "ssh -i /home/user/.ssh/mykey" /path/to/source /path/to/destination
@mamuz
mamuz / ConvertError2Exception.php
Last active December 16, 2015 12:29
Converting php errors into an exception
<?php
class ConvertError2Exception
{
/**
* Error string.
* Is null if there was no error
*
* @var string
*/
@mamuz
mamuz / ssh-push.sh
Last active December 16, 2015 12:28
#!/bin/bash
# configs
SSH_USR='myuser'
DIR_SRC='/update/directory'
# destinations
SERVER1[0]='custom-app1'
SERVER1[1]='custom-app2'
SERVER1[2]='custom-app3'
@mamuz
mamuz / mysql-helper.sql
Last active December 16, 2015 12:19
Helper snippets
# Remove row duplicates
SELECT DISTINCTROW * INTO doublettesTable FROM uniqueTable;
# Count column duplicates
SELECT col, count(*) AS cnt
FROM table
GROUP BY col
HAVING cnt > 1;
# Count duplicates with two cols
@mamuz
mamuz / Rename local and remote branch
Created August 24, 2015 09:00
git-rename-branch.sh
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote