Skip to content

Instantly share code, notes, and snippets.

View wudi's full-sized avatar
🎯
Focusing

Di Wu wudi

🎯
Focusing
View GitHub Profile
@wudi
wudi / http_streaming.md
Created November 21, 2023 12:22 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

const SPEEEEEED: bool = 1==1;
pub mod reg {
#[derive(Clone, Copy, Debug)]
#[repr(align(4))]
pub enum Instruction {
LoadInt { dst: u8, value: i16 },
@wudi
wudi / scanner.rl
Created October 20, 2023 06:49
How to parse quotes in Ragel
# source: https://numbers.brighterplanet.com/2012/08/21/how-to-parse-quotes-in-ragel/
examples = [
%{''},
%{""},
%{' '},
%{" "},
%{'A'},
%{'ABC'},
%{'AB C'},
@wudi
wudi / jq to filter by value.md
Created August 4, 2023 04:01 — forked from ipbastola/jq to filter by value.md
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@wudi
wudi / 01.bash_shortcuts_v2.md
Created July 7, 2023 04:54 — forked from tuxfight3r/01.bash_shortcuts_v2.md
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
@wudi
wudi / docker-compose.yaml
Created May 29, 2023 05:14 — forked from nobbynobbs/docker-compose.yaml
kafka and kafka-ui, without zookeeper
version: '2.4'
services:
kafka:
image: bitnami/kafka:3.1.0
container_name: kafka
command:
- 'sh'
- '-c'
- '/opt/bitnami/scripts/kafka/setup.sh && kafka-storage.sh format --config "$${KAFKA_CONF_FILE}" --cluster-id "lkorDA4qT6W1K_dk0LHvtg" --ignore-formatted && /opt/bitnami/scripts/kafka/run.sh' # Kraft specific initialise
environment:
@wudi
wudi / dynamic_router.go
Last active February 8, 2023 16:53
Dynamic Router for Gin
package main
import (
"net/http"
"sync"
"time"
"github.com/gin-gonic/gin"
)
@wudi
wudi / benchmark+go+nginx.md
Created August 29, 2016 14:51 — forked from hgfischer/benchmark+go+nginx.md
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@wudi
wudi / cloudflare_dyn_dns.sh
Created February 27, 2022 07:16 — forked from chappy84/cloudflare_dyn_dns.sh
CloudFlare Dynamic DNS Shell Script
#!/bin/sh
#
# CloudFlare Dynamic DNS
#
# Updates CloudFlare records with the current public IP address
#
# Takes the same basic arguments as A/CNAME updates in the CloudFlare v4 API
# https://www.cloudflare.com/docs/client-api.html#s5.2
#
# Use with cron jobs etc.
@wudi
wudi / MoveFile.go
Created May 24, 2021 11:15 — forked from var23rav/MoveFile.go
GoLang: os.Rename() give error "invalid cross-device link" for Docker container with Volumes. MoveFile(source, destination) will work moving file between folders
import (
"fmt"
"io"
"os"
)
/*
GoLang: os.Rename() give error "invalid cross-device link" for Docker container with Volumes.
MoveFile(source, destination) will work moving file between folders
*/