Skip to content

Instantly share code, notes, and snippets.

View ueaner's full-sized avatar

ueaner ueaner

  • Beijing, China
View GitHub Profile
@ueaner
ueaner / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ueaner
ueaner / gist:128839820ae5f9929c23
Created November 10, 2015 10:52 — forked from fernandoaleman/gist:5083680
How to update VirtualBox Guest Additions with vagrant
# Start the old vagrant
$ vagrant init centos-6.3
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
# this machine, please update the guest additions and repackage the
# box.
package counter
import "io"
type Counter struct {
w io.Writer
c int
}
func New(w io.Writer) (h *Counter) {
@ueaner
ueaner / authcode
Created December 5, 2016 03:46 — forked from sarices/authcode
Discuz 加密函数
// $string: 明文 或 密文
// $operation:DECODE表示解密,其它表示加密
// $key: 密匙
// $expiry:密文有效期
function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
// 动态密匙长度,相同的明文会生成不同密文就是依靠动态密匙
$ckey_length = 4;
// 密匙
$key = md5($key ? $key : $GLOBALS['discuz_auth_key']);
@ueaner
ueaner / test.retry.php
Created April 4, 2017 18:28 — forked from mudge/test.retry.php
A retry function for PHP.
<?php
require_once dirname(__FILE__) . '/../lib/simpletest/autorun.php';
function retry($f, $delay = 10, $retries = 3)
{
try {
return $f();
} catch (Exception $e) {
if ($retries > 0) {
sleep($delay);
@ueaner
ueaner / update-tags.md
Created July 10, 2017 14:39 — forked from alexrqs/update-tags.md
Update github tags with new commits
Create a branch with the tag
	git branch {tagname}-branch {tagname}
	git checkout {tagname}-branch
Include the fix manually if it's just a change ....
	git add .
	git ci -m "Fix included" # or cherry-pick the commit, whatever is easier
	git cherry-pick {num_commit}
@ueaner
ueaner / tcpdump.txt
Last active January 31, 2020 23:43 — forked from gstark/tcpdump.txt
Use tcpdump to monitor mysql
Use tcpdump to monitor mysql
# Capture the packets
sudo tcpdump -i eth0 port 3306 -s 65535 -x -n -q -tttt > tcpdump.out
# analyze all the requests from a given host
pt-query-digest --type=tcpdump --filter '($event->{host} || $event->{ip} || "") =~ m/192.168.248.64/' tcpdump.out
# 直接使用 tcpdump 打印相关SQL文本
sudo tcpdump -i any -nn -s 0 -l -w - host 192.168.56.102 and tcp port 3306 | strings
@ueaner
ueaner / exa-wrapper.sh
Created April 20, 2021 17:47 — forked from eggbean/eza-wrapper.sh
Wrapper script for exa to give it nearly identical switches and appearance to ls. Also automatically adds --git switch when in a git repository.
#!/bin/bash
## Change following to '0' for output to be like ls and '1' for exa defaults
# Don't list implied . and .. by default with -a
dot=1
# Show human readable file sizes by default
hru=1
# Don't show group column
fgp=0
# Don't show hardlinks column
@ueaner
ueaner / groupcache.go
Created July 19, 2021 02:31 — forked from fiorix/groupcache.go
Simple groupcache example
// Simple groupcache example: https://github.com/golang/groupcache
// Running 3 instances:
// go run groupcache.go -addr=:8080 -pool=http://127.0.0.1:8080,http://127.0.0.1:8081,http://127.0.0.1:8082
// go run groupcache.go -addr=:8081 -pool=http://127.0.0.1:8081,http://127.0.0.1:8080,http://127.0.0.1:8082
// go run groupcache.go -addr=:8082 -pool=http://127.0.0.1:8082,http://127.0.0.1:8080,http://127.0.0.1:8081
// Testing:
// curl localhost:8080/color?name=red
package main
import (
@ueaner
ueaner / next-antd-saas.js
Created November 21, 2021 00:19 — forked from chitru/next-antd-saas.js
Nextjs project with antd and saas
const withCss = require('@zeit/next-css')
const withSaas = require('@zeit/next-sass')
module.exports = withCss(withSaas({
webpack: (config, { isServer }) => {
if (isServer) {
const antStyles = /antd\/.*?\/style\/css.*?/
const origExternals = [...config.externals]
config.externals = [