Skip to content

Instantly share code, notes, and snippets.

Pierre Fenoll fenollp

Block or report user

Report or block fenollp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fenollp
fenollp / capitalize_header_keys.ex
Created Jan 17, 2019
Phoenix: capitalize header keys
View capitalize_header_keys.ex
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 / wth.txt
Created Jun 12, 2018
T460 stuck in boot loop? Try disabling TPM
View wth.txt
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 / monkey_patching.go
Created Apr 29, 2018
Monkey patching idea in Golang
View monkey_patching.go
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 Mar 31, 2018
Writing a single common CLI for all/most CI/CD providers
View CIs_CLI.md

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)
@fenollp
fenollp / update-main-binary.md
Created Jan 23, 2018
How to self-upgrade/swap a running binary in Golang
View update-main-binary.md

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
View conan_windows_onlinux_voidstar.log
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++
View keybase.md

Keybase proof

I hereby claim:

  • I am fenollp on github.
  • I am fenollp (https://keybase.io/fenollp) on keybase.
  • I have a public key ASAPCTAJhxr4eoNo_rM7TwkuQ_fPQZ3GSXnP4pijTX7laQo

To claim this, I am signing this object:

@fenollp
fenollp / func.ged.sh
Created Nov 10, 2017
git sed s%pattern%replacement%flags [-- git-grep flags]
View func.ged.sh
#!/bin/bash
ged() {
local sprf="$1" ; shift
[[ "$sprf" == 's%'* ]] || return 10 # MUST be s%p%r%f
local p="$(echo "$sprf" | cut -d% -f2)"
[[ "$p" == '' ]] && return 11
if git status --porcelain | grep '^ ' | grep .; then return 12; fi
local git_grep='git grep -IE'
local f="$(echo "$sprf" | cut -d% -f4)"
@fenollp
fenollp / pp_stack_inside_try_catch.erl
Created Aug 23, 2017
Test printing ST with -Wall & OTP20
View pp_stack_inside_try_catch.erl
%% Copyright © 2017 Pierre Fenoll ‹pierrefenoll@gmail.com›
%% See LICENSE for licensing information.
%% -*- coding: utf-8 -*-
%% @module Test printing ST with -Wall & OTP20
-module(pp_stack_inside_try_catch).
-export([m/1]).
@fenollp
fenollp / compile.log
Created Aug 20, 2016
rebar3 error erldocs_other
View compile.log
0 erldocs_other.git master (19.0) ∀ DEBUG=1 rebar3 compile
===> Expanded command sequence to be run: [{default,app_discovery},
{default,install_deps},
{default,lock},
{default,compile}]
===> Verifying dependencies...
===> Fetching erldocs ({git,"git://github.com/rebar/rebar.git",
{ref,
"1387a83e24eba0a794e9890c3351871a0fb7262e"}})
===> sh info:
You can’t perform that action at this time.