Skip to content

Instantly share code, notes, and snippets.

@xudifsd
xudifsd / Complete.java
Last active December 29, 2023 11:57
output of smali AST tree
package com.example;
public class Complete {
public int i;
private String s;
public Complete(int i, String s) {
this.i = i;
this.s = s;
}
@xudifsd
xudifsd / t.c
Created August 25, 2013 08:24
compile C and execute "python t.py", press CTRL+C or CTRL+\ when executing python. will print "^Cgot signal" in my laptop
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
int signaled = 0;
void handler(int ignored) {
signaled = 1;
}
@xudifsd
xudifsd / load-blancer.clj
Last active December 21, 2015 13:48
use zmq as concurrent server
(ns load-blancer
(:import [org.zeromq ZMQ ZMQ$PollItem ZMQ$Poller]))
; the functionality of this is same with zmq-server.clj, but we handle routing manually
(defn dequeue! [queue-ref]
(dosync
(let [q @queue-ref
result (peek q)
remain (if (= q [])
[]
@xudifsd
xudifsd / t.py
Created August 19, 2013 02:47
there are two method for get timestamp, first is just use system call, second is use system call for the first time, and then start a background thread and let system to schedule a inc function every second. from this test, we can see that the second method is more efficient.
#!/usr/bin/env python
import threading, time
time1 = 0
def get_time1():
return time1
def get_time2():