http://formatmysourcecode.blogspot.tw/
- 3月 29 週六 201418:08
format my source code to html
- 10月 06 週一 201417:25
python - time
Reference
Introduction to datetime object
Introduction to datetime object
- 9月 16 週二 201417:39
python - thread
Return Value of threads
# -*- coding: UTF-8 -*-
def foo(bar, result, index):
print 'hello {0}'.format(bar)
result[index] = "foo"
from threading import Thread
threads = [None] * 10
results = [None] * 10
for i in range(len(threads)):
threads[i] = Thread(target=foo, args=('world!', results, i))
threads[i].start()
# do some other stuff
for i in range(len(threads)):
threads[i].join()
print " ".join(results) # what sound does a metasyntactic locomotive make?
# -*- coding: UTF-8 -*-
def foo(bar, result, index):
print 'hello {0}'.format(bar)
result[index] = "foo"
from threading import Thread
threads = [None] * 10
results = [None] * 10
for i in range(len(threads)):
threads[i] = Thread(target=foo, args=('world!', results, i))
threads[i].start()
# do some other stuff
for i in range(len(threads)):
threads[i].join()
print " ".join(results) # what sound does a metasyntactic locomotive make?
- 9月 16 週二 201417:32
Javascript - class
Reference
[1]static method in javascript
http://stackoverflow.com/questions/1535631/static-variables-in-javascript
[1]static method in javascript
http://stackoverflow.com/questions/1535631/static-variables-in-javascript
- 4月 22 週二 201410:11
shell - while loop
#!/bin/bash
count=0
while [ true ]
do
count=$(( $count+1 ))
echo $count
if [ $count -eq 10 ];then
break
fi
sleep 1
done
count=0
while [ true ]
do
count=$(( $count+1 ))
echo $count
if [ $count -eq 10 ];then
break
fi
sleep 1
done
- 4月 22 週二 201410:09
expect - sftp example
#!/opt/csw/bin/expect
set timeout 20
spawn sftp root@host
expect "*password*"
send "ej03xu35k3au4a83\r"
expect "*sftp*"
send "cd /usr/bin/\r"
expect "*sftp*"
send "put rsync\r"
expect "*sftp*"
send "exit\r"
interact
set timeout 20
spawn sftp root@host
expect "*password*"
send "ej03xu35k3au4a83\r"
expect "*sftp*"
send "cd /usr/bin/\r"
expect "*sftp*"
send "put rsync\r"
expect "*sftp*"
send "exit\r"
interact
- 4月 17 週四 201417:46
javascript injection
<
>
>
- 4月 16 週三 201411:02
[轉錄] ls color setting
ref :http://blog.longwin.com.tw/2006/07/color_ls_in_bash_2006/
Display : ls --color
Setting : declare -x (for linux)
Display : ls --color
Setting : declare -x (for linux)
- 4月 14 週一 201416:31
python - inheritance & template pattern
class base:
def __init__(self, name):
self.name = name
def show(self):
print "Base Class is here!!"
def show_name(self):
print "name:", self.name
def process(self):
self.show_name()
self.show()
class sub(base):
def show(self): // override show method
print "Sub class is here!!"
base_class = base("Base Class")
base_class.process()
sub_class = sub("Sub Class")
sub_class.process()
def __init__(self, name):
self.name = name
def show(self):
print "Base Class is here!!"
def show_name(self):
print "name:", self.name
def process(self):
self.show_name()
self.show()
class sub(base):
def show(self): // override show method
print "Sub class is here!!"
base_class = base("Base Class")
base_class.process()
sub_class = sub("Sub Class")
sub_class.process()
- 4月 08 週二 201418:03
sorting by value of dictionary
d = {1: 2, 3: 4, 4:3, 2:1, 0:0}
sorted(d.items(), key=lambda x: x[1])
sorted(d.items(), key=lambda x: x[1])
