Skip to content

Instantly share code, notes, and snippets.

@michaelHL
michaelHL / py-generator-list.py
Created August 29, 2017 02:37
python - generator vs list
# -*- coding: utf-8 -*- | N Function Runtime
| -----------------------------------------
import time | 1e+00 createGenerator 0.00000000 s
| 1e+00 createGeneratorExp 0.00000000 s
def createGenerator(N): | 1e+00 createList 0.00000000 s
for i in range(N): | -----------------------------------------
yield i * i | 1e+01 createGenerator 0.00000000 s
| 1e+01 createGeneratorExp 0.00000000 s
def createGeneratorExp(N): | 1e+01 createList
@michaelHL
michaelHL / scopes.txt
Last active August 29, 2017 07:29 — forked from iambibhas/scopes.txt
Sublime Text 2: Snippet scopes
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
@michaelHL
michaelHL / cmd.py
Created August 29, 2017 07:26 — forked from dhrrgn/cmd.py
Running a command in Python and optionally processing the output in realtime.
import shlex
import subprocess
import sys
def run_cmd(cmd, callback=None, watch=False):
"""Runs the given command and gathers the output.
If a callback is provided, then the output is sent to it, otherwise it
is just returned.
@michaelHL
michaelHL / merge-sort.ipynb
Last active October 19, 2017 14:16
merge sort (in-place)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@michaelHL
michaelHL / ssh.md
Last active November 1, 2017 07:53
利用 ssh 穿透

利用 ssh 穿透内网

记号

代号 位置 地址 账户
A 位于公网 a.site usera
B 位于 NAT 之后 localhost userb
C 位于 NAT 之后 localhost userc
@michaelHL
michaelHL / web-servers.md
Created November 21, 2017 08:22 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@michaelHL
michaelHL / gist:b39606ccb15392b1c3754e5f81c9a76e
Created November 29, 2017 15:31 — forked from samhocevar/gist:00eec26d9e9988d080ac
Configure sshd on MSYS2 and run it as a Windows service
#!/bin/sh
#
# msys2-sshd-setup.sh — configure sshd on MSYS2 and run it as a Windows service
#
# Please report issues and/or improvements to Sam Hocevar <[email protected]>
#
# Prerequisites:
# — MSYS2 itself: http://sourceforge.net/projects/msys2/
# — admin tools: pacman -S openssh cygrunsrv mingw-w64-x86_64-editrights
#
@michaelHL
michaelHL / WordStringToTitle.vba
Last active April 14, 2020 13:53
word首字母大写
Sub captical()
Selection.WholeStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.SmallCaps = False
.AllCaps = True
End With
With Selection.Find
.Text = "<([A-Za-z])"
@michaelHL
michaelHL / cloudSettings
Last active October 27, 2018 00:54
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-10-27T00:54:27.927Z","extensionVersion":"v3.2.0"}
/**
* 2018 年刑侦科推理试题
*
* 1. 这道题的答案是:
* A. A B. B C. C D. D
*
* 2. 第 5 题的答案是:
* A. C B. D C. A D. B
*
* 3. 以下选项中哪一题的答案与其它三项不同: