Skip to content

Instantly share code, notes, and snippets.

View tmattio's full-sized avatar

Thibaut Mattio tmattio

View GitHub Profile
@tmattio
tmattio / git-import-repository.md
Created December 3, 2019 15:47 — forked from martinbuberl/git-import-repository.md
Import existing Git repository into another

Import existing Git repository into another

Folder structure before (2 separate repositories):

XXX
 |- .git
 |- (project files)
YYY
 |- .git
@tmattio
tmattio / git-import-repository.md
Created December 3, 2019 15:47 — forked from martinbuberl/git-import-repository.md
Import existing Git repository into another

Import existing Git repository into another

Folder structure before (2 separate repositories):

XXX
 |- .git
 |- (project files)
YYY
 |- .git
@tmattio
tmattio / har2csv.py
Last active January 25, 2019 19:33
Convert HAR files to CSV
import sys
import json
import csv
def truncate(s: str, threshold: int = 120):
return (s[:threshold] + "..") if len(s) > threshold else s
def get_headers():
@tmattio
tmattio / migrations.exs
Last active August 13, 2018 16:47
An implementation of has_many polymorphic association with Ecto
defmodule CreateCat do
use Ecto.Migration
def change do
create table(:cats) do
end
end
end
defmodule CreateDog do
@tmattio
tmattio / list_interfaces.py
Created December 19, 2017 16:35
List lines matching the interfaces in a Cisco configuration file
import sys
import re
def list_interfaces(input_file):
with open(input_file) as fp:
lines = fp.read().splitlines()
for l in lines:
match = re.match(r'^Interface (.*)$', l)
@tmattio
tmattio / cv2.cpp
Last active April 21, 2017 14:46
Cyphon OpenCV
#include <Python.h>
#include <opencv2/core/core.hpp>
#include <numpy/ndarrayobject.h>
#include <cstdio>
using namespace cv;
static PyObject* opencv_error = 0;
#define ERRWRAP2(expr) \
@tmattio
tmattio / text_tbb_opencv.cc
Created January 25, 2017 03:43
A google test that ensure that an image is not corrupted when passing it through a tbb flow graph
#include <gtest/gtest.h>
#include <tbb/flow_graph.h>
#include <opencv2/core.hpp>
using namespace tbb::flow;
/**
* Simple functor that return the inverted matrix.
*/
struct pass_image {
#pragma once
#include <atomic>
#include <condition_variable>
/// A mutex guaranted noexcept that can be used in destructors.
/// See:
/// http://stackoverflow.com/questions/16568990/locking-a-mutex-in-a-destructor-in-c11
template <class Tp_ = std::mutex>
class nothrow_mutex {
public:
@tmattio
tmattio / random.h
Last active September 20, 2016 21:21
A set of few functions for generating random values
// Created by Thibaut Mattio
#pragma once
#include <ctime>
#include <random>
namespace random {
inline auto random_float(float min = 0., float max = 1.) {
@tmattio
tmattio / timelapse.py
Created March 16, 2016 02:57
A simple python script for capturing images from a webcam and building a video from it
# This script is based on https://github.com/nvellon/timelapse
import os
import sys
import time
import cv2
command = 'capture'
cam_num = 0
output_path = 'out/'