Saturday, May 3, 2014

Heart bleed with Python

Programming is fun
When the work is done
if you wanna make your work also fun:
      use Python!




http://pen-testing.sans.org/blog/pen-testing/2014/04/16/sans-python-pen-testers-exploit-heartbleed-vulnerabilities-sec573-2

Tennis Lesson Step by Step

Tennis Lesson Step by Step


[This video is for quickstart 1 and 2, under 10 years old.]
QuickStart 3 can play the whole distance.

Tennis mom: To get them involved with each other and play together will help them in long run and play the game better. Team environment make it much easier.


[QuickStart Tennis - Ages 7 & 8: Instant Rally Progression]

The foundation of the game is to learn how to play the forehand.
a, soft rally, tapping the ball up.
b, head level high, one after another
c, alternate hit, with the partner
d, nice movement.
e, over the line and then over the net
f, put the racquet together and one step back, and give them a target.


[QuickStart Tennis - Ages 7 & 8: Roll Ball]

a, roll the ball on the court, stop with the racquet and roll it back

[QuickStart Tennis - Ages 7 & 8: Six Serve Options]

 a, when we start to play, what is the most important? we have to start with serving.

b, option 1: behind the line, under hand serving without bouncing

c, option 2: over hand serve, another legal serve

d, option 3, drop the ball and hit to the other side of the court.

e, option 4, coach drop the ball.

f, option 5, coach toss the ball in

[QuickStart Tennis - Ages 7 & 8: Dynamic Warm Up]

a, jogging around the place and toss the ball form side to side

b, slower the feet and faster the hand / and reverse

c, back to regular jog and regular juggle

d, skip and juggle

e, high knee and juggle  (freeze, and face me)

f,  pass the ball around the left leg / right leg

g, toss the ball in the air, jump up and catch the ball in the air

h, dribble the ball with the left hand and right hand

i, stay in the blue area, dribble without running into anybody.

j, grab a partner, toss the ball back and forth


 


 



Tuesday, March 4, 2014

Linux Memory information

[root@localhost ~]# cat /proc/self/status
Name: cat
State: R (running)
SleepAVG: 88%
Tgid: 5783
Pid: 5783
PPid: 5742
TracerPid: 0
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 256
Groups: 0 1 2 3 4 6 10
VmSize: 6588 kB
VmLck: 0 kB
VmRSS: 400 kB
VmData: 144 kB
VmStk: 2040 kB
VmExe: 14 kB
VmLib: 1250 kB
StaBrk: 0804e000 kB
Brk: 088df000 kB
StaStk: bfe03270 kB
ExecLim: 0804c000
Threads: 1
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000000000000
CapInh: 0000000000000000
CapPrm: 00000000fffffeff
CapEff: 00000000fffffeff


输出解释
参数 解释
Name 应用程序或命令的名字
State 任务的状态,运行/睡眠/僵死/
SleepAVG 任务的平均等待时间(以nanosecond为单位),交互式任务因为休眠次数多、时间长,它们的 sleep_avg 也会相应地更大一些,所以计算出来的优先级也会相应高一些。
Tgid 线程组号
Pid 任务ID
Ppid 父进程ID
TracerPid 接收跟踪该进程信息的进程的ID号
Uid Uid euid suid fsuid
Gid Gid egid sgid fsgid
FDSize 文件描述符的最大个数,file->fds
Groups
VmSize(KB) 任务虚拟地址空间的大小 (total_vm-reserved_vm),其中total_vm为进程的地址空间的大小,reserved_vm:进程在预留或特殊的内存间的物理页
VmLck(KB) 任务已经锁住的物理内存的大小。锁住的物理内存不能交换到硬盘 (locked_vm)
VmRSS(KB) 应用程序正在使用的物理内存的大小,就是用ps命令的参数rss的值 (rss)
VmData(KB) 程序数据段的大小(所占虚拟内存的大小),存放初始化了的数据; (total_vm-shared_vm-stack_vm)
VmStk(KB) 任务在用户态的栈的大小 (stack_vm)
VmExe(KB) 程序所拥有的可执行虚拟内存的大小,代码段,不包括任务使用的库 (end_code-start_code)
VmLib(KB) 被映像到任务的虚拟内存空间的库的大小 (exec_lib)
VmPTE 该进程的所有页表的大小,单位:kb
Threads 共享使用该信号描述符的任务的个数,在POSIX多线程序应用程序中,线程组中的所有线程使用同一个信号描述符。
SigQ 待处理信号的个数
SigPnd 屏蔽位,存储了该线程的待处理信号
ShdPnd 屏蔽位,存储了该线程组的待处理信号
SigBlk 存放被阻塞的信号
SigIgn 存放被忽略的信号
SigCgt 存放被俘获到的信号
CapInh Inheritable,能被当前进程执行的程序的继承的能力
CapPrm Permitted,进程能够使用的能力,可以包含CapEff中没有的能力,这些能力是被进程自己临时放弃的,CapEff是CapPrm的一个子集,进程放弃没有必要的能力有利于提高安全性
CapEff Effective,进程的有效能力

