Skip to content

Instantly share code, notes, and snippets.

View odeblic's full-sized avatar

Olivier de BLIC odeblic

View GitHub Profile
@odeblic
odeblic / regex.cpp
Created July 29, 2017 15:42
To be tested...
#include<string>
#include<set>
#include<iostream>
#include<sstream>
#include<regex>
using namespace std;
set<string> get_strings(istream& is, regex pat);
@odeblic
odeblic / streams.cpp
Created July 30, 2017 07:53
To be tested...
#include <iostream>
#include <string>
#include <sstream>
int main(int argc, char ** argv)
{
std::string content;
std::stringstream buffer;
if (argc > 1)
@odeblic
odeblic / casts.c
Created July 30, 2017 07:54
To be tested...
int my_int;
float my_float;
char my_char;
long long my_longlong;
struct { char a; long long b; } my_aligned;
@odeblic
odeblic / stats.cpp
Created July 30, 2017 07:56
To be tested...
#include <iostream>
#include <limits>
#include <math.h>
// x[i]=i++ + 1;
int array[5][2] = {{1, 2, 3}, {10, 20, 30}};
int x = array[++i, ++j];
@odeblic
odeblic / stl_size.cpp
Created July 30, 2017 13:14
To be tested...
#include <iostream>
#include <list>
#include <forward_list>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#define PRINT(X) std::cout << #X " -> " << sizeof(X) << std::endl;
@odeblic
odeblic / jinja2.py
Last active August 2, 2017 14:57
To be tested...
#pragma once
{% block title %}
{% endblock %}
{% for this_class in all_classes %}
class {{ this_class.name }}
{
{% for this_class in this_class.private %}
@odeblic
odeblic / bytes.cpp
Created August 2, 2017 14:51
Representations of bytes
#include <iostream>
#include <cstddef>
void action(char arg)
{
std::cout << "char arg -> " << (int)arg << "\n";
}
void action(signed char arg)
{
@odeblic
odeblic / monitoring.cpp
Created August 11, 2017 09:02
Monitoring and heartbeat
#include <thread>
#include <chrono>
class Monitor
{
public:
void onHeartbeat(int id, int status)
{
lastTimestamp = std::chrono::system_clock::now();
}
@odeblic
odeblic / finance.cpp
Created August 19, 2017 04:27
Financial tools
class Price
{
public:
Price(double val)
{
mValue = val * 1000;
}
operator double()()
{
@odeblic
odeblic / flush.cpp
Created August 24, 2017 08:20
Cost of flushing files
#include <chrono>
#include <cstdio>
#include <iostream>
void write_file(std::FILE* fd)
{
for (int i=0; i<1000000; i++)
{
std::fprintf(fd, "iteration no %d (last bit=%d)\n", i, i % 2);
}