Skip to content

Instantly share code, notes, and snippets.

View fpersson's full-sized avatar

Fredrik Persson fpersson

View GitHub Profile
@fpersson
fpersson / android-log.xml
Created June 16, 2015 13:25
Syntaxhighligting for android logfile, save the xml to ~/.kde/share/apps/katepart/syntax/android-log.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
This file is part of KDE's kate project.
copyright : (C) 2015 by Fredrik Persson
email : fpersson.se@gmail.com
This file is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@fpersson
fpersson / create.sh
Created May 20, 2015 19:57
A hard way to write Hello World i Bash or a easy way to create a c++ project
#!/bin/bash
############################################
# Name: create.sh
# Usage: ./create.sh app-name
############################################
PROJECTNAME=$1
WORKINGDIR=$HOME/development/$PROJECTNAME
SRCDIR=$WORKINGDIR/src
@fpersson
fpersson / gitstat.sh
Created February 19, 2015 11:35
Find large files in git repo
#!/bin/bash
TMPFILE="/tmp/gitstat.txt"
FILENAME="/tmp/gitstat_files.txt"
if [ -d $1 ] ; then
if [ -f $2 ] ; then
rm $2
fi
@fpersson
fpersson / getgist.py
Created October 1, 2014 21:13
How to list my public gist
import pycurl
import json
from StringIO import StringIO
from pprint import pprint
buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'https://api.github.com/users/fpersson/gists')
c.setopt(c.WRITEFUNCTION, buffer.write)
c.perform()
@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
*/
@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 / 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 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 / 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 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;