Skip to content

Instantly share code, notes, and snippets.

View sebnyberg's full-sized avatar
🇸🇪

Sebastian Nyberg sebnyberg

🇸🇪
View GitHub Profile
@amitz
amitz / BUILD
Last active December 14, 2021 16:00
Building gRPC Gateway Binary Using Bazel using 'grpc-gateway'
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_binary")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
##########
# Common #
##########
proto_library(
name = "project_proto",
srcs = [
"project.proto",
@dasMulli
dasMulli / DemoSetup.wixproj
Last active February 21, 2022 07:22
Demo wix project to publish a self-contained .NET Core app
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>91e4dc15-312a-4e90-bc1c-01de5dc99447</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>CoreConsoleAppSetup</OutputName>
<OutputType>Package</OutputType>
@sjparkinson
sjparkinson / RDS-Aurora-CloudFormation-Example.yaml
Last active May 10, 2022 10:43
A basic CloudFormation template for an RDS Aurora cluster.
---
AWSTemplateFormatVersion: 2010-09-09
Description: >
A basic CloudFormation template for an RDS Aurora cluster.
Parameters:
DatabaseUsername:
AllowedPattern: "[a-zA-Z0-9]+"
ConstraintDescription: must be between 1 to 16 alphanumeric characters.
@danielwhite
danielwhite / go-bench.sh
Created April 28, 2017 00:45
Benchmarking Golang with benchstat
#!/bin/bash
#
# Generate benchmark files in a Git repository.
#
# Usage: TIMES=1 go-bench [prefix]
#
# Number of times to run the benchmark; useful for benchstat.
TIMES=${TIMES:-1}
@sebnyberg
sebnyberg / cert.sh
Created September 21, 2021 21:15
Create Kubernetes certs using openssl
#!/local/bin/env bash
#
# Create certs
#
set -eux
# Create Root CA cert
ca="rootca"
cat > $ca.conf << EOM
[ req ]
@sebnyberg
sebnyberg / go_cpu_memory_profiling_benchmarks.sh
Last active March 6, 2023 11:10 — forked from arsham/go_cpu_memory_profiling_benchmarks.sh
Go cpu and memory profiling benchmarks. #golang #benchmark
FILENAME=$(basename $(pwd))
go test -run=. -bench=. -cpuprofile=cpu.out -benchmem -memprofile=mem.out -trace trace.out
go tool pprof -pdf $FILENAME.test cpu.out > cpu.pdf && open cpu.pdf
go tool pprof -pdf --alloc_space $FILENAME.test mem.out > alloc_space.pdf && open alloc_space.pdf
go tool pprof -pdf --alloc_objects $FILENAME.test mem.out > alloc_objects.pdf && open alloc_objects.pdf
go tool pprof -pdf --inuse_space $FILENAME.test mem.out > inuse_space.pdf && open inuse_space.pdf
go tool pprof -pdf --inuse_objects $FILENAME.test mem.out > inuse_objects.pdf && open inuse_objects.pdf
go tool trace trace.out
go-torch $FILENAME.test cpu.out -f ${FILENAME}_cpu.svg && open ${FILENAME}_cpu.svg
@yefim
yefim / Dockerrun.aws.json
Last active April 7, 2023 16:11
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<NAME>:<TAG>",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "443"
}
@LouisAmon
LouisAmon / avro_to_dataframe.py
Created January 15, 2017 11:55
Read Avro file from Pandas
import pandas
import fastavro
def avro_df(filepath, encoding):
# Open file stream
with open(filepath, encoding) as fp:
# Configure Avro reader
reader = fastavro.reader(fp)
# Load records in memory
records = [r for r in reader]
@arsham
arsham / go_cpu_memory_profiling_benchmarks.sh
Last active November 20, 2023 03:42
Go cpu and memory profiling benchmarks. #golang #benchmark
go test -run=. -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./package | tee bench.txt
go tool pprof -http :8080 cpu.out
go tool pprof -http :8081 mem.out
go tool trace trace.out
go tool pprof $FILENAME.test cpu.out
# (pprof) list <func name>
# go get -u golang.org/x/perf/cmd/benchstat
benchstat bench.txt