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
function uriDecode() { | |
#Usage echo Some%URI | uriDecode | |
echo -e "$(sed 's/%/\\x/g' <&0)" | |
} |
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
#From http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html | |
# save and change IFS | |
OLDIFS=$IFS | |
IFS=$'\n' | |
# read all file name into an array | |
fileArray=($(find $DIR -type f)) | |
# restore it |
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
BLAH=$(( (echo out >&1; echo err >&2; echo other >&3;) 1>/dev/null ) 3>&1) |
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
template< typename T > | |
T gcd( T a, T b ) { | |
T remainder = a % b; | |
while(remainder) { | |
a = b; | |
b = remainder; | |
remainder = a % b; | |
} | |
return b; | |
} |
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
template< typename T > | |
T lcm( T a, T b ) { | |
return a*b/gcd( a, b ); | |
} |
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
file * | grep broken | sed -re 's/^(.*):.*$/\1/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
#include <bitset> | |
char a = 'b'; | |
std::bitset<8> x{a}; | |
std::cout << x; |
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
(defun iota (m &optional (n 1) (step 1)) | |
(defun iter (m n lst) | |
(cond ((> n m) (reverse lst)) | |
(t (iter m (+ n step) (cons n lst))))) | |
(iter m n nil)) |
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
# For ubuntu 12.04 | |
# Remove unity | |
sudo apt-get remove --purge unity unity-2d unity-2d-panel unity-2d-spread unity-asset-pool unity-services unity-lens-files unity-lens-music unity-lens-applications gir1.2-unity-5.0 unity-common indicator-sound indicator-power indicator-appmenu libindicator7 indicator-application indicator-datetime indicator-messages libnux-2.0-0 nux-tools libunity-misc4 unity-2d-common | |
# Install gnome-shell | |
sudo add-apt-repository ppa:gnome3-team/gnome3 | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get install gnome-shell |
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
// @todo I'm sure it could be more efficient if we used a "safe" strlen and | |
// write the string into the stream using "ostream.write( const char*, size_t size)" | |
std::ostream& safePrint( std::ostream& out, const char* szStr, size_t maxSize ) { | |
for( size_t i = 0; i < maxSize && szStr[i] != '\0'; ++i) { | |
out.put(szStr[i]); | |
} | |
return out; | |
} |