CPT OPT STEM H1B …这些都是最近萦绕在脑海里的词眼,今天和猫叔聊天以后思路理清了不少。bty,猫叔的心态真年轻。

大二有拿到Birmingham的Condition Offer,当时因为各种各样的原因放弃了这个最接近肉身翻墙的机会,自己做的决定当然不会后悔,现在又到了选择的岔路口,我觉得是时候开始行动了。

问我为什么没有去腐国呢?给个链接,自己体会:)

http://dwz.cn/3G22vn

因为要写一段代码,需要用到sleep()函数,在我印象中,sleep(300)好像是休眠300微秒,结果在Ubuntu却是休眠了300秒。觉得很奇怪所以就查了一下。
linux下的sleep()函数原型为:

unsigned int sleep(unsigned int seconds);

而Windows中的Sleep()函数原型为:

void Sleep(DWORD dwMilliseconds);

也就是说,Linux下(gcc库),sleep()函数是以秒为单位的,sleep(1)就是休眠1秒。而Windows下的Sleep()函数是以微秒为单位的,Sleep(1000)是休眠1秒。

如果在Linux下也用微妙为单位休眠,可以使用线程休眠函数:void usleep(unsigned long usec);

#include <system.h>
void usleep(unsigned long usec);

BTW,linux下还有个delay()函数,原型为extern void delay(unsigned int msec),它可以延时msec*4 ms,也就是如果想延时一秒钟的话,可以用delay(250).

Here is a Python example where something is run once a minute:

import time 
while True:
    print "This prints once a minute."
    time.sleep(60)  # Delay for 1 minute (60 seconds)

今天机缘巧合黑进去了女神的教务系统,过程不想多说,本来想留下点什么,但是最后还是悄无声息的走了。

——

Only two things are infinite,

the universe and human stupidity,

and I’m not sure about the universe.

Space Station View of the Full Moon

Space Station View of the Full Moon

下午考完嵌入式,回来继续写操作系统课设,功能模块已经全部完成了,接下来打算用shell简单写一个脚本调用这些接口。

搞定之后执行脚本,在机器上报错Syntax error: "(" unexpected

这和程序所在机器的shell版本有关。你可以用 ls -l /bin/*sh 打印出来:

< os-1.3/bin >  ls -l /bin/*sh
-rwxr-xr-x 1 root root 986672 Oct  8  2014 /bin/bash
-rwxr-xr-x 1 root root 112204 Feb 19  2014 /bin/dash
lrwxrwxrwx 1 root root      4 Oct  8  2014 /bin/rbash -> bash
lrwxrwxrwx 1 root root      4 Jan 27  2015 /bin/sh -> dash
lrwxrwxrwx 1 root root      7 Nov 15  2013 /bin/static-sh -> busybox
You have new mail in /var/mail/root
< os-1.3/bin >

在这里,sh被重定向到dash,因此,如果执行./os-1.3 -e,则使用的是dash.

解决办法有很多,我是将脚本第一行改为#!/bin/bash,当然也可以不修改,执行# bash os也是可以的。

今天在StackOverflow上看到这样一道题,原题是这样的:

Divide a number by 3 without using *, /, +, -, % operators

===========================

This question has been asked in an Oracle interview.

How would you divide a number by 3 without using */+-%, operators?

The number may be signed or unsigned.

===========================

unsigned add(char const zero[], unsigned const x, unsigned const y) {
  // this exploits that &foo[bar] == foo+bar if foo is of type char*
  return (int)(uintptr_t)(&((&zero[x])[y]));
}

unsigned div_by(unsigned const x, unsigned const by) {
  unsigned floor = 0;
  for (unsigned cmp = 0, r = 0; cmp <= x;) {
    cmp = add(0,cmp,by);
    floor = r;
    r = add(0,r,1);
  }
  return floor;
}

===========================

Using cloud computing 😀

Google Search: 30 divided by 3

INTERSETING…

alias 的最大好处是,可以简化输入,从而为你节省时间,并提高效率。定义的 alias 可以保存到 ~/.bashrc 文件中,souce之后就可以直接使用了,今天分享一下我的Bash alias

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias grep='grep -i --color'
alias c='clear'
alias kill9='kill -9';
psid() {
  [[ ! -n {1} ]] && return;   # bail if no argument   pro="[{1:0:1}]{1:1}";      # process-name –> [p]rocess-name (makes grep better)   ps axo pid,user,command | grep -v grep |grep -i --color {pro};   # show matching processes
  pids="(ps axo pid,user,command | grep -v grep | grep -i {pro} | awk '{print 1}')";   # get pids   complete -W "{pids}" kill9     # make a completion list for kk
}
alias ls='ls --color=auto'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

进乌云空间需要5个乌币,记得以前看到过一篇空间的文章,没有登录空间也能进去看,奇怪的是,登录空间后反而不能看了,于是我退出空间,然后在进空间看.发现只能看一部分的文章,不能看全部的。但是我发现,只要有乌云空间帖子的地址,不需要登录就能看帖子,于是用Python爬了下空间的帖子。

简单的分析帖子地址

http://zone.wooyun.org/content/29
http://zone.wooyun.org/content/50

可以发现,帖子的标识就是URL最后面的数字

如果访问正确的数字,就会显示出帖子的内容

访问错误的数字,就会跳转到登录页面

大概过程

生成一个帖子地址数组

访问一个地址,判断是否为帖子

将帖子内容到本地

多线程爬乌云空间

准备工作:

Python3.5版本

编辑器:Pycharm

引用包:requests   threading

开始

① 生成一个帖子地址数组

def mkUrlList(maxNum):
    urlList = list(("http://zone.wooyun.org/content/%d" %num for num in range(0,maxNum)))
    return urlList

maxNum参数是最大帖子数字,比如你想生成0到1000的地址数组,这么调用就可以了:

mkUrlList(1000)

第二行的代码,可能有的我没看懂,这其实是Python的一个语法糖,第一段代码其实也可以这么写

def mkUrlList(maxNum):
    urlList = []
    for num in range(0,maxNum):
        urlList.append("http://zone.wooyun.org/content/%d" %num)
    return urlList

Continue reading

请假未遂,下个月只能去上海周边一个荒无人烟的小公司去做工,据说只有大床没有宽带,宝宝很不开心,作为一个爱学习的少年,自己动手丰衣足食,搞了这么一个小工具。

# How to Run

npm start # get a coffee or 10

# Require

lib ffmpeg is needed

# Thanks

lgy & soimort

# Click Here

https://github.com/HenryKamg/

There is one thing you should keep in mind when it comes to English tests.

English tests have very little to do with your ability to communicate in English.

These are two different sets of skills and they need a different strategy if you want to improve it.

(1) If you need to improve the test score

Use materials specifically designed to train you to pass this test.

(2) If you want to communicate in English

You need to listen to native conversations, speak and write in English every day. The only test here would be how fast you can come up with your own ideas in English and express these ideas to other people.

Learning a language can be very free-form. The only wrong way to learn a language is to do nothing.

I wish you the very best of luck.

via: Quara-How can I pass the CET6?