Skip to content

Instantly share code, notes, and snippets.

View philipjkim's full-sized avatar

Soo Philip Jason Kim philipjkim

View GitHub Profile
@magnetikonline
magnetikonline / README.md
Last active August 27, 2025 06:08
Setting Nginx FastCGI response buffer sizes.
@brandonmwest
brandonmwest / example.cs
Last active October 4, 2025 15:25
Generating base64-encoded Authorization headers in a variety of languages
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));
@john2x
john2x / 00_destructuring.md
Last active November 21, 2025 02:39
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@vdw
vdw / gist:09efee4f264bb2630345
Last active January 31, 2023 08:55
Kill tcp connection with tcpkill on CentOS

Install tcpkill
yum -y install dsniff --enablerepo=epel

View connections
netstat -tnpa | grep ESTABLISHED.*sshd.

Block with ip tables
iptables -A INPUT -s IP-ADDRESS -j DROP

Kill connection

@hoitomt
hoitomt / log_request.go
Created January 30, 2015 12:56
Golang: Log HTTP Requests in Go
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
@KoFish
KoFish / rmq-dlx.md
Last active August 21, 2023 05:57
RabbitMQ - Delay message by dead letter exchange

Delay queuing of messages in RabbitMQ/AMQP

Since RabbitMQ (and AMQP) have no specialized functionality for delay adding a message to the queue a dead-letter exchange can be used instead. This works by having two separate exchanges, one "worker exchange" and one "delay exchange", and one queue for each exchange. For each exchange and queue pair a binding has to be setup that specifies the same routing key for both exchanges.

The consumer

The consumer listens to the worker queue and any delayed message is added to the delay queue with the specified routing key and a expiration time. Instead of per-message expiration the delay queue can also specify a x-message-ttl that applies to all messages going in to it. When the message expires it will be reaped by RabbitMQ and put into the specified dead-letter exchange, the worker exchange in this case, and the routing key will direct it to the worker queue for consumption.

Delayed retry

@mikberg
mikberg / connection.js
Last active December 29, 2021 16:57
MongoDB connection with async/await
import { MongoClient } from 'mongodb';
import promisify from 'es6-promisify';
let _connection;
const connect = () => {
if (!process.env.MONGO_CONNECTION_STRING) {
throw new Error(`Environment variable MONGO_CONNECTION_STRING must be set to use API.`);
}
@adrianhall
adrianhall / .eslintrc.js
Last active September 17, 2025 08:24
A sample .eslintrc file
var OFF = 0, WARN = 1, ERROR = 2;
module.exports = exports = {
"env": {
"es6": true
},
"ecmaFeatures": {
// env=es6 doesn't include modules, which we are using
"modules": true
@jahe
jahe / spring-boot-cheatsheet.java
Last active September 3, 2025 14:31
Spring Boot Cheatsheet
// Enable component-scanning and auto-configuration with @SpringBootApplication Annotation
// It combines @Configuration + @ComponentScan + @EnableAutoConfiguration
@SpringBootApplication
public class FooApplication {
public static void main(String[] args) {
// Bootstrap the application
SpringApplication.run(FooApplication.class, args);
}
}
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm