Skip to content

Instantly share code, notes, and snippets.

@ancho85
ancho85 / patchApplyFromSVN.sh
Created August 23, 2019 19:38
apply svn patch to git branch
#!/bin/bash -xv
(cd $1 && patch --binary --no-backup-if-mismatch -p0 ) < $2
# git diff
@ancho85
ancho85 / ahead-behind.sh
Created August 23, 2019 15:39
simple ahead behind git script
#!/bin/bash
ahead=$(git rev-list --count master..$1)
behind=$(git rev-list --count $1..master)
echo "Ahead $ahead, behind $behind"
@ancho85
ancho85 / patchGenByBranch.sh
Last active August 23, 2019 19:36
svn compatible patch generator from within smartgit (linux)
#!/bin/bash
#_branchname_=$(git -C $1 rev-parse --abbrev-ref HEAD)
_branchname_="${2/refs\/heads\/}"
_branchcommit_=$(git -C $1 show-ref --heads -s master)
_mastercommit_=$(git -C $1 merge-base master $_branchname_)
if [[ $_branchcommit_ == $_mastercommit_ ]]; then
echo "generating patch for $_branchname_"
_patch_path="$1/gitPlayero-$_branchname_.patch"
git -C $1 diff --text --relative --no-prefix --no-textconv --ignore-submodules --abbrev master..$_branchname_ '*.py' '*.xml' > $_patch_path
echo "$_patch_path" | sed 's#/#\\#g' | sed 's#.patch#\ #g' > /dev/clipboard
@ancho85
ancho85 / exclude
Created July 21, 2016 14:34
.gitignore inside git directory (.git/info/exclude)
*.data
*.log
*.patch
*.pyc
TEST-unittest*.xml
coverage_playero.xml
erv/demo.htm
force.sync
last_python_error.txt
listwindowreport.txt
@ancho85
ancho85 / attributes
Created July 21, 2016 14:33
.gitattribute inside .git directory (.git/info/attributes)
# git-svn reverse the meaning of ours and theirs, thus I choose here "theirs" because I want my local gitignore file untouched
# https://stackoverflow.com/questions/2959443/why-is-the-meaning-of-ours-and-theirs-reversed-with-git-svn/2960751#2960751
.gitignore merge=theirs
# excluding files from diff
# https://stackoverflow.com/questions/1016798/excluding-files-from-git-diff
*.exe -diff
*.pyd -diff
*.tgz -diff
*.dll -diff
@ancho85
ancho85 / dropEmptyTables.sql
Created July 18, 2016 13:52
MySQL empty table dropper
DELIMITER $$
DROP PROCEDURE IF EXISTS `anchoDropEmptyTables` $$
CREATE PROCEDURE `anchoDropEmptyTables`()
BEGIN
-- contar las tablas
DECLARE table_list TEXT;
DECLARE done INT DEFAULT 0;
DECLARE TNAME CHAR(255);
@ancho85
ancho85 / patchGenByBranch.bat
Last active August 23, 2019 15:37
git patch generator by branchname. First parameter is full path where work was done, second is just the name of the generated patch before the branch name
@echo off
setlocal
for /f usebackq %%c in (`git -C %1 rev-parse --abbrev-ref HEAD `) do @set _branchname_="%%c"
for /f usebackq %%c in (`git -C %1 show-ref --heads -s master`) do @set _branchcommit_="%%c"
for /f usebackq %%c in (`git -C %1 merge-base master %_branchname_%`) do @set _mastercommit_="%%c"
IF "%_branchcommit_%"=="%_mastercommit_%" (
echo generating patch for %_branchname_%
git -C %1 diff --relative --no-prefix --no-textconv --ignore-submodules --abbrev master..%_branchname_% '*.py' '*.xml' > %1\%2-%_branchname_%.patch
) ELSE (
echo "first rebase master to branch %_branchname_% (CTRL+D in smartgit)"
@ancho85
ancho85 / startTest.sh
Last active July 18, 2016 13:48
Playero Test starter
#!/bin/bash -x
#reverting changes from svn
svn revert -R .
svn status --no-ignore | grep -E '(^\?)|(^\I)' | grep -v -E '(startTest.sh|startTestDirect.sh|*.patch)' | sed -e 's/^. *//' | sed -e 's/\(.*\)/"\1"/' | xargs rm -rf
svn update --force --username USERNAMEHERE --password PASSWORDHERE --no-auth-cache
#touching files
touch force.sync
touch sforcelogin.txt
touch stdout_excluded.txt
@ancho85
ancho85 / backup.sh
Created July 18, 2016 13:42
backuper
#!/bin/bash
BACKUPDIR="/opt/backup" #CARPETA DESTINO EN EQUIPO LOCAL
LOGFILE=$BACKUPDIR/backup.log # Destino del log
USERNAME=""
PASSWORD=""
BD1=""
BD2=""
#DISCOLOCAL="/dev/sda2"
DISCOLOCAL="/dev/sda"
#DISCOMYSQL="/dev/sdb1"
@ancho85
ancho85 / deleteDuplicateRows.sql
Created July 18, 2016 13:40
MySQL delete duplicate rows
DELIMITER $$
DROP PROCEDURE IF EXISTS `anchoDeleteDuplicate` $$
CREATE PROCEDURE `anchoDeleteDuplicate`()
BEGIN
DECLARE done BOOLEAN DEFAULT FALSE;
DECLARE uid integer;
DECLARE cWebFlotaRow cursor for
select wfr.internalid from WebFlotaRow wfr
inner join WebFlotaRow wfr2
on wfr.masterid = wfr2.masterid