Skip to content

Instantly share code, notes, and snippets.

🍊
Focusing

garden.yuen weaming

🍊
Focusing
View GitHub Profile
@weaming
weaming / DoH.go
Last active Dec 26, 2019
DNS over HTTP
View DoH.go
// https://developers.cloudflare.com/1.1.1.1/dns-over-https/json-format/
package redisHub
import (
"encoding/json"
"fmt"
"log"
"net/http"
"regexp"
"strings"
@weaming
weaming / webdavserv.go
Created Nov 28, 2019 — forked from staaldraad/webdavserv.go
A small webdav server in go
View webdavserv.go
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
"golang.org/x/net/webdav"
View id-dispatch.py
from math import ceil
from typing import List
import redis
def n1(n):
# left shift then minus 1
return (0b1 << n + 1) - 1
View setup-haskell-mac.sh
# 安装 stack, ghc, ghci
brew install haskell-stack
# 安装 HIE
## 安装 nix-env
curl https://nixos.org/nix/install | sh
## 安装 hie, 对应 haskell 版本 8.65
nix-env -iA selection --arg selector 'p: { inherit (p) ghc865; }' -f https://github.com/infinisil/all-hies/tarball/master
# 配置 VSCode 环境
View instagram_image_urls.py
import re
import json
import requests
from json_api.errors import ExceptionWithStatusCode
UA = (
'Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) '
'Mobile/15E148 MicroMessenger/7.0.8(0x17000820) NetType/WIFI Language/zh_CN'
)
View unify_date.py
import arrow
from datetime import datetime
def unify_date(text: str):
text = text.strip().lower()
if text.startswith('circa'):
text = text[len('circa') :].strip()
try:
return arrow.get(text).date()
View crawl-and-parse.py
"""
https://redis.io/commands
var xs = []; $('.command').each(function(i,x){xs.push($(x).text().trim())}); console.log(JSON.stringify(xs))
save output as x.json
"""
import json
data = json.load(open('x.json'))
print(len(data))
View apply-http3-patch-to-nginx.sh
#!/bin/bash
# Author : weaming
# Mail : garden.yuen@gmail.com
# Created : 2019-10-23 14:18:48
# https://blog.cloudflare.com/experiment-with-http-3-using-nginx-and-quiche/
# https://github.com/cloudflare/quiche/tree/master/extras/nginx#list-of-configuration-directives
# https://tools.ietf.org/html/rfc7838#section-3
# https://blog.cloudflare.com/http3-the-past-present-and-future/
# '/Applications/Google Chrome Canary.app' --enable-quic --quic-version=h3-23
View fzf_tab_binding.fish
# inspired by https://github.com/junegunn/fzf/issues/868
function __fzf_ls_files
git ls-tree -r --name-only HEAD 2>/dev/null; or fd --type f --hidden --follow --exclude .git
end
function __fzf_grep_last
set -l cmd (commandline)
# default complete all, and compatible with fzf `**<TAB>`
if str_endswith "$cmd" ' '; or test $cmd = '**'
View chrome-screenshot-by-area.js
#!/usr/bin/env node
// npm install -g puppeteer
// export NODE_PATH=$HOME/npm/lib/node_modules:$NODE_PATH
// http://screensiz.es/monitor
// https://pptr.dev/#?product=Puppeteer&version=v1.19.0&show=api-pagescreenshotoptions
// https://pptr.dev/#?product=Puppeteer&version=v1.19.0&show=api-pagesetcookiecookies
// https://github.com/GoogleChrome/puppeteer/issues/1062
// https://github.com/GoogleChrome/puppeteer/issues/669
("use strict");
You can’t perform that action at this time.