Skip to content

Instantly share code, notes, and snippets.

View rene-d's full-sized avatar
🤘
Let There Be Rock

rene-d rene-d

🤘
Let There Be Rock
  • Thales
  • France
View GitHub Profile
@rene-d
rene-d / pathfind.c
Created October 10, 2018 02:34
get the process path by PID on macOS. example: make pathfind && ./pathfind 86504
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <libproc.h>
int main(int argc, char* argv[])
{
pid_t pid;
int ret;
#! /usr/bin/env python3
# http://ifcuriousthenlearn.com/blog/2015/06/18/center-of-mass/
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
#set plot sizes
plt.rcParams['figure.figsize'] = (10, 2) # (width, height)
plt.rcParams['font.size'] = 20
#! /usr/bin/env python3
import decimal
import re
import math
import readline
RED = "\033[0;31m"
LIGHT_GREEN = "\033[1;32m"
@rene-d
rene-d / bash_colors.sh
Last active December 30, 2018 05:58 — forked from claymcleod/bash_colors.sh
print ANSI colors
#!/bin/bash
useage() {
printf "\n\e[1;4mAscii Escape Code Helper Utility\e[m\n\n"
printf " \e[1mUseage:\e[m colors.sh [-|-b|-f|-bq|-fq|-?|?] [start] [end] [step]\n\n"
printf "The values for the first parameter may be one of the following:\n\n"
printf " \e[1m-\e[m Will result in the default output.\n"
printf " \e[1m-b\e[m This will display the 8 color version of this chart.\n"
printf " \e[1m-f\e[m This will display the 256 color version of this chart using foreground colors.\n"
printf " \e[1m-q\e[m This will display the 256 color version of this chart without the extra text.\n"
@rene-d
rene-d / setfdate.py
Last active December 30, 2018 05:58
set file date based on the pattern in the filename
#! /usr/bin/env python3
"""
set file atime and ctime based on the date pattern YYYY[_-]MM[_-]DD in filename
"""
import argparse
import re
import os
import datetime
@rene-d
rene-d / emplace.cpp
Last active March 18, 2019 18:21
C++17 emplace demo
// démonstration emplace c++11 vs. c++17
// rene-d 2019
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
struct toto
# Docker image downloader
# download Docker images without Docker installed
FROM docker:edge
RUN apk add --no-cache bash curl ca-certificates jq go
ADD https://raw.githubusercontent.com/moby/moby/master/contrib/download-frozen-image-v2.sh /bin/download-frozen-image
FROM alpine AS builder
RUN apk add gcc musl-dev glib-static glib-dev upx
COPY a.c /
RUN gcc a.c `pkg-config --cflags --libs glib-2.0` -static \
&& strip a.out \
&& upx -q a.out || true
FROM scratch
COPY --from=builder /a.out /
ENTRYPOINT ["/a.out"]
@rene-d
rene-d / CMakeLists.txt
Created October 14, 2019 07:04
cmake best practices
cmake_minimum_required(VERSION 3.7)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type)
message("AAA CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE} ${cmake_build_type}")
if (cmake_build_type STREQUAL "debug")
#! /usr/bin/env python3
"""
télécharge les exemples de https://edupython.tuxfamily.org
"""
import requests
import re
import pathlib
# import black