Skip to content

Instantly share code, notes, and snippets.

View binderclip's full-sized avatar
👨‍💻
build

clip binderclip

👨‍💻
build
  • Beijing
View GitHub Profile

golang 结构体内部变量被引用实验

结论

struct 的某个 filed 被引用的时候 struct 本身就不会被垃圾回收器回收。

操作步骤

$ go run memtest.go -cpuprofile cpu.pprof -memprofile mem.pprof
@binderclip
binderclip / deploy-flask-gunicorn-supervisor-nginx.md
Last active March 22, 2023 09:17
Flask Gunicorn Supervisor Nginx 项目部署小总结

Flask Gunicorn Supervisor Nginx 项目部署小总结

服务器的基本连接和配置

SSH 连接

使用公钥私钥来登陆而不是账号密码,公钥私钥需要简单的在本地生成一下。Github 的生成 SSH 公钥私钥的教程:Generating SSH keys

可能需要使用 -i 参数选择一下本地的私钥,一个示例的 ssh 连接如下:

@binderclip
binderclip / python-smtp-send-qq-mail.py
Last active February 16, 2023 14:59
Python & Email,附上用 Python 发送 QQ 邮箱邮件的代码
import smtplib
from getpass import getpass
def prompt(prompt):
return input(prompt).strip()
fromaddr = prompt("From: ")
toaddrs = prompt("To: ").split()
subject = prompt("Subject: ")
print("Enter message, end with ^D (Unix) or ^Z (Windows):")
@binderclip
binderclip / mysql-installation-ready-to-hand-on-mac.md
Last active September 19, 2020 08:52
MySQL Installation on Mac

MySQL 安装和上手使用 on Mac

安装

之前看 MySQL 的入门教程的时候发现不是很容易找到和自己环境完全一样的方法,后来问同事,作比较终于走通了。安装方法不只是一种,用的相关 APP 也不是一种,每种都是可行的,但是这里只描述自己更偏好的那一种 :D。这篇文章假设读者开始对 MySQL 都没有一个概念,所以除了软件的安装和配置,还会简单介绍一点点关于 MySQL 的东西。

首先 $ brew install mysql 安装 mysql,之后可能需要重启一下终端,然后成功的话输入 $ mysql 再按 Tab 会提示一些和 mysql 相关的命令出来,如果有的话就 OK 了,如下:

$ mysql
@binderclip
binderclip / set-proxy-for-atom.md
Created September 12, 2015 04:27
set shadowsocks proxy for atom

~/.atom/.apmrc

strict-ssl = false
http-proxy = http://127.0.0.1:8090/proxy.pac
$ apm config list
...
@binderclip
binderclip / flask_file_upload.py
Created July 18, 2016 08:57
Flask file upload
import os
from flask import Flask, request, redirect, url_for, send_from_directory
from werkzeug.utils import secure_filename
UPLOAD_FOLDER = '/tmp/flask-upload-test/'
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
#!/bin/sh
exit_code=0
goimports_fix() {
hash goimports 2>&- || { echo >&2 "goimports not in PATH."; exit 1; }
for file in `git diff --cached --name-only --diff-filter=d | grep -v vendor | grep '\.go$'`
do
if [[ ! -z `git diff --name-only ${file} | grep '\.go$'` ]]
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#190521 22:03:48 server id 1 end_log_pos 123 CRC32 0x9a9ea66e Start: binlog v 4, server v 5.7.25-28-log created 190521 22:03:48 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
# at 123
#190521 22:03:48 server id 1 end_log_pos 154 CRC32 0xc13e82af Previous-GTIDs
# [empty]
@binderclip
binderclip / pinyin-to-emoji.json
Created January 11, 2019 09:57
汉字 pinyin emoji
{"e":"🐊","ai":"❤️","er":"👂","ba":"🎱","bo":"🍍","bi":"🖋","bu":"🙅‍♂️","bai":"💯","bao":"🎒","ban":"🔧","bang":"🍭","bei":"🐚","ben":"📒","biao":"⌚️","bian":"🦇","bie":"🧷","bin":"🍾","bing":"🍧","pa":"👏","pi":"🍺","pu":"🍇","pai":"🏓","pao":"🏃‍♂️","pan":"🍽","pen":"⛲️","peng":"⛺️","piao":"🐞","pin":"🧩","ping":"🍎","ma":"🐴","mo":"🍄","mi":"🍯","mai":"🎙","mao":"🐈","man":"🈵","mang":"🥭","mei":"🍓","men":"🚪","meng":"🍋","miao":"🐱","mian":"🍜","mie":"🧯","fa":"👩‍⚖️","fu":"🗻","fan":"🍚","fang":"🏠","fei":"✈️","feng":"🐝","da":"🖨","de":"🉐","di":"🌎","du":"🦄","dai":"🦘","dao":"🔪","dan":"🥚","dong":"🕳","deng":"💡","diao":"🎣","dian":"⚡️","die":"🦋","ding":"🔝","dui":"✔️","dun":"🛡","ta":"🗼","tu":"🐇","tai":"☯️","tao":"🍑","tang":"🍬","tong":"🛢","tiao":"💃","tian":"😛","tie":"🛤","ting":"⏹","tuan":"🍙","tui":"🦵","tun":"🐬","tuo":"🐪","nv":"🚺","nai":"🍼","nao":"🧠","nan":"🚹","nang":"💊","nong":"👩‍🌾","nei":"👙","niao":"🐦","niu":"🐂","ning":"🍋","niang":"👰","la":"🌶","li":"🍐","lu":"🦌","lv":"💚","lao":"🧀","lan":"🏀","lang":"🐺","lou":"🏢","long":"🐉","lei":"⚡️","leng":"🥶","lian":