Skip to content

Instantly share code, notes, and snippets.

View honmaple's full-sized avatar

honmaple honmaple

View GitHub Profile
@honmaple
honmaple / yabai.lua
Created March 25, 2024 10:27
Like i3wm's scratchpad
local _M = {
scratchpad = {}
}
local yabai = string.gsub(hs.execute("which yabai", true), "%s+", "")
_M.init = function()
local output, status = _M.exec("query --windows")
if not status then return end
@honmaple
honmaple / file_encrypt.go
Created July 16, 2023 03:25
large file compression, encryption with io.Reader and io.Writer
package main
import (
"bytes"
"compress/gzip"
"crypto/aes"
"crypto/cipher"
"crypto/md5"
"crypto/rand"
"fmt"
@honmaple
honmaple / insert_and_sort.go
Last active April 6, 2023 14:57
insert new element to array and sort compare to search and sort when insert
package main
import (
"math/rand"
"sort"
"testing"
"time"
)
func randNums() []int {
@honmaple
honmaple / tproxy_upstream.py
Created March 16, 2022 02:11
transparent proxy with python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
import select
import sys
IP_TRANSPARENT = 19
HOST = "0.0.0.0"
PORT = 10
@honmaple
honmaple / slice_pass_test.go
Created February 11, 2022 06:45
test function slice param
package main
import (
"testing"
)
type myStruct struct {
list []string
}
@honmaple
honmaple / upload.go
Created September 10, 2021 10:24
upload multi file with golang http client
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
@honmaple
honmaple / re_multiline_test.go
Created September 5, 2021 14:54
golang多行匹配与逐行匹配性能
package main
import (
"fmt"
"regexp"
"strings"
"testing"
)
var template = `
package main
import (
"compress/gzip"
"flag"
"fmt"
"io"
"os"
)
@honmaple
honmaple / session.py
Last active July 20, 2017 06:37
tornado session include memory and redis
from uuid import uuid4
from redis import StrictRedis
from functools import wraps
from datetime import datetime
from pytz import timezone
def singleton(cls):
instances = {}
@honmaple
honmaple / validator
Last active October 26, 2016 06:07
数据校验
class DataValidator(object):
def __init__(self, values, validators, force=False, callback=None):
self.values = values
self.validators = validators
self.callback = callback
self.force = force
def check(self):
values = self.values.copy()
for k, v in self.validators.items():