Skip to content

Instantly share code, notes, and snippets.

import socket
import sys
import time
from math import floor
class Controller:
def __init__(self, sock, target_v):
self.s = sock
self.target_v = target_v
f, v = self.get_status()
@teloon
teloon / hg_discard_local_changes
Created October 16, 2013 21:48
The -C flag tells the update command to discard all local changes before updating. However, this might still leave untracked files in your repository. It sounds like you want to get rid of those as well, so I would use the purge extension for that:
hg pull
hg update -r MY_BRANCH -C
hg purge
function htmlDecode(input){
var e = document.createElement('div');
e.innerHTML = input;
return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
}
htmlDecode("<img src='myimage.jpg'>");
// returns "<img src='myimage.jpg'>"
@teloon
teloon / coloncolon.cpp
Created April 16, 2012 07:12
example of "::"
#include <stdio.h>
int count = 0; //全局变量 0
void main()
{
int count = 10; //局部变量10
printf("count =%d\n",count);//局部变量屏蔽了全局变量 所以输出结果是10
{
int count = 20;
printf("count =%d\n",::count); //作用域符号指出引用全局变量0
//::sort
@teloon
teloon / wait_notify.java
Created April 6, 2012 13:00
multi-thread wait&notify
public class MultiThread {
public static void main(String[] args) {
new Thread(new Thread1()).start();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
new Thread(new Thread2()).start();
}
@teloon
teloon / abstract.java
Created March 16, 2012 08:01
inheritance of abstract class & the initialization sequence
abstract class A{
abstract void f();
A(){
System.out.println("Initialize A before f()");
f();
System.out.println("Initialize A after f()");
}
}
class B extends A {
#!/usr/bin/python
# -*- encoding:utf-8 -*-
import cookielib, urllib2, urllib
import re
def get_postFormID(opener):
temp = open('temp.txt', 'w+')
form_url = 'http://blog.renren.com/blog/0/addBlog'
lines = opener.open(form_url).readlines()
# it seems the order of value and id is random