Skip to content

Instantly share code, notes, and snippets.

View aerostitch's full-sized avatar

aerostitch aerostitch

View GitHub Profile
@aerostitch
aerostitch / test_errgroup_context.go
Created January 3, 2020 22:43
Just verifying that the WithContext does not abort the other goroutines in an errgroup
package main
import (
"context"
"fmt"
"math/rand"
"time"
"golang.org/x/sync/errgroup"
)
@aerostitch
aerostitch / Makefile
Last active October 22, 2019 07:58
Testing out cunit
all:
gcc -g -Wall -c search.c -lcunit -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lglib-2.0
gcc -g -Wall test_search.c search.o -lcunit -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lglib-2.0 -o test_search
./test_search && rm search.o test_search
@aerostitch
aerostitch / slab.com_curl_api_examples.sh
Last active June 17, 2019 19:20
Examples of usage of the slab.com api using curl
# This is a list of examples on how to interact with the slab.com API using curl.
# The original documentation is https://the.slab.com/public/slab-api-vk0o0i33 but missing good examples
# so I figured I'd keep that one here for future reference
SLAB_TOKEN=<PLACE_YOUR_TOKEN_HERE>
# Get the organization domain
curl -s -X POST \
-H "Authorization: ${SLAB_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"query":"query { organization { host } }"}' \
# reports the number of occurences of an IP in aws ELB access logs files
awk '{match($3, /(.*):.*/,arr);k=arr[1];if(k in counter){counter[k]++}else{counter[k]=1}} END {for(i in counter){printf "%d \t %s\n",counter[i],i}}' *.log | sort -n
@aerostitch
aerostitch / terraform_import_github_resources.sh
Last active May 17, 2018 06:13
Import github resources in terraform
export ORG=VEVO
# generate import commands for users in the org
# /!\ Note the parge_arg, this one looks for the page number 2 of the list
export page_arg="page=2"
curl -s -H "Authorization: token ${GITHUB_AUTH_TOKEN}" https://api.github.com/orgs/VEVO/members?${page_arg} | jq -r '.[]| "terraform import github_membership.\(.login) VEVO:\(.login)"'
# generate import commands for teams in the org
# /!\ Note the parge_arg, this one looks for the page number 2 of the list
export page_arg="page=2"
curl -s -H "Authorization: token ${GITHUB_AUTH_TOKEN}" https://api.github.com/orgs/${ORG}/teams?${page_arg} | jq -r '.[]| "terraform import github_team.\(.slug) \(.id)"'
@aerostitch
aerostitch / go-github_usage.go
Last active March 29, 2018 22:39
Usage example of creating a repo and pushing several files inside a single commit (for just 1 file, the contents api is easier to use)
package main
import (
"context"
"errors"
"time"
"github.com/google/go-github/github"
"golang.org/x/oauth2"
)
---
apiVersion: batch/v2alpha1
kind: CronJob
metadata:
name: dynamodbdump-mytable
namespace: myteam
spec:
failedJobsHistoryLimit: 5
successfulJobsHistoryLimit: 10
schedule: 0 2 * * *
@aerostitch
aerostitch / dynamodbdump_example_restore.sh
Last active February 5, 2018 22:44
Example of how to restore a DynamoDB table from S3 using dynamodbdump
git clone https://github.com/VEVO/dynamodbdump.git
cd dynamodbdump
make build
# Now just restore the table:
./dynamodbdump -action restore \
-dynamo-table mynewtable \
-wait-ms 800 \
-batch-size 100 \
-restore-append \
-s3-bucket my-dynamo-backup-bucket \
@aerostitch
aerostitch / dynamodbdump_example_backup.sh
Last active February 5, 2018 22:44
Example of how to backup a DynamoDB table to S3 using dynamodbdump
git clone https://github.com/VEVO/dynamodbdump.git
cd dynamodbdump
make build
# Now just take a backup
./dynamodbdump -action backup \
-dynamo-table mytable \
-wait-ms 2000 \
-batch-size 1000 \
-s3-bucket my-dynamo-backup-bucket \
-s3-folder "backups/mytable" \
#!/bin/bash
# This script's purpose is to test the response time on a url
# by doing a simple curl loop (no pause, so a bit hammering).
# It returns the several curl metrics in a csv file for further analysis.
#
TO="localhost"
OUTFILE="$(date +%Y%m%d%H%M)_curl_test_from_$(hostname)_to_${TO}.csv"
CURLURI="http://${TO}/crossdomain.xml"
CURLFORMAT='\n%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total},%{num_connects},%{num_redirects}'
ITERATIONS=100000