Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ysmood
ysmood / nginx.minimal.conf
Last active February 23, 2024 03:01
nginx minimal reverse proxy config
events {}
http {
server {
listen 8080;
server_name a.com;
location / {
proxy_pass http://127.0.0.1:8888;
}
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
#
# Mar 2013 Yad Smood
# VCS
YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} "
YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}"
@ysmood
ysmood / osx_zshrc.sh
Created May 22, 2013 09:48
A zshrc with some common settings.
#!/usr/bin/env bash
# Default zsh runcom.
# Oct 2012 y.s.
################################### OH-MY-ZSH Settings ##########################################
# If your current shell is not zsh, try to change your default shell to zsh.
if [[ $0 != '-zsh' ]]; then
echo "Your default shell is not zsh."
@ysmood
ysmood / shuffle_names.go
Last active December 18, 2020 06:09
Copy the names then run it, it will output to your clipboard, names should be separated by commas
package main
import (
"math/rand"
"strings"
"github.com/atotto/clipboard"
)
func main() {
package main
import (
"os"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/input"
"github.com/go-rod/rod/lib/utils"
)
@ysmood
ysmood / hang.go
Last active November 24, 2020 17:46
Issue 1151822: CDP call Page.close on the non-exist session id will hang
package main
import (
"context"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/cdp"
"github.com/go-rod/rod/lib/launcher"
)
@ysmood
ysmood / crash_chromedp.go
Last active October 30, 2020 06:51
Such as when you want to inject a large js helper to the page, chromedp will crash.
package main
import (
"context"
"fmt"
"log"
"strings"
"github.com/chromedp/chromedp"
)
const puppeteer = require('puppeteer')
;(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
// Total timeout for all operations is not supported, only supports timeout for individual operations.
// Puppeteer doesn't support aborting of slow operation.
page.setDefaultTimeout(5 * 1000)
package main
import (
"fmt"
"time"
"github.com/ysmood/kit"
"github.com/ysmood/storer"
"github.com/ysmood/storer/pkg/kvstore"
)
@ysmood
ysmood / dns-server.go
Created December 12, 2019 20:54
DNS server example
// dns server
package dnser
import (
"net"
"golang.org/x/net/dns/dnsmessage"
)