Skip to content

Instantly share code, notes, and snippets.

@yougg
yougg / hibernate.md
Last active December 16, 2020 04:16
Ubuntu 19.04 enable hibernate

Enable hibernate with swapfile on Ubuntu 19.04

Install hibernate and other dependencies which are needed to hibernate

sudo apt install hibernate

Create the swap file

@yougg
yougg / qq_nickname.md
Last active March 25, 2020 14:42
通过QQ空间个人资料修改QQ昵称为空格过程记录
  1. 登陆自己的QQ空间 https://qzone.qq.com/

  2. 进入个人档,点击修改基本资料

  3. 在昵称处填入一个到多个Unicode空格

  4. 点击最下方的保存按钮,此时会弹框提示很抱歉,昵称不能全为空,请重新输入

    • 按Chrome F12或者Ctrl+Shift+I快捷键打开开发者工具窗口
  • 进入Network标签页,先点击Clear清理一下之前的请求记录
@yougg
yougg / acfun_emoji.sh
Last active September 8, 2019 04:08
AC娘表情包图片下载脚本
#!/bin/bash
#AC娘表情包 01-54
#http://cdn.aixifan.com/dotnet/20130418/umeditor/dialogs/emotion/images/ac/01.gif?v=0.1
#匿名版表情包 01-40
#http://cdn.aixifan.com/dotnet/20130418/umeditor/dialogs/emotion/images/ais/01.gif?v=0.1
#AC新娘表情包 01-55
#http://cdn.aixifan.com/dotnet/20130418/umeditor/dialogs/emotion/images/ac2/01.gif?v=0.1
@yougg
yougg / dump.go
Created August 16, 2019 08:39
Dump goroutine stack by signal
package dump
import (
"fmt"
"os"
"os/signal"
"runtime"
"syscall"
)
@yougg
yougg / githook.sh
Created August 17, 2018 09:38
git pre-commit hook for format go source files
#!/usr/bin/env bash
cd `dirname $0`
if [ "githook.sh" = "`basename $0`" ]; then
gitroot=$(git rev-parse --show-toplevel)
cp -f ${gitroot}/scripts/githook.sh ${gitroot}/.git/hooks/pre-commit
chmod u+x ${gitroot}/.git/hooks/pre-commit
exit 0
elif [ "pre-commit" = "`basename $0`" ]; then
cd ../..
@yougg
yougg / codecount.sh
Created August 17, 2018 09:17
shell count code lines in the directory
#!/bin/bash
if [ -n "${1}" ]; then
WD=${1}
else
WD=$(cd `dirname $0`/..;pwd)
fi
# find all text file extensions which not in the dir: .idea/.git/vendor/thirdparty/sdk/swagger
exts=$(find ${WD} -type f -not -path "*.idea*" -not -path "*.git*" -not -path "*/sdk/*" -not -path "*rd*arty*" -not -path "*vendor*" -not -path "*swagger*" -exec grep -Iq . {} \; -and -print 2> /dev/null | awk -F '.' '{if ($NF!~/\//){print $NF}}' | sort | uniq)
@yougg
yougg / pidstat.sh
Created August 17, 2018 09:09
monitor process state by pid
#!/usr/bin/env bash
# Thread state
# pidstat -dhut -p <PID>
# top -bcH -n 1 -p <PID>
# pstree -ps <PID>
pname=${1}
if [ -z "${pname}" ] || [[ "${pname}" =~ [-](h|H|[-]?help) ]]; then
echo -e "Error: need input a process name or pid\n"
@yougg
yougg / random.go
Created July 30, 2018 12:06
generate random string in go
package main
import (
"math/rand"
"time"
"fmt"
)
const (
lowercaseLetter = `abcdefghijklmnopqrstuvwxyz`