Skip to content

Instantly share code, notes, and snippets.

View tmattio's full-sized avatar

Thibaut Mattio tmattio

View GitHub Profile
@tmattio
tmattio / dune
Created January 29, 2025 17:29
Demo of a Space Invaders game in OCaml.
(executable
(public_name space-invaders)
(name space_invaders)
(libraries raylib))
@tmattio
tmattio / main.c
Created January 8, 2025 15:47
Stardew Valley Animation Canceler - A macOS tool that automates keypresses to cancel animations in Stardew Valley, optimizing actions like mining and farming. Triggered by a key (default: Spacebar) and requires accessibility permissions.
#include <sys/sysctl.h>
#include <stdbool.h>
#include <time.h>
#include <string.h>
#include <libproc.h>
#include <pthread.h>
#include <Carbon/Carbon.h>
// Default configuration values
#define KEY_CODE 49 // Space key
@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: