Skip to content

Instantly share code, notes, and snippets.

View mamuz's full-sized avatar

Marco Muths mamuz

View GitHub Profile
@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
@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 / 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 / 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-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 / mysql-dump.sh
Last active December 16, 2015 13:29
dump database with mysql
# export
# cd /usr/local/bin/
mysqldump -username -password databasename > /home/user/directory/databasename.sql
# import
mysqladmin -u username -p create databasename
# cd /usr/bin
mysql -u username -p databasename < /home/user/directory/databasename.sql
@mamuz
mamuz / secureRegEx
Last active December 16, 2015 18:00
RegExpressions to find vulnerabilities
# SQL-Injections
.*mysql_query\(.*\s*\$_(GET|POST|REQUEST|COOKIE)).*
# reflective xss
(echo|print).*\$_(GET|POST|COOKIE|REQUEST)
@mamuz
mamuz / tokenGenerator.php
Last active December 16, 2015 18:00
Secure token generator
<?php
$token = md5(
microtime() .
rand() .
serialize(shuffle($GLOBALS))
);
@mamuz
mamuz / escapeShell.php
Last active December 16, 2015 18:00
Php functions to escape arguments for shell executes
<?php
escapeshellcmd();
escapeshellarg();
@mamuz
mamuz / .dockerignore
Last active March 12, 2017 13:17
global dockerignore
.DS_Store
Desktop.ini
.idea
*~
*.swp
._*
*.pyc
Thumbs.db
.Spotlight-V100
.Trashes