Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cirocosta's full-sized avatar

Ciro S. Costa cirocosta

View GitHub Profile
package main
import (
"context"
"fmt"
"time"
)
func sleepHalfTheTime(ctx context.Context, total time.Duration) {
time.Sleep(total >> 1)
@cirocosta
cirocosta / setenv-sample.c
Created December 23, 2019 15:26
setenv-sample.c
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void handle_sig(int sig) {}
void wait_a_bit() {
if (signal(SIGINT, handle_sig) == SIG_ERR) {
perror("signal");
@cirocosta
cirocosta / USAGE
Last active October 21, 2020 11:53
example showing how MADV_FREE does not incur in RSS reduction right away
1. compile it
gcc -O2 -static -o sample ./madvise-sample.c
2. run it in a terminal that has the current proc in a cgroup
mkdir /sys/fs/cgroup/memory/test
echo $$ > /sys/fs/cgroup/memory/test/cgroup.procs
./sample
3. in another terminal, observe `memory.stat` for that cgroup
cat /sys/fs/cgroup/memory/test/memory.stat
@cirocosta
cirocosta / quick-sync-counter.py
Last active November 23, 2019 17:26
counts quick uses of `sync` - modified version from `iovisor/bcc` to keep track of statistics
#!/usr/bin/python
# hello-sync.py Detect quick uses of `sync`
#
# The program detects when two `sync()` calls get issued within a 1s delta.
#
# For instance, `sync; sleep 2; sync` will count `quick` as 0, but `sync;sync;sync`
# will.
#
# Example output:
@cirocosta
cirocosta / list
Created November 6, 2019 19:10
about:* firefox
about: — The same page as "Help -> About" (except that, on some applications, Help → About is a much smaller popup).
about:about — Lists all these about: URLs (Mozilla Suite/SeaMonkey or Firefox 4 and newer only).
about:accounts — Firefox Sync account. New on Firefox 29. [1][2]
about:addons — The "new" addons manager, in trunk builds dated 2010-05-11 or later.
about:app-manager — new on Firefox 26. App Manager, a tool to help users build and install web apps on compatible devices (i.e. Firefox OS).
about:buildconfig — Reveals details about your Mozilla build options.
about:cache — Displays cache statistics and disk cache directory location.
about:cache?device=memory — Lists memory cache entries.
about:cache?device=disk — Lists disk cache entries.
about:cache-entry — Shows information about a cache entry. Used in about:cache links. Requires parameters.
@cirocosta
cirocosta / bench_test.go
Last active October 30, 2019 12:36
benchmarking who's faster: checking elapsed time (in intervals) with `time.Now().Sub()`, or using a `time.Ticker`
package main_test
import (
"time"
"testing"
)
type TimeNowChecker struct {
lastTime time.Time
interval time.Duration
@cirocosta
cirocosta / blog-note.sh
Created October 26, 2019 19:54
no-execuses blogging 😅
#!/bin/bash
set -o errexit
set -o xtrace
readonly dir=/Users/cirocosta/cirocosta/blog/content/notes
main() {
case $1 in
@cirocosta
cirocosta / docker-compose.yml
Created October 16, 2019 12:59
a three-worker Concourse `docker-compose.yml` with Jaeger
version: '3'
services:
db:
image: postgres
ports:
- 6543:5432
environment:
POSTGRES_DB: concourse
POSTGRES_USER: dev
@cirocosta
cirocosta / Dockerfile
Created July 14, 2019 20:39
An example of how to build the `concourse/concourse` image with a modified `gdn`
FROM golang AS base
RUN apt update && \
apt install -y \
git gcc libseccomp-dev
ENV \
CC=gcc \
CGO_ENABLED=1
@cirocosta
cirocosta / test-execution-14945
Created June 20, 2019 18:29
test-execution-14945
Running in parallel across 6 nodes
• [SLOW TEST:57.335 seconds]
Main team role config
/Users/cirocosta/workspace/concourse/topgun/k8s/mainteam_role_test.go:11
Adding team role config yaml to web
/Users/cirocosta/workspace/concourse/topgun/k8s/mainteam_role_test.go:45
returns the correct user role
/Users/cirocosta/workspace/concourse/topgun/k8s/mainteam_role_test.go:74
------------------------------