Skip to content

Instantly share code, notes, and snippets.

View sebnyberg's full-sized avatar
🇸🇪

Sebastian Nyberg sebnyberg

🇸🇪
View GitHub Profile
@sebnyberg
sebnyberg / ipow.c
Created February 6, 2022 16:21 — forked from orlp/ipow.c
int64_t ipow(int64_t base, uint8_t exp) {
static const uint8_t highest_bit_set[] = {
0, 1, 2, 2, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 255, // anything past 63 is a guaranteed overflow with base > 1
@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
@sebnyberg
sebnyberg / build.sh
Created October 3, 2019 07:03 — forked from bobbytables/build.sh
Protocol Buffer build script for multiple folders
#!/usr/bin/env bash
# This script is meant to build and compile every protocolbuffer for each
# service declared in this repository (as defined by sub-directories).
# It compiles using docker containers based on Namely's protoc image
# seen here: https://github.com/namely/docker-protoc
set -e
REPOPATH=${REPOPATH-/opt/protolangs}
CURRENT_BRANCH=${CIRCLE_BRANCH-"branch-not-available"}
@sebnyberg
sebnyberg / RDS-Aurora-CloudFormation-Example.yaml
Created February 6, 2018 15:40 — forked from sjparkinson/RDS-Aurora-CloudFormation-Example.yaml
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.
@sebnyberg
sebnyberg / introrx.md
Created October 24, 2017 11:47 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@sebnyberg
sebnyberg / Dockerfile
Last active October 27, 2020 21:34 — forked from yefim/Dockerrun.aws.json
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
# Example Dockerfile
FROM hello-world
@sebnyberg
sebnyberg / Decorators-For-React-Native-Instruction.md
Created September 7, 2017 16:17
How to setup decorators in React Native

Using decorators in React Native

  1. Install babel plugins to enable decorators.

    npm install babel-plugin-transform-decorators-legacy --save-dev
  2. Create or update your .babelrc file in root folder: