-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d262a6d
Showing
6 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Shell Scripts | ||
============= | ||
This repository contains of a collection of simple and small, but very useful | ||
shell scripts that I often use personally. | ||
|
||
* base64decode: decode BASE64 strings received from stdin. | ||
* base64encode: encode plain strings into BASE64 from stdin. | ||
* git-can-ff: determines if the current branch can fast-forward (ff) to its | ||
remote counterpart. | ||
* quote: quotes each line from stdin to stdout. Very useful when piping | ||
filenames with spaces into xargs. | ||
* sedfiles.sh: batch change file names using a sed expression. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/php | ||
<?php print base64_decode(file_get_contents('php://stdin')) ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/php | ||
<?php print base64_encode(file_get_contents('php://stdin')) ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
usage() { | ||
echo "usage: $(basename $0) <from-ref> <to-ref>" >&2 | ||
exit 2 | ||
} | ||
|
||
[ $# -ne 2 ] && usage | ||
|
||
FROM_REF=$1 | ||
TO_REF=$2 | ||
|
||
FROM_HASH=$(git show-ref --hash $FROM_REF) | ||
TO_HASH=$(git show-ref --hash $FROM_REF) | ||
BASE_HASH=$(git merge-base $FROM_REF $TO_REF) | ||
|
||
if [ "$BASE_HASH" = "$FROM_HASH" -o \ | ||
"$BASE_HASH" = "$FROM_REF" ]; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
sed -E 's/^(.*)$/"&"/g' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
if test -z "$*"; then | ||
echo "No files to parse" | ||
exit | ||
fi | ||
|
||
SEARCH="contextStackSize" | ||
REPLACE="actualStackSize" | ||
|
||
echo "Searching for $SEARCH" | ||
echo "Replacing with $REPLACE" | ||
|
||
for afile in $*; do | ||
DATA=`grep "$SEARCH" $afile` | ||
|
||
if test -n "$DATA"; then | ||
|
||
echo "Processing $afile ..." | ||
|
||
rm -f $afile.backup | ||
rm -f $afile.backup2 | ||
|
||
cp $afile $afile.backup | ||
|
||
COMMAND="s/$SEARCH/$REPLACE/g" | ||
echo "`cat $afile.backup | sed -e $COMMAND`" > $afile | ||
|
||
if grep "$SEARCH" $afile; then | ||
echo "Ops.. maybe it didn't work..." | ||
else | ||
echo "Ok, it worked." | ||
fi | ||
fi | ||
|
||
done |