Skip to content

Instantly share code, notes, and snippets.

@julbouln
julbouln / c_refactoring_tool.rb
Created April 7, 2021 14:52
convert C globals to structures using clang ast json dump
require 'set'
require 'json'
require 'tree'
require 'fileutils'
# convert C globals to structures using clang ast json dump
# algorithm description
# - get AST with clang
# - convert AST into ruby tree
@jvranish
jvranish / c_option_type.c
Last active May 2, 2022 19:17
Simple option type in C
//usr/bin/make -s "${0%.*}" CFLAGS="-O2 -Wall -Werror" && ./"${0%.*}" "$@"; s=$?; rm ./"${0%.*}"; exit $s
#include <stdio.h>
#include <stdbool.h>
enum option_tag { OPTION_SOME, OPTION_NONE };
#define option_type(T) { enum option_tag tag; T some; }
#define SOME(S) { .tag = OPTION_SOME, .some = S }
#define NONE() { .tag = OPTION_NONE }
import React, { useState } from 'react';
import { withStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import axios from 'axios';
msys2 vs msys vs msysgit
MinGW doesn't provide a linux-like environment, that is MSYS(2) and/or Cygwin
Cygwin is an attempt to create a complete UNIX/POSIX environment on Windows.
MinGW is a C/C++ compiler suite which allows you to create Windows executables - you only
need the normal MSVC runtimes, which are part of any normal Microsoft Windows installation.
MinGW provides headers and libraries so that GCC (a compiler suite,
not just a "unix/linux compiler") can be built and used against the Windows C runtime.
@jannismain
jannismain / CompactJSONEncoder.py
Last active April 22, 2024 17:56
A JSON Encoder in Python, that puts small lists on single lines.
#!/usr/bin/env python3
from __future__ import annotations
import json
class CompactJSONEncoder(json.JSONEncoder):
"""A JSON Encoder that puts small containers on single lines."""
CONTAINER_TYPES = (list, tuple, dict)
@benmarwick
benmarwick / object-outline-and-dimensions-opencv.py
Last active April 23, 2024 01:28
Python 3 script to take live video, detect the largest object, trace an outline (contour) and measure linear dimensions, using OpenCV
# in a terminal
# python -m pip install --user opencv-contrib-python numpy scipy matplotlib ipython jupyter pandas sympy nose
import cv2
import pandas as pd
import numpy as np
import imutils
from scipy.spatial import distance as dist
from imutils import perspective
@giraldeau
giraldeau / CMakeLists.txt
Created November 3, 2017 21:48
The missing example to use cmake qt5_create_translation
cmake_minimum_required(VERSION 3.8)
project(tsProject)
# Managing translations require LinguistTools module
# The cmake function is defined in the Qt installation tree:
# i.e. Qt5.9.1/5.9.1/gcc_64/lib/cmake/Qt5LinguistTools/Qt5LinguistToolsMacros.cmake
# Reference: https://doc.qt.io/qt-5/cmake-manual.html#qt5linguisttools-macros
find_package(Qt5 COMPONENTS Widgets LinguistTools)
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@linw1995
linw1995 / tasks.json
Created August 4, 2017 05:45
VSCode Task.json for Python Traceback.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [{
"taskName": "Run Python",
"group": {
"kind": "build",
"isDefault": true
},
@iffy
iffy / .gitignore
Last active April 17, 2024 07:19
Example using electron-updater with `generic` provider.
node_modules
dist/
yarn.lock
wwwroot
@ictlyh
ictlyh / libpq-demo.cc
Last active December 28, 2023 14:35
libpq examples.
/*
* Demo of libpq.
* Build: g++ libpq-demo.cc -o libpq-demo -lpq
* Run: ./libpq-demo
*/
#include <arpa/inet.h>
#include <iostream>
#include <libpq-fe.h>
#include <sstream>