View gist:d9fe7c566cdb1abde94d58bc742302d5
var dispatchMouseEvent = function(target, var_args) {
var e = document.createEvent("MouseEvents");
// If you need clientX, clientY, etc., you can call
// initMouseEvent instead of initEvent
e.initEvent.apply(e,, 1));
function clickContinue() {
dispatchMouseEvent(element, 'mouseover', true, true);
//In discussion of
//awang:/tmp/ $ cat [20:57:30]
public class GarbageTest {
private void f() throws IOException {
throw new IOException();
View solve Einstein puzzle using Pycosat
import pycosat
class Var(object):
_num_vars = 0
idx_to_var = {}
def _add_var(var):
Var._num_vars += 1
idx = Var._num_vars
View Java.Apache.HttpClient.MakeRequest
public static String getAccessTokenOfAccount() throws IOException {
String url = "SOMEURL";
DefaultHttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
StringBuilder result = new StringBuilder();
View server-vagrant-setup
apt-cache search virtualbox
sudo aptitude install virtualbox-ose-dkms
wget (#
dpkg -i vagrant_1.7.2_x86_64.deb
sudo dpkg -i vagrant_1.7.2_x86_64.deb
sudo apt-get install linux-headers-$(uname -r)
sudo dpkg-reconfigure virtualbox-ose-dkms
ps = d.disqus.posts.list(forum='campusnews')
#likes / dislikes
rs = d.disqus.posts.details( post='1310432214')
View lisp.el
(defun db-compile()
"run a command on the current file and revert the buffer"
(format " %s"
(shell-quote-argument (buffer-file-name))))
(revert-buffer t t t))
(global-set-key (kbd "M-o M-c") 'db-compile)
def foo():
if __name__ == '__main__':
import timeit
print(timeit.timeit("test()", setup="from __main__ import test", number=10))
if __name__=='__main__':
from timeit import Timer
t = Timer(lambda: foo(bar) )
View faq.ksh
T=$(grep -i "Message received:" $F | wc -l)
typeset -F2 MP=$M.00/$T.00 #float number calculation
printf "Total[%8s] [%8.2f]"
#meaning escalate all warnings like 0 rows
set -e
tr '\n' ' ' | sed s/.$//' '
grep -i "message" `find 2014* -type f -name *.log` | wc -l