Skip to content

Instantly share code, notes, and snippets.

View odeblic's full-sized avatar

Olivier de BLIC odeblic

View GitHub Profile
@odeblic
odeblic / fast_logger.cpp
Created July 29, 2017 00:38
fast logger
class FastLogger
{
void registerMessage(int msgId, std::string& )
{
}
void logMessage(enum logType, int msgId)
{
}
@odeblic
odeblic / containers.cpp
Created July 29, 2017 00:39
containers
#include <iostream>
#include <list>
#include <chrono>
#include <functional>
MEASURE(ID, STATEMENT)
M_START(ID)
M_STOP(ID)
class Queue
@odeblic
odeblic / sampling.py
Created July 29, 2017 00:40
Data sampling for latency measurement
import random
class Sampling(object):
def __init__(self, size_max):
self.__count = 0
self.__samples = list()
self.__size_max = size_max
def sample(self, value):
@odeblic
odeblic / head_tail.cpp
Created July 29, 2017 00:42
Head or tail prediction
#include <iostream>
#include <ctime>
inline bool randomBool()
{
return rand() % 2;
}
int heads = 0;
int tails = 0;
@odeblic
odeblic / dna.cpp
Created July 29, 2017 00:43
DNA encoding and decoding
#include <iostream>
struct Wheel
{
wheel(char initial_escape_symbol) : escape_id(0), left_id(1), right_id(2), switch_id(3) { while(symbols[escape_id] != esc) rotate(); }
void rotate() { escape_id++; left_id++; right_id++; switch_id++; }
char getEscapeSymbol() { return symbols[escape_id]; }
@odeblic
odeblic / console.cpp
Last active July 29, 2017 14:34
To be tested...
#include <iostream>
#include <iomanip>
//using namespace std;
void display(double n)
{
std::cout << "Flottant : \"" << n << "\" (précision " << std::cout.precision() << ")" << std::endl;
}
@odeblic
odeblic / containers.cpp
Created July 29, 2017 14:35
To be tested...
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <unordered_set>
#include <algorithm>
using namespace std;
@odeblic
odeblic / hacktest.cpp
Created July 29, 2017 14:37
To be tested...
#include <iostream>
#include <math.h>
/*
* Complete the function below.
*/
int getIntegerComplement(int n) {
if(n <= 0)
{
@odeblic
odeblic / alignment.c
Created July 29, 2017 14:47
To be tested...
#include <stdio.h>
typedef struct
{
int a;
char b;
int c;
char d;
} s1;
@odeblic
odeblic / signed_unsigned.c
Last active July 30, 2017 05:18
Signed and unsigned integers
#include <stdio.h>
int main(int argc, char* argv[])
{
union
{
signed short int signed_short_int;
unsigned short int unsigned_short_int;
struct {unsigned char char1; unsigned char char2;} s;
} u;