Skip to content

Instantly share code, notes, and snippets.

View trungie's full-sized avatar

Trung Hoang trungie

View GitHub Profile
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing

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.

@guitarrapc
guitarrapc / _get_github_oidc_thumbprint.sh
Last active May 2, 2024 13:55
Get Thumbprint of GitHub OIDC, updated on 2022/01/13.
$ openssl s_client -servername token.actions.githubusercontent.com -showcerts -connect token.actions.githubusercontent.com:443 < /dev/null 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sed "0,/-END CERTIFICATE-/d" > certificate.crt
$ openssl x509 -in certificate.crt -fingerprint -noout | cut -f2 -d'=' | tr -d ':' | tr '[:upper:]' '[:lower:]'
6938fd4d98bab03faadb97b34396831e3780aea1
@liudong
liudong / gist:3993726
Created November 1, 2012 13:49
Java: Generate Public/Private Keys
import java.security.KeyPairGenerator;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.KeyFactory;
import java.security.spec.EncodedKeySpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.NoSuchAlgorithmException;
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@staringispolite
staringispolite / asciiputsonglasses
Last active March 22, 2024 06:39
Ascii art sunglasses meme
Puts on glasses:
(•_•)
( •_•)>⌐■-■
(⌐■_■)
Takes off glasses ("mother of god..."):
(⌐■_■)
( •_•)>⌐■-■
@shmup
shmup / twitch_irssi.md
Last active March 19, 2024 11:50 — forked from hunterbridges/twitch_irc.md
How to connect to Twitch with IRSSI (SSL)

IRSSI / TWITCH

Here's a method to chat in a twitch #channel with IRSSI

Get your oauth token here: https://twitchapps.com/tmi/

Server block

server = {
 address = "irc.chat.twitch.tv";
@kevin-lee
kevin-lee / JProfiler-with-Docker.md
Created August 10, 2016 15:55
JVM Profiler with Docker

JProfiler with Docker

Docker

DockerFile

DockerFile should have JProfiler installation.

RUN wget <JProfiler file location> -P /tmp/ && \
  tar -xzf /tmp/<JProfiler file> -C /usr/local && \
  rm /tmp/<JProfiler file>
@glnds
glnds / aws-transfer-sftp.yaml
Last active February 23, 2024 09:53
CloudFormation template for AWS Transfer for SFTP
---
AWSTemplateFormatVersion: '2010-09-09'
Description: some-sftp-server
Parameters:
HostedZoneIdParam:
Type: String
Description: Hosted Zone ID
SFTPHostnameParam:
Type: String