Skip to content

Instantly share code, notes, and snippets.

View kwilczynski's full-sized avatar
🐧
Have you built a Linux kernel recently?

Krzysztof Wilczyński kwilczynski

🐧
Have you built a Linux kernel recently?
  • Yokohama, Japan
  • 10:21 (UTC +09:00)
View GitHub Profile
ARG go_version=1.11.3
ARG alpine_version=latest
FROM golang:${go_version}-alpine AS builder
ENV GOPATH /build
ENV GOOS linux
ENV GOARCH amd64
ENV CGO_ENABLED 0
@kwilczynski
kwilczynski / dynamodb-usage.sh
Created January 30, 2019 16:00
Print metrics for DynamoDB table and secondary indexes to show provisioned capacity usage.
#!/bin/bash
set -Eeuf
set -o pipefail
PERIOD=${PERIOD-'3600'}
DAYS_AGO=${DAYS_AGO-'30'}
AWS_DEFAULT_REGION="$1"
shift
@nicebyte
nicebyte / dyn_arr.h
Last active February 25, 2025 10:29
dyn_arr
#pragma once
#define DYN_ARR_OF(type) struct { \
type *data; \
type *endptr; \
uint32_t capacity; \
}
#if !defined(__cplusplus)
#define decltype(x) void*
@antonbabenko
antonbabenko / ecs-codedeploy
Last active November 16, 2022 23:25
This script performs deployment of ECS Service using AWS CodeDeploy
#!/usr/bin/env bash
#######################################################################
# This script performs deployment of ECS Service using AWS CodeDeploy
#
# Heavily inspired by https://github.com/silinternational/ecs-deploy ,
# which unfortunately can't be used to deploy ECS service when `deployment_option=ECS`
#
# Author: Anton Babenko
# URL: https://github.com/antonbabenko
@pamolloy
pamolloy / README.md
Last active October 16, 2024 20:40
Ubiquiti USG configuration for Wireguard

Download the latest ugw3 package from https://github.com/Lochnair/vyatta-wireguard/releases and install it on your USG using dpkg -i wireguard-ugw3-<version>.deb.

cd /config/auth
umask 077
mkdir wireguard
cd wireguard
wg genkey > wg_private.key
wg pubkey < wg_private.key > wg_public.key
@lummie
lummie / custom_time.go
Last active August 14, 2024 14:14
Golang custom date / time formats when marshalling to JSON
// CustomTime provides an example of how to declare a new time Type with a custom formatter.
// Note that time.Time methods are not available, if needed you can add and cast like the String method does
// Otherwise, only use in the json struct at marshal/unmarshal time.
type CustomTime time.Time
const ctLayout = "2006-01-02 15:04:05 Z07:00"
// UnmarshalJSON Parses the json string in the custom format
func (ct *CustomTime) UnmarshalJSON(b []byte) (err error) {
@kwilczynski
kwilczynski / main.go
Last active November 30, 2021 20:10
A small parser for a grammar used to filter EC2 instances based on their tags. Inspired by Ansible.
package main
import (
"crypto/sha1"
"fmt"
"regexp"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
@kwilczynski
kwilczynski / main.go
Created October 24, 2018 01:48
Kingpin multiple filters
package main
import (
"fmt"
"github.com/davecgh/go-spew/spew"
"gopkg.in/alecthomas/kingpin.v2"
)
type Config struct {
@kwilczynski
kwilczynski / dynamodb-setup.sh
Last active January 14, 2024 15:22
Quickly automatically associate Elastic IP address with the current EC2 instance written in Go.
aws dynamodb create-table --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --attribute-definitions "AttributeName=key,AttributeType=S" --key-schema "AttributeName=key,KeyType=HASH" --billing-mode "PAY_PER_REQUEST"
aws dynamodb create-table --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --attribute-definitions "AttributeName=key,AttributeType=S" --key-schema "AttributeName=key,KeyType=HASH" --billing-mode "PROVISIONED" --provisioned-throughput "ReadCapacityUnits=1,WriteCapacityUnits=1"
aws dynamodb update-time-to-live --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --time-to-live-specification "Enabled=true,AttributeName=ttl"
aws dynamodb scan --region <REGION> --profile <PROFILE> --table-name "<TABLE>"
@notpushkin
notpushkin / build_pa_ldac.sh
Last active May 2, 2021 01:46
pulseaudio-module-bluetooth with LDAC support for Ubuntu and (untested) Debian · https://files.catbox.moe/i1tsk1.deb
PULSE_VERSION="$(pkg-config libpulse --modversion)"
PACKAGE_DIR="$(mktemp -d)"
SRC_DIR="$(mktemp -d)"
if [[ "x${PULSE_VERSION}x" == "x11.1x" ]]; then
git clone --depth=1 --branch=pulseaudio_v11.x https://github.com/EHfive/pulseaudio-modules-bt.git "${SRC_DIR}"
else
git clone --depth=1 https://github.com/EHfive/pulseaudio-modules-bt.git "${SRC_DIR}"
fi