Skip to content

Instantly share code, notes, and snippets.

@arieffikhrie
arieffikhrie / google.js
Created October 26, 2022 10:17
Test puppeteer on google.com
const puppeteer = require("puppeteer-core"); // v13.0.0 or later
const path = require("path");
(async () => {
const browser = await puppeteer.launch({
executablePath:
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
});
const page = await browser.newPage();
const timeout = 5000;
@bacher09
bacher09 / http_intf.go
Created August 24, 2021 12:22
Golang, http with SO_BINDTOINTERFACE
package main
import (
"fmt"
"io"
"net"
"net/http"
"syscall"
)
@luqmansungkar
luqmansungkar / restore-ibd-frm.md
Created April 12, 2020 05:58
How to restore mysql database from .ibd and .frm file

Have you ever stuck in a condition where you have to restore your mysql database from only an *.frm and *.ibd files? I have.

So what happen is somehow our mysql service is going down and can not be restarted. I try many things to no avail and getting tired of it.

And then I came across this page https://dev.mysql.com/doc/mysql-enterprise-backup/3.11/en/partial.restoring.single.html. I think probably I can just copy the *.frm and *.ibd file, wipe the current mysql data, reset the mysql, and restore those two files. Easy.

So I stupidly remove /var/lib/mysql/[schema_name], and also /var/lib/mysql/ib* file. Restart the mysql, and it start normally. Finally!

@movsb
movsb / tunnel.go
Created December 6, 2019 14:50
An HTTP Tunnel Proxy, which implements the CONNECT method. Written in Golang, within 100 lines of code.
package main
import (
"io"
"log"
"net"
"net/http"
"sync"
)
@thomasschaeferm
thomasschaeferm / clat-jool.lte.sh
Created October 29, 2019 21:05
jool clat for 464xlat script
#!/bin/bash
PREFIX="$1"
IFACE="$2"
ip netns add jool
ip link add name to_jool typ veth peer name to_world
ip link set up dev to_jool
ip link set dev to_world netns jool
ip netns exec jool ip link set up dev to_world
@bamoo456
bamoo456 / main.go
Last active August 7, 2024 16:23
[Golang] execute long running job and streaming the realtime output
func main() {
cmd := exec.Command("sh", "-c", "cd ../../bin/worker; ./run.sh")
// some command output will be input into stderr
// e.g.
// cmd := exec.Command("../../bin/master_build")
// stderr, err := cmd.StderrPipe()
stdout, err := cmd.StdoutPipe()
if err != nil {
fmt.Println(err)
}
@goldsborough
goldsborough / assignment3.c
Created June 14, 2016 20:04
Working IPv6 Neighbor Discovery
#include <arpa/inet.h>
#include <asm/byteorder.h>
#include <assert.h>
#include <errno.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <netinet/icmp6.h>
#include <netinet/ip6.h>
#include <stdio.h>
#include <stdlib.h>
@ipmb
ipmb / ratelimit.nginxconf
Last active July 21, 2024 05:37
Nginx reverse proxy with rate limiting
upstream myapp {
server 127.0.0.1:8081;
}
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
server {
listen 443 ssl spdy;
server_name _;