Skip to content

Instantly share code, notes, and snippets.

View rochacon's full-sized avatar

Rodrigo Chacon rochacon

  • Remote
  • 13:41 (UTC -03:00)
View GitHub Profile
@rochacon
rochacon / list-queues-sizes.ts
Last active March 16, 2024 22:08
Bun shell experiments
// this script lists all queues with a message count diferrent than 0
// usage: bun list-queues-sizes.ts
import { $ } from 'bun';
const queuesUrls = await $`aws sqs list-queues`.json();
const attrs = "QueueArn ApproximateNumberOfMessages ApproximateNumberOfMessagesNotVisible ApproximateNumberOfMessagesDelayed";
const queueAttributes = await Promise.all(queuesUrls.QueueUrls.map((url) => (
$`aws sqs get-queue-attributes --attribute-names ${{ raw: attrs }} --queue-url ${url}`.quiet().json()
)));
const output = queueAttributes.filter((e) => e.Attributes.ApproximateNumberOfMessages !== "0").map((e) => e.Attributes);
@rochacon
rochacon / wg-ns
Created December 8, 2023 17:25
wg-ns: wireguard network namespace setup helper
% cat bin/wg-ns
#!/bin/bash
set -exuo pipefail
name="${1?must provide name as argument}"
netns="${name}"
wg_conf="/etc/wireguard/wg.conf"
ipv4="$(grep Address "${wg_conf}" | grep -Po '([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\/32)')"
dnsaddr="$(grep DNS "${wg_conf}" | grep -Po '([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\/32)')"
@rochacon
rochacon / kshell
Last active December 8, 2023 17:44
kshell
#!/bin/bash
set -euo pipefail
test "${DEBUG:-false}" = "true" && set -x
USERNAME="${USER}"
NAMESPACE="${NS:-${USERNAME}}"
IMAGE="${IMAGE:-docker.io/pkgxdev/pkgx}"
ENV_FROM="${ENVFROM:-${NAMESPACE}}"
package main
import (
"flag"
"fmt"
"log"
"os"
"sort"
"strings"
"text/tabwriter"
@rochacon
rochacon / portscan.go
Created May 30, 2020 03:18
portscan a cidr block port
package main
import (
"flag"
"fmt"
"log"
"net"
"os"
"sync"
"time"

Keybase proof

I hereby claim:

  • I am rochacon on github.
  • I am rochacon (https://keybase.io/rochacon) on keybase.
  • I have a public key whose fingerprint is 1C1D A0A2 1A14 2267 1BBC 680B D2FF 14CE D133 597F

To claim this, I am signing this object:

@rochacon
rochacon / node-id.go
Created August 31, 2015 07:07
Simple Go app to print an UUID per instance. Useful to debug load balancers
package main
import (
"code.google.com/p/go-uuid/uuid"
"net/http"
)
var (
id []byte = []byte(uuid.New() + "\n")
)
@rochacon
rochacon / kubernetes-dev.yml
Last active March 5, 2017 13:21
Kubernetes single node cloud-config for CoreOS.
#cloud-config
---
hostname: master
coreos:
units:
- name: docker.service
command: start
enable: true
drop-ins:
@rochacon
rochacon / s3upload.py
Last active May 25, 2016 08:06
Simple script to upload a file to S3 using a pre-signed URL
#!/usr/bin/env python
# Reference: http://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html
import argparse
import os
import boto
import requests
if __name__ == '__main__':
@rochacon
rochacon / README.md
Created April 10, 2015 05:15
AUR Sync

aur-sync is a simple script to keep AUR packages up to date.

How to use it:

# 1. First you need to create some directories where the work will happen:
mkdir -p /tmp/aur-sync-ws
mkdir -p /tmp/aur-sync-ws/build
mkdir -p /tmp/aur-sync-ws/src
cd /tmp/aur-sync-ws