Skip to content

Instantly share code, notes, and snippets.

View j178's full-sized avatar
🕶️
Living

Jo j178

🕶️
Living
View GitHub Profile

Galaxy Brain

Galaxy Brain Badge

这个徽章需要由你在 Discussion Q&A 中回答别人的问题,并且由 OP(不能是你自己)mark as answer 才能获得。需要至少回答两个问题。

Pair Extraordinaire

Pair Extraordinaire Badge

@j178
j178 / bench_bool_to_string.cpp
Last active April 11, 2023 11:36
Compile with `g++ -std=c++11 -O2 bench.cpp -o bench`
#include <iostream>
#include <chrono>
#include <sstream>
using namespace std;
using namespace chrono;
// Method 1: Using a conditional operator
string bool_to_string_conditional(bool b) {
return b ? "true" : "false";
@j178
j178 / main.go
Last active July 1, 2023 10:00
Gin route confliction
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.GET("/users/:name", func(c *gin.Context) {})
// can't use `:id` here, change to `:name` will fix the confliction
r.GET("/users/:id/repos", func(c *gin.Context) {})
_ = r.Run(":8080")
@j178
j178 / nc-proxy-readme.md
Created August 9, 2024 13:17 — forked from m1tk4/nc-proxy-readme.md
netcat tcp proxy, for mapping ports on a remote machine to a local machine

Helper script to map ports to other servers.

Use Case

had a database that was only accesible in the VPC on aws, so i created an dev intance and did a ssh tunnel to that dev instance with netcat mapping the port to the database

Sample Usage

Forward all request from local 5432 to remote host google.com port 80

./nc-proxy.sh 5432 google.com 80
@j178
j178 / nc-proxy-readme.md
Created August 9, 2024 13:17 — forked from m1tk4/nc-proxy-readme.md
netcat tcp proxy, for mapping ports on a remote machine to a local machine

Helper script to map ports to other servers.

Use Case

had a database that was only accesible in the VPC on aws, so i created an dev intance and did a ssh tunnel to that dev instance with netcat mapping the port to the database

Sample Usage

Forward all request from local 5432 to remote host google.com port 80

./nc-proxy.sh 5432 google.com 80