View RestartmDNSResponder
#!/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 |
View snow.js
/* | |
Snow Fall 1 - no images - Java Script | |
Visit http://rainbow.arch.scriptmania.com/scripts/ | |
for this script and many more | |
*/ | |
// Set the number of snowflakes (more than 30 - 40 not recommended) | |
var snowmax=35; | |
// Set the colors for the snow. Add as many colors as you like |
View doubanRefresh.js
javascript:if(typeof(flag)=="undefined"||flag==false){flag=true;timer=window.setInterval(function(){$(".stream-new").click();},4000);}else{flag=false;window.clearInterval(timer);} |
View onlylz.js
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);}}});}})() |
View CORSServer.py
#!/usr/bin/python | |
import SimpleHTTPServer | |
import SocketServer | |
import time | |
import os | |
import socket | |
class TestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): |
View PriorityQueue.py
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() |
View SegmentTree.py
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 |
View dijkstra.py
from heapq import heappush, heappop | |
def dijkstra(N, S, edges): | |
d = [INF for i in range(N)] | |
d[S] = 0 | |
h = [] | |
heappush(h, (0, S)) | |
for i in range(N - 1): | |
min_dist, k = 0, 0 | |
if not h: break |
View tarjan.py
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: |
View Treap.py
import random | |
class TreapNode(object): | |
def __init__(self, key, data): | |
self.key = key | |
self.ran = random.random() | |
self.size = 1 | |
self.cnt = 1 | |
self.data = data | |
self.left = None |
OlderNewer