Skip to content

Instantly share code, notes, and snippets.

View rhcarvalho's full-sized avatar
🎥
Building something new

Rodolfo Carvalho rhcarvalho

🎥
Building something new
View GitHub Profile
@rhcarvalho
rhcarvalho / test.yml
Created August 3, 2022 10:46
Building golangci-lint from source in a GitHub Workflow
# .github/workflows/test.yml
# ...
jobs:
# ...
lint-go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
@rhcarvalho
rhcarvalho / ctx.py
Created June 28, 2021 11:50
Python ContextVars don't propagate across exception handling boundaries
# coding: utf-8
import contextvars
import sys
v = contextvars.ContextVar('v')
v.set('global default')
def code():
print(f'before: v={v.get()}')
@rhcarvalho
rhcarvalho / main.go
Created June 15, 2021 15:02
Sentry Go SDK - how to manually propagate traces in arbitrary programs
// This is an example program that demonstrates how to continue a Sentry trace
// for a hypothetical and arbitrary job runner, not a typical web server.
//
// Try it by running:
//
// go run main.go new
// go run main.go 55c41d7f4727204c592c87974aa1eedb-01ae7746826ce117-1
//
// To actually report events to Sentry, set the DSN either by editing the
// appropriate line below or setting the environment variable SENTRY_DSN to
@rhcarvalho
rhcarvalho / main.go
Created September 3, 2020 10:12
Smart timestamps in Go: decode/encode JSON from Unix timestamp numbers or RFC3339 strings
// https://play.golang.org/p/wSZvxQbT3KY
package main
import (
"encoding/json"
"fmt"
"os"
"strconv"
"text/tabwriter"
@rhcarvalho
rhcarvalho / go.mod
Last active January 16, 2024 01:17
Example of using sentry-go and go-chi
module sentry.io/go/chi-example
go 1.13
require (
github.com/getsentry/sentry-go v0.4.0
github.com/go-chi/chi v4.0.3+incompatible
)
@rhcarvalho
rhcarvalho / main.go
Created December 6, 2019 14:24
Go cannot capture panics in arbitrary goroutines - https://play.golang.org/p/_YUfKreCkeY
package main
import (
"fmt"
)
func main() {
done := make(chan int)
defer func() {
<-done
@rhcarvalho
rhcarvalho / main.dart
Created February 11, 2019 10:40
Dart constructors are not really functions
class Greeter {
final String name;
Greeter(this.name);
Greeter.withName(this.name);
static Greeter staticWithName(String name) {
return Greeter(name);
}
void greet(String who) {
@rhcarvalho
rhcarvalho / README.md
Created February 2, 2017 09:04
DojoTimer helper for Linux

DojoTimer helper for Linux

This script is used to launch DojoTimer on Linux/Mono.

Place both dojotimer and dojotimer.exe in one of the directories in your $PATH. I place then in ~/bin.

Now, from the working directory of your dojo, where you will have your tests and implementation, run:

dojotimer .
@rhcarvalho
rhcarvalho / .gitconfig
Created November 6, 2016 09:36
Git config for large repositories
# This file represents part of the .git/config file for a given repository.
# The settings below allow git-pack-objects to work on large repositories (e.g., Kubernetes, OpenShift Origin, ...).
[core]
packedGitLimit = 4g
[pack]
windowMemory = 256m
# packSizeLimit = ...
@rhcarvalho
rhcarvalho / old.sh
Created November 5, 2016 19:29
List old files in a Git repository by last modification date
git ls-tree -r --name-only HEAD | while read filename; do
echo "$(git log -1 --format="%ad" --date=short -- $filename) $filename";
done | sort | head -20