Skip to content

Instantly share code, notes, and snippets.

View fenollp's full-sized avatar

Pierre Fenoll fenollp

View GitHub Profile
@fenollp
fenollp / update-main-binary.md
Created January 23, 2018 15:48
How to self-upgrade/swap a running binary in Golang

How to self-upgrade/swap a running binary in Golang

You are writing a CLI client in Go and your users would love to be able to update this client seamlessly.

I'm talking replacing a currently running executable on UNIX platforms.

Using exec

// exa.go
@fenollp
fenollp / wth.txt
Created June 12, 2018 22:42
T460 stuck in boot loop? Try disabling TPM
If your thinkpad T460 is somehow stuck in a reboot cycle
* right after a storm
* even though your SSD / peripherals work fine on other laptops
* even after trying everything forums & youtube has to offer
* even after buying a non functional motherboard from Moldavia from [this guy](https://www.ebay.com/usr/goodwinflat)
* even after expecting that previous idea would work somehow
well then try disabling anything you can in your BIOS.
If you can't even get to BIOS you have bigger issues. Maybe power? Probably motherboard.
Turns out, for me, disabling the Intel Trusted execution things (TPM, TXT, ...) solved it!
@fenollp
fenollp / gpu.sh
Created June 9, 2020 09:42
Run FacialSearch app on GPU with Bazel
bazel run --platform_suffix=_gpu \
--copt=-fdiagnostics-color=always --run_under="cd $PWD && " \
-c opt --copt -DMESA_EGL_NO_X11_HEADERS --copt -DEGL_NO_X11 \
mediapipe/examples/facial_search/desktop:facial_search \
-- \
--calculator_graph_config_file=mediapipe/examples/facial_search/graphs/facial_search.pbtxt \
--images_folder_path=mediapipe/examples/facial_search/images/
@fenollp
fenollp / cpu.sh
Created June 9, 2020 09:42
Run FacialSearch app on CPU with Bazel
bazel run --platform_suffix=_cpu \
--copt=-fdiagnostics-color=always --run_under="cd $PWD && " \
-c opt --define MEDIAPIPE_DISABLE_GPU=1 \
mediapipe/examples/facial_search/desktop:facial_search \
-- \
--calculator_graph_config_file=mediapipe/examples/facial_search/graphs/facial_search.pbtxt \
--images_folder_path=mediapipe/examples/facial_search/images/
@fenollp
fenollp / wut.sh
Created March 30, 2020 15:49
macOS (BSD) `grep` bug (incompatibility) when using `-mX` with `-Ay` (but not with `-By` nor `-Cy`)
grep --version && uname -v
# grep (BSD grep) 2.5.1-FreeBSD
# Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64
grep -A1 -E "urls = \[" */WORKSPACE
# example_http_archive_locked/WORKSPACE: urls = [
# example_http_archive_locked/WORKSPACE- "https://github.com/bazelbuild/bazel-skylib/releases/download/0.8.0/bazel-skylib.0.8.0.tar.gz",
#but:
grep -m1 -A1 -E "urls = \[" */WORKSPACE
@fenollp
fenollp / capitalize_header_keys.ex
Created January 17, 2019 09:40
Phoenix: capitalize header keys
defmodule CapitalizeHeaderKeys do
def hook(status, headers, body, req) do
headers = capitalize_resp_headers(headers)
{:ok, req} = :cowboy_req.reply(status, headers, body, req)
req
end
# Cowboy v1
defp capitalize_resp_headers(headers) when is_list(headers) do
:lists.keymap(&:cowboy_bstr.capitalize_token/1, 1, headers)
@fenollp
fenollp / monkey_patching.go
Created April 29, 2018 20:26
Monkey patching idea in Golang
package main
import "fmt"
import "bytes"
func (* bytes.Buffer) Eh() string {
return "yay"
}
func main() {
fmt.Println("hey!")
@fenollp
fenollp / CIs_CLI.md
Last active March 31, 2018 10:30
Writing a single common CLI for all/most CI/CD providers

Writing a single common CLI for all/most CI/CD providers

Let's do this!

Usability requirements

  1. multiplatform + installation --> use Golang or Rust
  2. easy for others to PR/MR --> Golang then
  3. useful exit codes
  4. lots of streaming things (at least logs. at least of least a "streamed" travis show)
0 voidstar.git conan (20.2) ∀ ./dockcross bash -c 'mkdir build && cd build && conan install --build -- .. && cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build .'
Auto detecting your dev setup to initialize the default profile (/home/pete/.conan/profiles/default)
CC and CXX: /usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-gcc, /usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-g++
Found gcc 5.4
Default settings
os=Linux
arch=x86_64
compiler=gcc
compiler.version=5.4
compiler.libcxx=libstdc++