Skip to content

Instantly share code, notes, and snippets.

View svagionitis's full-sized avatar

stavros vagionitis svagionitis

View GitHub Profile
/* Instructions on compilation and execution
* =========================================
*
* Compile this program with pthreads:
*
* g++ -Wall -lpthread -o graphdb-simulator graphdb-simulator.cpp
*
* Before you run this program, you need to create the following
* directories:
*
0 1 2 3 4 5 6 7 8
--------------------------
{{4, 0, 0, 0, 0, 0, 8, 0, 5}, //0
{0, 3, 0, 0, 0, 0, 0, 0, 0}, //1
{0, 0, 0, 7, 0, 0, 0, 0, 0}, //2
{0, 2, 0, 0, 0, 0, 0, 6, 0}, //3
{0, 0, 0, 0, 8, 0, 4, 0, 0}, //4
{0, 0, 0, 0, 1, 0, 0, 0, 0}, //5
{0, 0, 0, 6, 0, 3, 0, 7, 0}, //6
{5, 0, 0, 2, 0, 0, 0, 0, 0}, //7
@svagionitis
svagionitis / GitInteractiveRebaseBranchToMaster.md
Last active December 24, 2015 14:19
Git interactive rebase a branch to the master

Git interactive rebase a branch to the master

  1. Check out the lastest changes for the master with one of the following commands

    git checkout origin master or git fetch origin master
    
  2. Create a new branch from the master

git branch -b TEMP

@svagionitis
svagionitis / split_query_web.cpp
Created September 24, 2013 15:03
Split/parse the query part of a URL. The correct one is getQueryParameters1.
#include <iostream>
#include <vector>
#include <utility>
std::vector< std::pair<std::string, std::string> > getQueryParameters(std::string query)
{
std::vector< std::pair <std::string, std::string> > queryParams;
size_t pos = 0;
std::string delimiter = "&";
std::string token;
#ifndef ma_concurrent_queue_h
#define ma_concurrent_queue_h
// Based on code from http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html
// Original version by Anthony Williams
// Modifications by Michael Anderson
#include "boost/thread.hpp"
#include <deque>
@svagionitis
svagionitis / UpdateTime.wsd
Last active December 20, 2015 12:18
Update UTC time using TDT and/or TOT
<div class="wsd" wsd_style="vs2010"><pre>
title Update Time
participant irisplayer
participant app
note left of irisplayer: receive the TDT and/or TOT tables
alt TOT exists
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void usage(char *argv0);
unsigned char isPrime(unsigned long num);
int main(int argc, char *argv[])
{
unsigned long input = 0, result = 0;
/*
(Easy): Sum-the-Digits, Part II (http://www.reddit.com/r/dailyprogrammer/comments/1fnutb/06413_challenge_128_easy_sumthedigits_part_ii/)
------------------------------------------------------------------------------------------------------------------------------------------
Given a well-formed (non-empty, fully valid) string of digits, let the integer N be the sum of digits. Then, given this integer N, turn it into a string of digits. Repeat this process until you only have one digit left. Simple, clean, and easy: focus on writing this as cleanly as possible in your preferred programming language.
`Author: nint22. This challenge is particularly easy, so don't worry about looking for crazy corner-cases or weird exceptions. This challenge is as up-front as it gets :-) Good luck, have fun!`
Formal Inputs & Outputs
-----------------------
@svagionitis
svagionitis / .bashrc
Last active December 17, 2015 21:29
Dot file .bashrc Mac Os X 10.5.8 and 10.9.3
#-------------------------------------------------------------
# Source global definitions (if any)
#-------------------------------------------------------------
#if [ -f /etc/bashrc ]; then
# . /etc/bashrc # --> Read /etc/bashrc, if present.
#fi
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TRUE 1
#define FALSE 0
/*The index Base64 table.*/
static const unsigned char indexBase64Tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";