Skip to content

Instantly share code, notes, and snippets.

@samuelsmal
samuelsmal / plot the stuff
Last active August 29, 2015 14:05
R Script to plot the data from my genetic programming paper
cat("\014") # clears the console
raw_data <- read.table("~/Desktop/raw_data/do_1_nohigherfn_data_points.txt", sep="\t", col.names=c("pos", "WIN EP", "WIN RP", "draws EP", "draws RP", "matches", "title"), fill=FALSE, strip.white=TRUE)
raw_data["generation"] <- NA # adding a new column
numberOfGenerations = 100
numberOfWinners = 16
# Adding the generation count
#for (i in 0:numberOfGenerations) {
@samuelsmal
samuelsmal / git_exclude
Last active August 29, 2015 14:05
git exclude
git config --global core.excludesfile ~/.gitignore_global
Now you can put your global ignores in ~/.gitignore_global.
I just use .git/info/exclude for project specific stuff I want to ignore that only I would have.
@samuelsmal
samuelsmal / system_call_wrapper.cpp
Created August 21, 2014 08:58
c++ system call wrapper
#include <unistd.h>
#include <sys/socket.h>
// … and others for actual syscalls
#include <system_error>
#include <functional>
namespace sys
{
namespace
@samuelsmal
samuelsmal / makefile
Last active July 1, 2023 20:55
Generic clang++ (or c++ for that matter) makefile with directory structure
# Requires the following project directory structure:
# /bin
# /obj
# /src
# Use 'make remove' to clean up the hole project
# Name of target file
TARGET = foooooooobar
@samuelsmal
samuelsmal / getline
Created September 19, 2014 12:08
c++ read by line
std::string line;
std::string _first_name, _last_name;
long _yearly_salary;
int _age, _clearance_level;
while (std::getline(input_file_stream, line))
{
std::istringstream iss(line);
if (!(iss >> _last_name >> _first_name >> _yearly_salary >> _age >> _clearance_level)) { break; } // error
@samuelsmal
samuelsmal / opensuse_specific.md
Last active August 29, 2015 14:06
Latex notes

When using TexLive you can install new packages with

zypper in 'tex(<package name>.sty)'

For example if you want to install the multirow package:

zypper in 'tex(multirow.sty)'

@samuelsmal
samuelsmal / Preferences.sublime-settings
Last active August 29, 2015 14:06
sublime text 3 settings
// User/Preferences.sublime-settings
{
"font_face": "inconsolata",
"font_size": 13,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
],
@samuelsmal
samuelsmal / Stats
Created October 6, 2014 11:24
Check if a file exists
Method exists_test0 (ifstream): **0.485s**
Method exists_test1 (FILE fopen): **0.302s**
Method exists_test2 (posix access()): **0.202s**
Method exists_test3 (posix stat()): **0.134s**
@samuelsmal
samuelsmal / code
Created November 4, 2014 22:26
Printing a vector to stdout
#include <vector
#include <algorithm> // for copy, for_each
#include <iterator> // for ostream_iterator
std::copy(vector.cbegin(), vector.cend(), std::ostream_iterator<vector_element_type>(std::cout, " "));
std::for_each(vec.cbegin(), vec.cend(), [] (const vector_element_type c) {std::cout << c << " ";});
@samuelsmal
samuelsmal / create-git-alias.md
Created November 6, 2014 01:22
List of helpful command line commands

This answer builds upon the [answer][1] by [johnny][2]. I got it from stackoverflow user A-B-B.

It applies if you're not using [git-alias][3] from [git-extras][4].

On Linux, run once:

git config --global alias.alias "! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /"

This will create a permanent git alias named alias which gets stored in your ~/.gitconfig file. Using it will list all of your git aliases, in nearly the same format as they are in the ~/.gitconfig file. To use it, type: