This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=203 | |
""" | |
import math | |
def prim(n, edges): | |
g = [[] for i in range(n)] | |
for u, v, w in edges: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" Restart mDNSResponder if it's not responsible (just for MacOS) | |
Run this script as root via cron. | |
* * * * * /Users/xupeng/bin/check_mDNSResponder.py | |
""" | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:if(typeof(flag)=="undefined"||flag==false){flag=true;timer=window.setInterval(function(){$(".stream-new").click();},4000);}else{flag=false;window.clearInterval(timer);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){u=$(".topic-content .user-face a").attr("href");a=window.location.href.match(/\/(\d+)\//)[1];$("li.clearfix:not(:has(h4 a[href="+u+"]))").hide();h=$(".paginator");j=h.find(">a:last").text();k=1;$a=new Array;c=new Array;for(i=1;i<j;i++){$.ajax({url:"/group/topic/"+a+"/?start="+(i*100),success:function(data){d=$(data);n=d.find(".thispage").text()-1;$a[n]=d.find("li.clearfix:has(h4 a[href="+u+"])");c[n]=d.find(".paginator").html();if(n==k){do{$a[k].appendTo($(".topic-reply"));h.html(c[k]);k++;}while($a[k]!=undefined);}}});}})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import SimpleHTTPServer | |
import SocketServer | |
import time | |
import os | |
import socket | |
class TestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
class PriorityQueueNode(object): | |
def __init__(self, id, value): | |
self.id = id | |
self.value = value | |
class PriorityQueue(object): | |
def __init__(self, k): | |
self.q = deque() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INF = 999999999999999 | |
class SegTreeNode(object): | |
def __init__(self, left, right, data): | |
self.left = left | |
self.right = right | |
self.data = data | |
self.left_child = None | |
self.right_child = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tarjan(N, S, T, edges): | |
cnt = 0 | |
bridges = [] | |
visit = [0 for i in range(N)] | |
low = [N + 1 for i in range(N)] | |
ret = [False for i in range(N)] | |
q = [0 for i in range(N + 1)] | |
q[0] = (S, -1, -1) | |
top = 0 | |
while top >= 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
__doc__ = """Tiny HTTP Proxy. | |
This module implements GET, HEAD, POST, PUT and DELETE methods | |
on BaseHTTPServer, and behaves as an HTTP proxy. The CONNECT | |
method is also implemented experimentally, but has not been | |
tested yet. | |
Any help will be greatly appreciated. SUZUKI Hisao |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getDistanceFromLatLonInKm = (lat1, lon1, lat2, lon2)-> | |
R = 6371 # Radius of the earth in km | |
dLat = deg2rad(lat2 - lat1) # deg2rad below | |
dLon = deg2rad(lon2 - lon1) | |
a = Math.sin(dLat/2) * Math.sin(dLat/2) + | |
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * | |
Math.sin(dLon/2) * Math.sin(dLon/2) | |
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)) | |
d = R * c # Distance in km | |
return d |
OlderNewer