public void callAsynchronousTask() {
final Handler handler = new Handler();
Timer timer = new Timer();
TimerTask doAsynchronousTask = new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
public void run() {
try {
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
import smtplib | |
from email.mime.text import MIMEText | |
from email.header import Header | |
from email.utils import parseaddr, formataddr | |
def _format_addr(s): | |
name, addr = parseaddr(s) | |
return formataddr(( \ | |
Header(name, 'utf-8').encode(), \ | |
addr.encode('utf-8') if isinstance(addr, unicode) else addr)) |
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
import socket | |
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP | |
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
client.bind(("", 12476)) | |
while True: | |
data, addr = client.recvfrom(1024) | |
print("received message: %s"%data) |
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
gist.el now maintains a local cache so as to not go to the gist server every now and then. | |
multi-files gist support (indicated by a '+' in the gist list) | |
improved gist-list buffer, based on tabulated-list.el (same codebase as package.el) New keybindings: | |
g : reload the gist list from server | |
e : edit current gist description | |
k : delete current gist | |
+ : add a file to the current gist | |
- : remove a file from the current gist | |
y : print current gist url | |
b : browse current gist |
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
import pickle | |
a = # some NumPy array | |
serialized = pickle.dumps(a, protocol=0) # protocol 0 is printable ASCII | |
deserialized_a = pickle.loads(serialized) |
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
let initialState = Immutable.Map({count:1, b:2, c:3}); | |
function counter(state = initialState, action) { | |
switch (action.type) { | |
case 'INCREMENT': | |
return state.set('count',state.get('count')+1); | |
case 'DECREMENT': | |
return state.set('count',state.get('count')-1); | |
default: |
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 { | |
include mime.types; | |
server { | |
listen 8080; | |
lua_code_cache off; | |
location / { | |
default_type text/html; | |
content_by_lua ' |
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
alias duone="du -m -d 1 | sort -n" |
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
alias gitcurrentstatus="git remote -v && git rev-list HEAD --max-count=1" |
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 _ParseArguments(args): | |
cmd = None | |
opt = _Options() | |
arg = [] | |
for i in range(len(args)): | |
a = args[i] | |
if a == '-h' or a == '--help': | |
opt.help = True |
NewerOlder