Skip to content

Instantly share code, notes, and snippets.

@egmontkob
egmontkob / Hyperlinks_in_Terminal_Emulators.md
Last active May 21, 2024 17:20
Hyperlinks in Terminal Emulators

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.

@mgoodness
mgoodness / k8s-svc-annotations.md
Last active March 11, 2024 16:24
AWS ELB-related annotations for Kubernetes Services (as of v1.12.0)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-emit-interval (in minutes)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-enabled (true|false)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-name
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-prefix
  • service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags (comma-separated list of key=value)
  • service.beta.kubernetes.io/aws-load-balancer-backend-protocol (http|https|ssl|tcp)
  • service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled (true|false)
@ahmdrz
ahmdrz / dump.go
Created September 23, 2016 08:07
Golang Reflection Example of an array.
package main
import (
"fmt"
"reflect"
)
type Test struct {
Name string
}
@steinwaywhw
steinwaywhw / One Liner to Download the Latest Release from Github Repo.md
Last active May 22, 2024 10:23
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@andyshinn
andyshinn / composer.json
Last active February 18, 2024 12:05
Docker Compose PHP Composer Example
{
"require": {
"mfacenet/hello-world": "v1.*"
}
}
@kkiernan
kkiernan / vuejs-filter-snake-to-title.js
Last active December 6, 2021 12:34
A Vue.js filter that converts snake case to title case.
/**
* Converts a snake case string to title case.
* Example: snake_case => Snake Case
*
* @param {String} str the string to convert
* @return {String}
*/
Vue.filter('snakeToTitle', function (str) {
return str.split('_').map(function (item) {
return item.charAt(0).toUpperCase() + item.substring(1);
@coderofsalvation
coderofsalvation / export_process
Last active February 22, 2022 15:38
updates an environment variable of a running process
# updates an environment variable of a running process (needs sudo)
# example: sudo export_pid <variable=value> <pid>
export_process(){
script=/tmp/.gdb.$2
echo -e "attach $2\ncall putenv (\"$1\")\ndetach\n" > $script
gdb -q -batch -x $script &>/dev/null
rm $script
}

Deploy your site with git securely

This gist assumes:

  • you have a local git repo
  • you have an online remote repository (github)
  • you have a server running Apache with git already installed

you should be able to do the same with Java, Perl, RoR, JSP etc. however you'll need to recreate the (rather simple) PHP script

@hnakamur
hnakamur / main.go
Last active February 12, 2023 00:15
A go example to stop a worker goroutine when Ctrl-C is pressed (MIT License)
package main
import (
"fmt"
"os"
"os/signal"
"time"
"golang.org/x/net/context"
)