Skip to content

Instantly share code, notes, and snippets.

View fpersson's full-sized avatar

Fredrik Persson fpersson

View GitHub Profile
@fpersson
fpersson / test.txt
Created January 5, 2012 11:02
Unix commad to print date as posixtime
date +"%s"
@fpersson
fpersson / CMakeLists.txt
Created August 28, 2012 20:18
a c++ 11 dice
cmake_minimum_required (VERSION 2.8)
project(demo)
set(CMAKE_CXX_FLAGS "-Wall -std=c++0x")
add_executable(demo main.cpp)
target_link_libraries(demo )
@fpersson
fpersson / CMakeLists.txt
Created September 15, 2012 09:16
Boost statechart simple test
cmake_minimum_required (VERSION 2.8)
project(demo)
find_package(Boost 1.4.2)
include_directories(${Boost_INCLUDE_DIR})
set(CORELIBS ${Boost_LIBRARIES})
add_executable(demo ${CORELIBS} main.cpp)
@fpersson
fpersson / git-dropbox.sh
Created September 15, 2012 09:22 — forked from klang/git-dropbox.sh
git repository on dropbox
export DROPBOX=~/Dropbox/repos
export newRepo=project-name
export NAME=$(git config --global --get user.name)
cd ~/projects/$newRepo
git init
git add .
git commit -m 'initial'
HERE=$(pwd)
@fpersson
fpersson / main.cpp
Created September 20, 2012 21:10
Simple with std::map
#include <iostream>
#include <string>
#include <map>
enum TMemoryValue{YES=1, NO, MAYBE, UNKNOWN};
int main () {
std::map<std::string, TMemoryValue> memorymap;
std::map<std::string, TMemoryValue>::iterator it;
@fpersson
fpersson / main.cpp
Created November 3, 2012 14:12
a simple log, useing c++11
#include <iostream>
#include <fstream>
#include <string>
#include <chrono>
#include <ctime>
class FLog{
public:
FLog(std::string logfile);
@fpersson
fpersson / main.cpp
Created December 28, 2012 12:52
a quick sample code to answare a beginers question about file paths in C++, this code is free to use for anyone.
#include <iostream>
#include <fstream>
/**
* @brief a quick sample code to answare a beginers question about file paths in C++, this code is free to use for anyone.
*/
class Path{
public:
Path(std::string path, std::string file);
@fpersson
fpersson / foo.cpp
Created January 10, 2013 20:13
a quick and dirty fix.
/**
* best and easiest way... improvement can still be done ;)
*/
bool wortdateoOeffnen(){
bool openSuccess = false
string Dateiort;
cout << "Bitte die Datei inklusive Pfad angeben" << endl;
//Text noch rot machen
cout << "ACHTUNG: Bei Windows bitte / (Slash) mit \ (Backslash) austauschen " << endl << endl ;
cout << "---> ";
@fpersson
fpersson / main.cpp
Created May 12, 2013 17:30
2D array in C++ 11 with std::array (note the brackets).
#include <iostream>
#include <array>
int main(){
//col, row
std::array<std::array<int, 10>, 10> mymap{{
{{1,2,3,4,5,6,7,8,9,0}},
{{1,2,3,4,5,6,7,8,9,0}},
{{1,2,3,4,5,6,7,8,9,0}},
{{1,2,3,4,5,6,7,8,9,0}},
@fpersson
fpersson / main.cpp
Created March 21, 2014 19:16
How to use popen for system calls with return value.
#include <string>
#include <iostream>
#include <stdio.h>
/**
* This is not tested in windows.
* Windows users should use _popen and _pclose.
* http://msdn.microsoft.com/en-us/library/aa298534(v=vs.60).aspx
*/