Skip to content

Instantly share code, notes, and snippets.

View hatzopoulos's full-sized avatar

Anthony Hatzopoulos hatzopoulos

View GitHub Profile
# add-whitespace-only.bash
for fname in $(git diff --name-only --diff-filter=ACMR --full-index HEAD)
do
diff=$(git diff -w --ignore-blank-lines --exit-code $fname)
if [ $? -eq 0 ]; then
echo "only whitespace diff on $fname ! adding to git..."
git add $fname
else
echo "diff on $fname!"
fi
function tabs_or_spaces () {
spaces = $(grep -P '^ *' "$@" | wc -l);
tabs = $(grep -P '^\t' "$@" | wc -l);
echo "Number of Spaces: $spaces"
echo "Number of Tabs: $tabs"
}
@hatzopoulos
hatzopoulos / sed1line.txt
Last active March 8, 2018 06:51 — forked from un33k/sed cheatsheet
magic of sed -- find and replace "text" in a string or a file. Useful One-Line Scripts For SED (Unix Stream Editor). From http://sed.sourceforge.net/sed1line.txt
-------------------------------------------------------------------------
USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) Dec. 29, 2005
Compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.5
Latest version of this file (in English) is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.pement.org/sed/sed1line.txt
This file will also available in other languages:
Chinese - http://sed.sourceforge.net/sed1line_zh-CN.html
-------------------------------------------------------------------------
USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) Dec. 29, 2005
Compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.5
Latest version of this file (in English) is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.pement.org/sed/sed1line.txt
This file will also available in other languages:
Chinese - http://sed.sourceforge.net/sed1line_zh-CN.html
@hatzopoulos
hatzopoulos / fftb.php
Last active October 5, 2015 22:07 — forked from rewmike/fftb.php
fftb.php
<?php
// Set content type and disable encoding
header('Content-Type: text/html; charset=UTF-8');
while (@ob_get_level()) ob_end_flush();
ob_start();
// Send some content
function padding () {
@hatzopoulos
hatzopoulos / web-dev-kits.md
Last active September 5, 2015 14:30
web development kits
@hatzopoulos
hatzopoulos / rewrite-history.bash
Last active August 29, 2015 14:27
rewrite-history.bash
#!/bin/bash
# usage:
# cd ~/your-repo
# git filter-branch --prune-empty --tree-filter ~/rewrite-history.bash
if [[ ! -e httpdocs ]]; then
mkdir -p httpdocs
git ls-tree --name-only $GIT_COMMIT | grep -v ^'.gitignore\|.gitattributes'$ | xargs -I files mv files httpdocs
fi
#!/bin/bash
set -e
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another