Thursday, January 2, 2014

Learn Python the hard way


Programming is fun
When the work is done
if you wanna make your work also fun:
      use Python!



######Exercise 1: A Good First Program

######Exercise 2: Comments And Pound Characters
a, How do I comment out multiple lines?
[Put a # in front of each one.]

######Exercise 3: Numbers And Math

######Exercise 4: Variables And Names
a, What is the difference between = (single-equal) and == (double-equal)?
[The = (single-equal) assigns the value on the right to a variable on the left. The == (double-equal) tests if two things have the same value]

######Exercise 5: More Variables And Printing (embedded a variable in the string)
a, print "He's got %s eyes and %s hair." % (my_eyes, my_hair)  ==> multiple format
b,  %r is a very useful one. It's like saying "print this no matter what."

######Exercise 6: Strings And Text
######Exercise 7: More Printing (watch the comman at the end)
print end1 + end2 + end3 + end4 + end5 + end6,
print end7 + end8 + end9 + end10 + end11 + end12

######Exercise 8: Printing, Printing
formatter = "%r %r %r %r"

print formatter % (1, 2, 3, 4)
print formatter % ("one", "two", "three", "four")

######Exercise 9: Printing, Printing, Printing
######Exercise 10: What Was That?
a, This use of the \ (backslash) character is a way we can put Difficult-To-Type characters into a string.
\\     Backslash ()
\'     Single-quote (')
\"     Double-quote (")
\a     ASCII bell (BEL)
\b     ASCII backspace (BS)
\f     ASCII formfeed (FF)
\n     ASCII linefeed (LF)
\N{name}     Character named name in the Unicode database (Unicode only)
\r ASCII     Carriage Return (CR)
\t ASCII     Horizontal Tab (TAB)
\uxxxx     Character with 16-bit hex value xxxx (Unicode only)
\Uxxxxxxxx     Character with 32-bit hex value xxxxxxxx (Unicode only)
\v     ASCII vertical tab (VT)
\ooo     Character with octal value ooo
\xhh     Character with hex value hh

######Exercise 11: Asking Questions
x = int(raw_input())  and raw_input()

######Exercise 12: Prompting People
a, [pydoc -p 80]
b, [age = raw_input("How old are you? ")]
c, install new package requests:
---download: curl -OL https://github.com/kennethreitz/requests/tarball/master
---tar -xvf xxx.tar
---python setup.py install

######Exercise 13: Parameters, Unpacking, Variables
a, [Remember that an important skill is paying attention to details.]  <=================
b, code:
---from sys import argv
---script, first, second, third = argv  ==>Easier way
---print "The script is called:", script

######Exercise 14: Prompting And Passing
likes = raw_input(prompt)

