Skip to content

Instantly share code, notes, and snippets.

func BenchmarkNew(b *testing.B) {
var matrix Matrix
for i := 0; i < b.N; i++ {
var err error
matrix, err = New("1 2 3 10 11\n4 5 6 11 12\n7 8 9 12 13\n 8 7 6 13 14")
if err != nil {
b.Fatalf("Failed to create the matrix: %v", err)
}
}
if matrix == nil {

Obsidian helps us manage our notes and other kinds of writings. With everything stored in a local directory, we can easily backup our knowledge base with tools like Dropbox. But still we need a way to share our writings, this tutorial shows a simple way to share notes with Github gist that only requires two steps to set up.

Set up

  1. Make sure you have a Github account.
  2. Install a command line tool for gist: gist. On macOS you can use brew install gist if you have brew installed.
  3. Login with gist --login. It would ask you for your Github username and password to obtain OAuth2 access token, but it won't save your password as you can see in the source code.

Share

gist MyNote.md

Obsidian helps us manage our notes and other kinds of writings. With everything stored in a local directory, we can easily backup our knowledge base with tools like Dropbox. But still we need a way to share our writings, this tutorial shows a simple way to share notes with Github gist that only requires two steps to set up.

Set up

  1. Make sure you have a Github account.
  2. Install a command line tool for gist: gist. On macOS you can use brew install gist if you have brew installed.
  3. Login with gist --login. It would ask you for your Github username and password to obtain OAuth2 access token, but it won't save your password as you can see in the source code.

Share

gist -f MyNote.md < MyNote.md

syntax = "proto3";
// for date and time type, string_value is set
// for int type int64 or uint64_value is set
// for float, double, double_value is set
// for decimal, string_value is set in human-readable now
// for bit, bytes_value is set
// for text and char type, string_value is set
@suzaku
suzaku / intro-vlog-health-checker.md
Last active June 25, 2019 09:47
用 vlog_health_checker 检查及修复错位的 vlog

安装

  1. 下载 vlog_health_checker
  2. tar -xzf vlog_health_checker.tgz

适用场景

保存 binlog 过程中,因为磁盘写满等意外导致出现不完整的写入,使 pump 在内存中维护的文件指针出现偏差,影响后续 binlog 位置的索引。 使用 vlog_health_checker 的第一步,就是先检查确定是否是上述场景。

// Copyright 2019 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@suzaku
suzaku / read_not_after.py
Created December 24, 2018 03:13
Parse notAfter of P12 certificate
import datetime
from OpenSSL.crypto import load_pkcs12
with open("your.p12", "rb") as f:
content = f.read()
p = load_pkcs12(content, "YOUR PASSSPHRASE")
cert = p.get_certificate()
format = "%Y%m%d%H%M%SZ"
print(datetime.datetime.strptime(cert.get_notAfter(), format))
/9j/4QGwRXhpZgAATU0AKgAAAAgACQEPAAIAAAAIAAAAegEQAAIAAAAIAAAAggEaAAUAAAABAAAAigEbAAUAAAABAAAAkgEoAAMAAAABAAIMwAITAAMAAAABAAEAAIdpAAQAAAABAAAAqIglAAQAAAABAAABjgExAAIAAAAOAAAAmgAAAABYaWFvbWkAAE1pVHdvAAAAAAAASAAAAAEAAABIAAAAAXd3dy5tZWl0dS5jb20AAA2CmgAFAAAAAQAAAUqIJwADAAAAAQYyAYGQAAAHAAAABDAyMjCQAwACAAAAFAAAAVKQBAACAAAAFAAAAWaRAQAHAAAABAECAwCSAgAFAAAAAQAAAXqSCgAFAAAAAQAAAYKgAAAHAAAABDAxMDCgAQADAAAAAQABAY6gAgAEAAAAAQAADMCgAwAEAAAAAQAACZCgBQAEAAAAAQAAAYoAAAAAAAAZTwABhqAyMDE1OjExOjIyIDE2OjUyOjE4ADIwMDI6MTI6MDggMTI6MDA6MDAAAAOCcAABhqAAAAGBAAAAZAACAAEAAgAAAARSOTgAAAIABwAAAAQwMTAwAAAAAP/bAEMAAwICAwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsQFhARExQVFRUMDxcYFhQYEhQVFP/bAEMBAwQEBQQFCQUFCRQNCw0UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFP/AABEIAe0C1wMBEQACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3
# RTFM -> http://docs.gunicorn.org/en/latest/settings.html#settings
bind = '0.0.0.0:9090'
workers = 1 # only use one process to make sure all testing requests hit the same worker
timeout = 3 # set a very low timeout value so that we can more easily reproduce the issue
worker_connections = 5000 # allow more connections to make the server busy
proc_name = 'experiment'
import random
import gevent
from flask import Flask
app = Flask(__name__)
@app.route('/')
def complex_bound():