Skip to content

Instantly share code, notes, and snippets.

View annismckenzie's full-sized avatar

Daniel Lohse annismckenzie

View GitHub Profile
@ctron
ctron / user-data.yml
Last active May 4, 2022 04:30
Reserving additional space on Hetzner cloud instances using CentOS 7
#cloud-config
# we need to disable the initial call to "growpart" as otherwise the first partition would consume
# all space on the dist
#
# The final disk layout is:
# #0 0 - 10GB - ext4 on /
# #1 10GB - 100% - lvm
#
# The reason for this approach is that when using CentOS on Hetzner you cannot use
@carlosedp
carlosedp / gist:5040f4a1b2c97c1fa260a3409b5f14f9
Created February 19, 2018 20:01
Reset Kubernetes cluster with Weave
# Drain and delete the nodes (for each node you have)
kubectl drain kubenode1 --delete-local-data --force --ignore-daemonsets
kubectl delete node kubenode1
# Reset the deployment
sudo kubeadm reset
# On each node
## Reset the nodes and weave

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

Set up InfluxDB, Grafana and Telegraf for LeoFS's Storage (Ubuntu)

Install influxdb

$ wget https://s3.amazonaws.com/influxdb/influxdb_nightly_amd64.deb
$ sudo dpkg -i influxdb_nightly_amd64.deb
$ sudo service influxdb start

Install Grafana

@paulirish
paulirish / what-forces-layout.md
Last active June 19, 2024 15:52
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@dreamcat4
dreamcat4 / debug.sh
Last active April 27, 2019 07:32
entrypoint script to take core files, and another script to take a stacktrace (while program is hung running, deadlocked / live-locked)
#!/bin/bash
# Tvheadend Debugging Guide
# https://tvheadend.org/projects/tvheadend/wiki/Debugging
_cleanup ()
{
if [ "$core_pattern_orig" ]; then
# Restore core path
echo "$core_pattern_orig" > /proc/sys/kernel/core_pattern

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style