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;
@ataki
ataki / tiktok-search-scraper.js
Created September 21, 2022 16:28
Scrapes TikTok results for a certain hashtag. Paste into chrome console
let seen = new Set()
async function getBioLink(row) {
try {
const { signature, uniqueId } = row
const secUid = row.secUid
const url = `https://us.tiktok.com/api/user/detail/?aid=1988&app_language=en&app_name=tiktok_web&battery_info=1&browser_language=en-US&browser_name=Mozilla&browser_online=true&browser_platform=MacIntel&browser_version=5.0%20%28Macintosh%3B%20Intel%20Mac%20OS%20X%2010_15_7%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome%2F105.0.0.0%20Safari%2F537.36&channel=tiktok_web&cookie_enabled=true&device_id=7137341942917350955&device_platform=web_pc&focus_state=true&from_page=user&history_len=2&is_fullscreen=false&is_page_visible=true&language=en&os=mac&priority_region=US&referer=&region=US&screen_height=1440&screen_width=2560&secUid=${secUid}&tz_name=America%2FNew_York&uniqueId=${uniqueId}&webcast_language=en&msToken=J9m3_eBf4GKuBDGa063BDCsjVBzMBmcFqJvEGf0M62WHW9yPzXAHzcFhc8-X5-DLAkVoNH7CKKi-Jkp1Kb7ua75MV6btEfjcZPAbhZJKirSwPlP_CTcRrSMHocUTnU4=&X-Bogus=DFSz
@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"
)
@rojenzaman
rojenzaman / update-cdn.sh
Created September 6, 2020 14:21
firewalld rules for cloudflare cdn IPs (Red Hat, CentOS, Fedora)
#!/bin/bash
curl https://www.cloudflare.com/ips-v4 > .ips-v4
curl https://www.cloudflare.com/ips-v6 > .ips-v6
firewall-cmd --new-zone=cloudflare --permanent
firewall-cmd --reload
for i in `<.ips-v4`; do firewall-cmd --zone=cloudflare --add-source=$i; done
for i in `<.ips-v6`; do firewall-cmd --zone=cloudflare --add-source=$i; done
@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 March 2, 2025 06:36
[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)
}
@nikhita
nikhita / update-golang.md
Last active May 15, 2025 07:07
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@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>