Skip to content

Instantly share code, notes, and snippets.

View zhaocai's full-sized avatar
🤨
I may be slow to respond.

Zhao Cai zhaocai

🤨
I may be slow to respond.
View GitHub Profile
@zhaocai
zhaocai / utf16toascii.py
Last active October 19, 2016 01:14
decode utf16
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import codecs
encoded_text = open(sys.argv[-1], 'rb').read()
bom= codecs.BOM_UTF16_LE
assert encoded_text.startswith(bom)
encoded_text= encoded_text[len(bom):]
@zhaocai
zhaocai / Liberal Regex Pattern for URLs
Created October 16, 2016 23:07 — forked from winzig/Liberal Regex Pattern for URLs
Updated @gruber's regex with a modified version that looks for 2-13 letters rather than trying to look for specific TLDs. Given the recent addition of ~1400 gTLDs, it may be time to give up on that front.
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:[a-z]{2,13})(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])|(?:(?<!@)[a-z0-9]+(?:[.\-][a-z0-9]+)*[.](?:[a-z]{2,13})\b/?(?!@)))
# Commented multi-line version:
(?xi)
\b
( # Capture 1: entire matched URL
(?:
@zhaocai
zhaocai / Everything in XYplorer.xys
Created October 10, 2016 06:46
Everything in XYplorer
/* CUSTOMIZATIONS
-------------------------------------------------------------------------------------------------
$path: the path of the folder containing the es.exe executable, with a final
slash.
$paper: the base name of the paper folder containing the search results, without
extension;
$mode: controls how the minus sign, which introduces switches in es.exe, is
treated/escaped. Three modes are available.
@zhaocai
zhaocai / cVim Alfred Style.css
Created September 7, 2016 01:47
cVim Options
#cVim-link-container, .cVim-link-hint, #cVim-command-bar, #cVim-command-bar-mode, #cVim-command-bar-input, #cVim-command-bar-search-results, .cVim-completion-item, .cVim-completion-item .cVim-full, .cVim-completion-item .cVim-left, .cVim-completion-item .cVim-right, #cVim-hud, #cVim-status-bar {
font-family: Helvetica, Helvetica Neue, Neue, sans-serif, Arial;
font-size: 9pt !important;
-webkit-font-smoothing: antialiased !important;
border-radius: 4px!important;
}
#cVim-link-container {
position: absolute;
pointer-events: none;
@zhaocai
zhaocai / .remarkrc.yaml
Created August 28, 2016 21:21
remark rc config
---
plugins:
remark-lint:
blockquote-indentation: 2
final-newline: true
hard-break-spaces: true
list-item-bullet-indent: true
list-item-indent: 'tab-size'
maximum-line-length: false
no-auto-link-without-protocol: true
; WINDOWS KEY + Y TOGGLES FILE EXTENSIONS
#y::
RegRead, HiddenFiles_Status, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, HideFileExt
If HiddenFiles_Status = 1
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, HideFileExt, 0
Else
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, HideFileExt, 1
WinGetClass, eh_Class,A
If (eh_Class = "#32770" OR A_OSVersion = "WIN_VISTA")
send, {F5}
<#
.Synopsis
Displays a visual representation of a calendar.
.Description
Displays a visual representation of a calendar. This function supports multiple months
and lets you highlight specific date ranges or days.
.Parameter Start
The first month to display.
From 8c376bdb5e6d22ab56044bd07f4f631eaa40855d Mon Sep 17 00:00:00 2001
From: Zhao Cai <[email protected]>
Date: Sun, 27 Oct 2013 22:05:23 -0400
Subject: [PATCH] Disable "Pattern not found" message unless verbose > 0
---
src/edit.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/edit.c b/src/edit.c
From 9dfbbe18f2e84da649f28dc1a3b06935ac0e3b17 Mon Sep 17 00:00:00 2001
From: Zhao Cai <[email protected]>
Date: Wed, 31 Jul 2013 16:43:01 -0400
Subject: [PATCH] Add QueryPartialMatch to ycm_core
---
cpp/ycm/PythonSupport.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++
cpp/ycm/PythonSupport.h | 11 +++++++++++
cpp/ycm/ycm_core.cpp | 1 +
3 files changed, 55 insertions(+)
@zhaocai
zhaocai / cprofile.sh
Created September 25, 2013 19:09
py` PythonSpeed/PerformanceTips - Python Wiki
python -m cProfile -s time mine.py <args>