######Exercise 15: Reading Files
######Exercise 16: Reading And Writing Files
######Exercise 17: More Files
######Exercise 18: Names, Variables, Code, Functions
######Exercise 19: Functions And Variables
######Exercise 20: Functions And Files
######Exercise 21: Functions Can Return Something
######Exercise 22: What Do You Know So Far?
######Exercise 23: Read Some Code
######Exercise 24: More Practice
######Exercise 25: Even More Practice
######Exercise 26: Congratulations, Take A Test!
######Exercise 27: Memorizing Logic
######Exercise 28: Boolean Practice
######Exercise 29: What If
######Exercise 30: Else And If
######Exercise 31: Making Decisions
######Exercise 32: Loops And Lists
######Exercise 33: While Loops
######Exercise 34: Accessing Elements Of Lists
######Exercise 35: Branches and Functions
######Exercise 36: Designing and Debugging
######Exercise 37: Symbol Review
######Exercise 38: Doing Things To Lists
######Exercise 39: Dictionaries, Oh Lovely Dictionaries
######Exercise 40: Modules, Classes, And Objects
######Exercise 41: Learning To Speak Object Oriented
######Exercise 42: Is-A, Has-A, Objects, and Classes
######Exercise 43: Gothons From Planet Percal #25
######Exercise 44: Inheritance Vs. Composition
######Exercise 45: You Make A Game
######Exercise 46: A Project Skeleton
######Exercise 47: Automated Testing
######Exercise 48: Advanced User Input
######Exercise 49: Making Sentences
######Exercise 50: Your First Website
######Exercise 51: Getting Input From A Browser
######Exercise 52: The Start Of Your Web Game
Advice From An Old Programmer
Next Steps
Appendix A: Command Line Crash Course

Monday, September 30, 2013

If you can't explain it simply, you don't understand it well enough. Albert Einstein

Tuesday, April 16, 2013

UFile Content

UFile

a, Email address as username

b, the TAB need to fill.
--1, ID. SIN card, Name, Birthday
--2, CRA questions.
--3, Interview. check "Foreign income (T1135)", Provincial Tax,
--4, current address. And when move into BC
--8, T4A(OAS). Have to fill 0. otherwise it will report an error.
--9, foreign income.


Saturday, March 2, 2013

US Visa

一个多月前陪父母申请了美国签证,现在把过程写下来,供同学们参考(再不写,时间一长就都忘了)。很早前 有网友写过“2008年11月在温哥华申请美国签证最新全过程”,里面对每一步都写得很详细,但因美签自2010年9月1日起采用新的预约系统,预约、交 费及Pick up等都与以往不同了,所以偶还是把这些过程写一下:

1 填表

填表这一步骤与以前并没有什么不同,仍然是到ceac.state.gov/genniv/ 网站上填表及上传照片。具体可以参考(2008年11月在温哥华申请美国签证最新全过程)中的“填表” 那部分。需要注意的是:

- 要为每一位成人填一份申请表,也就是说,父母两个人要填两份正式的申请表。
- 填表前先用"Test Photo"功能,上传父母每个人的照片,看照片是否满足要求。
- 每次填申请表都会得到一个Application ID,并会问一个Security Question(例如你外婆的名字等)。这个ID 很重要,最好另外保存起来。因为填表的过程中要回答很多很多问题,如果当天不能填完的话,可以点击"Save"将申请表保存起来,下次填写时凭 Application ID及Security Question的答案,即可调出之前未填完的表格继续填写。
- 填完后一定要将Confirmation Page(就是带条形码的那一页)打印出来,这是面试时必须要带的文件。表格本身可以不打印,如果担心自己会忘记所填的各项内容,也可以打印出来供自己备份。

2 预约

填完表后,在新的美签预约网站预约面试时间: usvisa-info.com/en-CA/...vice/login 。如果父母的国籍是中国,请注意填国籍的时候一定要改成China, 系统默认的是Canada。签证类型选择:Visitor Visa for Business or Pleasure (B-1/B-2) ,并选择好你想Pick up 护照/签证的城市(DHL Branch),之后是填写名字,性别,电话,E-mail 地址,Confirmation Page上的Confirmation Number 等简单信息。进去后系统会显示最早的available time(通常是某天的早上7点或8点),接着进到选择具体时间的页面,会看到很多上午和下午的时间供选择。选择好时间后,可以点击"Add Family Member",增加另一位的信息,然后在线用信用卡付两个人的签证费用(现在是每人$140美金)。付费后将预约信Appointment information letter 打印出来,这是面试当天需要出示给门口的使馆人员看的。

