Skip to content

Instantly share code, notes, and snippets.

View ygmpkk's full-sized avatar
😬
No more monkeys jumping on the bed

Timothy ygmpkk

😬
No more monkeys jumping on the bed
  • didi
  • Hangzhou
View GitHub Profile
@bryanbraun
bryanbraun / git-branching-diagram.md
Last active April 27, 2025 17:30
Example Git Branching Diagram

Example Git Branching Diagram

You can use this diagram as a template to create your own git branching diagrams. Here's how:

  1. Create a new diagram with diagrams.net (formerly draw.io)
  2. Go to File > Open From > URL
  3. Insert this url (it points to the xml data below): https://gist.githubusercontent.com/bryanbraun/8c93e154a93a08794291df1fcdce6918/raw/bf563eb36c3623bb9e7e1faae349c5da802f9fed/template-data.xml
  4. Customize as needed for your team.

@kskmori
kskmori / trac2md.py
Last active August 14, 2024 11:43
Trac Wiki to Markdown converter
#!/usr/bin/env python
#
# Trac Wiki to Markdown converter
#
# Copyright(c) 2019 Keisuke MORI ([email protected])
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
@tusharf5
tusharf5 / retry_promise.js
Created August 2, 2019 17:04
Javascript function to retry a promise n no. of times before rejecting.
/**
* Retries a promise n no. of times before rejecting.
*/
async function retryPromise(promise, nthTry) {
try {
const res = await promise;
return res;
} catch (e) {
if (nthTry === 1) {
return Promise.reject(e);
@jwsmithers
jwsmithers / DownloadFromIB.py
Last active December 2, 2022 17:42
Function to download from IB
from ib_insync import *
import asyncio
import nest_asyncio
async def update_from_IB(stock):
"""
Asynchronous call example to update stocks from Interactive broker.
Args:
stock(str): Stock, I.e. AAPL
@bessarabov
bessarabov / gist:674ea13c77fc8128f24b5e3f53b7f094
Last active August 23, 2024 19:11
One-liner to generate data shown in post 'At what time of day does famous programmers work?' — https://ivan.bessarabov.com/blog/famous-programmers-work-time
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
@jsvd
jsvd / gen.sh
Created October 16, 2018 11:55
warning: do not use the certificates produced by this tool in production. This is for testing purposes only
# warning: do not use the certificates produced by this tool in production. This is for testing purposes only
# certificate authority
openssl genrsa -out RootCA.key 4096
openssl req -new -x509 -days 1826 -extensions v3_ca -key RootCA.key -out RootCA.crt
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in RootCA.key -out RootCA.key.pkcs8
# intermediate CA
openssl genrsa -out IntermediateCA.key 4096
@mhofman
mhofman / HAProxy-transparent-web-services-routing.md
Last active February 3, 2025 21:03
Leverage HAProxy to transparently route requests to web services identified by host name.

Web Service Fronting

Multiple Web properties on a single IP address

Hosting multiple websites on a single public IP address on the standard HTTP(S) ports is relatively easy with popular web servers like Apache, Nginx and lighttpd all supporting Virtual Hosts.
For Web Services which bundle their own HTTP server, things get more complicated, unless their HTTP stack can be shared somehow. More often than not, the application's HTTP stack listens directly on a dedicated TCP port.

Hosting multiple services on a single IP then requires using a fronting server listening on the standard HTTP port, and routing to the right backend service based on the host name or the path sent by the client.
Path based routing is cumbersome, usually requiring either the service to be aware of the path prefix, or a rewrite by the HTTP fronting server of all absolute URLs in the requests and responses.
Hostname based routing is more straightforward. The fronting server can just look at the [HTTP/1.1 Host header](https://tools

@clemfromspace
clemfromspace / puppeteer-middleware.py
Last active June 26, 2021 08:02
Scrapy with Puppeteer
"""This module contains the ``SeleniumMiddleware`` scrapy middleware"""
import asyncio
from pyppeteer import launch
from scrapy import signals
from scrapy.http import HtmlResponse
from twisted.internet import defer
from .http import PuppeteerRequest
@bbc4468
bbc4468 / influx_schema.sql
Last active July 25, 2024 02:51
Influx DB Schema for OHLC
create database price_history_db
CREATE CONTINUOUS QUERY "cq_1m" ON "price_history_db" BEGIN SELECT MIN(price) as low, MAX(price) as high, FIRST(price) as open, LAST(price) as close, SUM(size) as volume INTO "price_1m" FROM "trade" GROUP BY time(1m), symbol END
CREATE CONTINUOUS QUERY "cq_5m" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_5m" FROM "price_1m" GROUP BY time(5m), symbol END
CREATE CONTINUOUS QUERY "cq_15m" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_15m" FROM "price_5m" GROUP BY time(15m), symbol END
CREATE CONTINUOUS QUERY "cq_1h" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_1h" FROM "price_15m" GROUP BY time(1h), symbol END
CREATE CONTINUOUS QUERY "cq_6h" ON "price_history_db" BEGIN SELECT
搜狗双拼口诀
搜狗双拼的规则
双拼是用定义好的单字母代替较长的多字母韵母或声母来进行输入的一种方式。
例如:如果 T=t, M=ian,键入两个字母 “TM” 就会输入拼音 “tian” 。
使用双拼可以减少 击键次数,但是需要记忆字母对应的键位,但是熟练之后效率会有一定提高。
如果 使用双拼,要在设置属性窗口把双拼选上即可。
对于单韵母字,需要在前面输入字母 O+韵母。例如:输入 OA → A ,输入 OO → O , 输入 OE → E 。
而在自然码双拼方案中,和自然码输入法的双拼方式一致,对于单韵 母字,需要输入双韵母,例如:输入 AA → A ,输入 OO → O ,输入 EE → E 。