Skip to content

Instantly share code, notes, and snippets.

@PeterHajdu
PeterHajdu / bitmagic.cpp
Created September 11, 2010 12:23
Some bitmagic in c++.
#include <iomanip>
#include <string>
#include <sstream>
std::string
hexDump( const unsigned char * data, unsigned int length )
{
std::stringstream ret;
for ( unsigned int i = 0; i < length; ++i )
@PeterHajdu
PeterHajdu / smiley.sh
Created September 21, 2010 17:20
Awesome smiley prompt for bash.
export PS1="\[\e[34m\]\w \[\e[0m\]\`
if [ \$? = 0 ]; then
echo \[\e[32m\]\A \:\)\[\e[0m\];
else
echo \[\e[31m\]\A \:\(\[\e[0m\];
fi\` "
import os
curr_dir = os.getcwd()
while curr_dir!="/" and not os.path.isfile( os.path.join( curr_dir, ".proj.sf" ) ):
print( curr_dir )
( curr_dir, temp ) = os.path.split( curr_dir )
@PeterHajdu
PeterHajdu / .gitignore
Created March 11, 2012 12:06
DataContainer
*.swp
*.log
covsummary
*~
*gcov
*gcna
*gcda
*gcno
testFile
test.cpp
@PeterHajdu
PeterHajdu / README
Created March 14, 2012 12:02
small helper script for training exercises
trainee should source the with arguments instead of simply execute it
@PeterHajdu
PeterHajdu / git_commands
Created April 4, 2012 09:49
Some notes on git
1. distributed <-> centralized
2. cloning / initing ( let's start with a repo with some ruby code )
3. recording changes:
* git status (working tree/directory status) / git log
* the three states ( working directory, staging area, repository )
* file status / lifecycle of a file: untracked, unmodified, modified, staged
* status -> add -> status -> modify -> add -> status -> commit
* introduce yourself -> commit -> status -> log
* commit -a ( easy )
*.o
*.so
*.swp
*~
tst/test
tst/test.cpp
@PeterHajdu
PeterHajdu / stl.cpp
Created July 29, 2012 13:59
anagram generation
#include <iostream>
#include <algorithm>
#include <string>
int main()
{
std::string word( "dog" );
std::sort( word.begin(), word.end() );
do {
@PeterHajdu
PeterHajdu / main.cpp
Created July 29, 2012 17:05
Reading character matrix from file
#include <cassert>
#include <iostream>
#include <fstream>
#include <vector>
#include <iterator>
std::vector< std::string >
getContainerFromFile( const std::string& fileName )