3 面试

预约信上会详细列出面试时需要准备的材料及各种注意事项。如果是陪父母申请美国签证,子女一方最好准备好公司开的雇佣信(Employment Letter),工资单,税单(Notice of Assessment),银行月结单(Bank Statement)以及自己的护照(公民只需带护照,移民需带上护照和枫叶卡)。父母一方准备好护照,如果已经移民就一定带上枫叶卡,如果在银行有账 户,就带上银行月结单(Bank Statement)。

美国使馆的地址是:1075 West Pender Street。面试当天如果到得比较早,就先在使馆门外排队,门口的工作人员会以Family为单位,让进入到一楼安检。这时跟工作人员说明自己是翻译, 工作人员都会让进去的。进去后在一楼狭窄的入口处,将所有口袋里的所有东西都拿出来放到托盘上,将外套脱掉,工作人员会从上到下地仔细检查外套。明文规 定:食物、饮料、武器、工具、背包、行李、钱包、大的儿童推车、各类电子设备(手提电脑、手机、PDAs、卡带机、CD机、MP3、传呼机、无线遥控)等 都不让带进去,所以偶只带了一个装有文件及护照的文件夹,口袋里放了钥匙和一点现金,其他连手机等都没敢带。不过偶后来在二楼等面试的时候,有看到带背包 的女士,偶猜测可能背包仔细检查过没问题的话也是可以带的。

安检过后上二楼,二楼等候厅门口的工作人员查收了父母的护照及Confirmation Page,并检查了他们的枫叶卡,之后给了一个号。等候厅里有饮料机,公共电话及自动照相机。从等候厅的后门出去就是洗手间,等候期间可以从后门去洗手 间,然后再从查收证件的前门进来。等候厅上方正中间的指示牌显示轮到去按指模的号码,轮到后就去前面的小窗口,父母每个人按照工作人员的指导分别在仪器上 按两个手的指模。按完后,工作人员会把护照和确认信还回来,然后继续关注等候厅上方右侧的指示牌。轮到后就从后门出去坐电梯去二十楼面试,从进等候厅开始 到轮到上二十楼,大概等了一个小时。现在上到二十楼后已经不需要再安检了,在等候室坐着等几分钟后,看到上方的指示牌显示出自己的号码及窗口号后,就到相 应的窗口见面试官。

面试官开始问问题,并要求偶必须先把问题翻译给父母听,然后再把他们的回答翻译给他听,偶不可以直接用英语回答他的问题。面试过程很短,面试官主要是问了 偶父母是否是第一次去美国,在美国有没有亲戚,问有没有带Bank Statement(父母没有,偶没带,偶原以为有雇佣信和工资单就可以了),偶说没带但有雇佣信,他将雇佣信拿过去看后点点头。接着问父母是否与偶一起 居住,问去美国做什么,父母的旅行费用是否由偶支付以及父母退休前的工作等等(每位面试官可能问的问题不太一样,上述面试过程仅供参考)。问完后,他马上 说签证已批准,并给了一张纸,让过几天去上面的网站(就是预约网站)查status,看什么时候可以取。

4 取护照/签证

现在不需要自己去领事馆pickup签证了,美国使馆已交由快递公司处理了。如果在预约时填了Email 地址的话,快递公司会发邮件告知处理的进度及DHL Waybill Number 。大约两到三个工作日后,去预约网站用之前预约的时候填的护照号码与国籍登陆(再次提醒,国籍不要选错了),如果看见:

Applicant Status: Ready for pickup
DHL Waybill Number:

就是签证可以取了,然后抄下或打印出DHL WayBill Number,带上父母的Photo ID (例如枫叶卡),就可以到你指定的DHL Branch 拿护照/签证了。