Skip to content

Instantly share code, notes, and snippets.

View mpoullet's full-sized avatar

Matthieu Poullet mpoullet

View GitHub Profile
@hosct
hosct / ctBiosKey.cpp
Last active January 5, 2024 23:03
ctBiosKey
#include <iostream>
#include <Windows.h>
int main()
{
DWORD firmwareTableProviderSignature = 0x41435049; // "ACPI"
DWORD firmwareTableMSDMID = 0x4d44534d; // "MSDM"
UINT structSize = EnumSystemFirmwareTables(firmwareTableProviderSignature, NULL, 0);
if (structSize == 0) {
@dimo414
dimo414 / _README.md
Last active November 28, 2022 07:25
Bash array expansion patterns for use with -u

Expanding Bash arrays safely with set -u

Prior to Bash 4.4 set -u treated empty arrays as "unset", and terminates the process. There are a number of possible workarounds using array parameter expansion, however almost all of them fail in certain Bash versions.

This gist is a supplement to this StackOverflow post.

@mblondel
mblondel / check_convex.py
Last active March 21, 2022 22:25
A small script to get numerical evidence that a function is convex
# Authors: Mathieu Blondel, Vlad Niculae
# License: BSD 3 clause
import numpy as np
def _gen_pairs(gen, max_iter, max_inner, random_state, verbose):
rng = np.random.RandomState(random_state)
# if tuple, interpret as randn
@fosterbrereton
fosterbrereton / better_macros_better_flags.cpp
Last active April 28, 2024 15:20
Companion source code for the article "Better Macros, Better Flags."
/*
MIT License
Copyright 2019 Foster T. Brereton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
createStrippedAndDebugInfo() {
cd ${REPO_PATH} # assuming we're in your repository's directory
ANDROID_NDK=<PATH_TO_NDK>
TMP_DIR_NAME=tmp_strip_symbols
AAR=`find -name '*.aar'` # find the path to the AAR containing the binaries
mkdir -p ${TMP_DIR_NAME}
try cd ${TMP_DIR_NAME}

Discovering the Fourier Transform: A Tutorial on Circulant Matrices, Circular Convolution, and the DFT

Summary

  • Discrete Fourier Transform (DFT) arises naturally out of analysis of circulant matrices
  • DFT can be derived as the change of basis that simultaneously diagonalizes all circulant matrices
@puffybsd
puffybsd / launch.json
Last active July 7, 2022 11:56
VSCode launcher for rust using lldb
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug-LLDB",
"type": "lldb",
"request": "launch",
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active July 17, 2024 07:40
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@wallneradam
wallneradam / pkguninst.sh
Created January 18, 2018 01:03
MacOS Package Uninstaller
#!/bin/bash
############################################################
### Shell script to uninstall Mac Os X packages ###
### Based on pkgutil. ###
### Created by Adam Wallner <adam.wallner at gmail.comu> ###
### V1.0.1 ###
############################################################
IFS=$'\n'
function get_pkgid {