Skip to content

Instantly share code, notes, and snippets.

View jackbergus's full-sized avatar
🏖️

Giacomo Bergami jackbergus

🏖️
View GitHub Profile
@jackbergus
jackbergus / parse_commands_http.cpp
Created July 8, 2013 16:05
An easy way to parse http headers
/*
* parse_commands_http.cpp
* This file is part of parse_commands_http
*
* Copyright (C) 2013 - Giacomo Bergami
*
* parse_commands_http is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@jackbergus
jackbergus / Vertex.cpp
Last active January 2, 2016 02:29
A simple wrapping over Boost Graph Library
/*
* Vertex.cpp
* This file is part of socialsim
*
* Copyright (C) 2014 - Giacomo Bergami
*
* socialsim is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
# Giacomo Bergami (c) 2014
# This gists is licensed under GPL-2 | GPL-3
library(hyperdraw)
library(hypergraph)
#vertices <- c("id1","id2","id3","id4","tom","sam","pos1","pos2","helloworld","ciaomondo","hashtag","geotag1","geotag2")
#dh1 <- DirectedHyperedge(c("tom","pos1"),c("id1"),"User<:ED")
#dh2 <- DirectedHyperedge(c("sam","pos2"),c("id2"),"User<:ED")
#h <- Hypergraph(vertices,list(dh1,dh2))
@jackbergus
jackbergus / iteratortest.cpp
Last active August 29, 2015 13:57
A simple example of how to use iterators in C++11
/*
* iteratortest.cpp
* This file is part of iteratortest.cpp
*
* Copyright (C) 2014 - Giacomo Bergami
*
* iteratortest.cpp is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@jackbergus
jackbergus / daemon.c
Created July 4, 2014 16:10
Run a R script inside a daemon
/*
* daemon.c
* This file is part of aviva2014
*
* Copyright (C) 2014 - Giacomo Bergami
*
* aviva2014 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@jackbergus
jackbergus / Repository-MonoView.cpp
Created August 17, 2014 20:02
A variant of the repository pattern
/*
* Repository-MonoView.cpp
* This file is part of <program name>
*
* Copyright (C) 2014 - Giacomo Bergami
*
* <program name> is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@jackbergus
jackbergus / Dénes Kőnig matching.cpp
Created November 20, 2014 23:58
Calculates the graph matching with the Konig matching theorem
/*
* Dénes Kőnig matching.cpp
* This file is part of Dénes Kőnig matching
*
* Copyright (C) 2014 - Giacomo Bergami
*
* Dénes Kőnig matching is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
data Tree = Leaf | Node Int Tree Tree deriving Show
leftmost Leaf x = x
leftmost (Node x Leaf _) _ = x
leftmost (Node v (Node x y z) _) _ = leftmost (Node x y z) v
rightmost Leaf x = x
rightmost (Node x _ Leaf) _ = x
rightmost (Node v _ (Node x y z)) _ = rightmost (Node x y z) v
@jackbergus
jackbergus / data.json
Last active November 8, 2016 18:53
A python script for learning German's die Wörter
[
{
"art": "der",
"de": "Apfel",
"errors": 0,
"first": 0,
"it": "la mela"
},
{
"art": "die",
@jackbergus
jackbergus / split_and_to_mp3.py
Created July 20, 2017 14:52
Splists a file readable by ffmpeg into several mp3 files
#!/usr/bin/python
# -*- coding: utf-8 -*-
import unicodedata
import codecs
import re
from subprocess import call
import os.path
import string
import sys