Skip to content

Instantly share code, notes, and snippets.

@zhyu
zhyu / scc.py
Created August 10, 2015 13:48
scc
import sys
import threading
def buildG(filename):
g, g_rev = [], []
with open(filename) as f:
for line in f:
u, v = map(int, line.split())
m = max(u, v)
@zhyu
zhyu / palindromeLinkedList.py
Created July 13, 2015 03:25
Palindrome Linked List
class Solution:
def isPalindrome(self, head):
rhead = None
slow = fast = head
while fast and fast.next:
fast = fast.next.next
slow.next, slow, rhead = rhead, slow.next, slow
if fast:
slow = slow.next
while rhead and rhead.val == slow.val:
keys = [
'status',
'temperature',
'power_up',
'glist',
'uncorrected_read',
'uncorrected_write',
]
mappings = {key: deepcopy(mapping) for key in keys}
@zhyu
zhyu / private.xml
Last active August 29, 2015 14:10
Custom rule for Karabiner(KeyRemap4MacBook) to select the second/third candidate using left/right shift key only in Chinese Simplified input source
<?xml version="1.0"?>
<root>
<item>
<name>Select the second/third candidate using left/right shift key.(only in Chinese-Simplified-*)</name>
<identifier>private.select_candidate_using_shift_key</identifier>
<inputsource_only>CHINESE_SIMPLIFIED</inputsource_only>
<autogen>__KeyOverlaidModifier__ KeyCode::SHIFT_L, KeyCode::SHIFT_L, KeyCode::KEY_2</autogen>
<autogen>__KeyOverlaidModifier__ KeyCode::SHIFT_R, KeyCode::SHIFT_R, KeyCode::KEY_3</autogen>
</item>
</root>
@zhyu
zhyu / private.xml
Created December 3, 2014 07:06
Custom rule for Karabiner(KeyRemap4MacBook) to change input source to Chinese Simplified using right option key
<?xml version="1.0"?>
<root>
<item>
<name>Change Input Source to Chinese Simplified when press right option key.</name>
<identifier>private.change_input_source_with_right_option</identifier>
<autogen>--KeyToKey-- KeyCode::OPTION_R, KeyCode::VK_CHANGE_INPUTSOURCE_CHINESE_SIMPLIFIED</autogen>
</item>
</root>
@zhyu
zhyu / private.xml
Created December 2, 2014 08:08
Custom rule for Karabiner(KeyRemap4MacBook) to change input source using right option key
<?xml version="1.0"?>
<root>
<item>
<name>Change Input Source when press right option key.</name>
<appendix>Option_R to Command+Space</appendix>
<identifier>private.change_input_source_with_right_option</identifier>
<autogen>--KeyToKey-- KeyCode::OPTION_R, KeyCode::SPACE, ModifierFlag::OPTION_L | ModifierFlag::COMMAND_L</autogen>
</item>
</root>
@zhyu
zhyu / feed.xml
Last active August 29, 2015 14:03
Gist for www.hexieshe.com feed that hasn't updated in Feedbin since June 4, 2014. Bug report for Feedbin.
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">
<channel>
<title>和邪社</title>
<atom:link href="http://www.hexieshe.com/feed/" rel="self" type="application/rss+xml"/>
<link>http://www.hexieshe.com</link>
<description>文不在长.内涵则明 图不在色.意淫则灵</description>
<lastBuildDate>Wed, 25 Jun 2014 09:11:21 +0000</lastBuildDate>
<language>zh-CN</language>
<sy:updatePeriod>hourly</sy:updatePeriod>