存档

作者存档

12306 自动登录 自动刷票攻略

2012年1月7日 Jarod Lee 没有评论

网络牛人就是多啊,真心感谢这些脚本的作者,下面简单介绍如何购票。

工具:

firefox + GreaseMonkey插件 + 自动登录脚本 + 自动刷票脚本

1. 首先安装firefox及其插件GreaseMonkey(用来管理JS脚本的)

2. 点击链接安装自动登录脚本,原始链接:https://gist.github.com/raw/1570973/f200dd587f6d68ab81edf74436b1fb7d91c79973/12306AutoLogin.user.js

作者实时更新中,最新的在这儿:https://gist.github.com/1570973

备用链接:

该插件严重推荐:只需要输入一次用户名、密码、验证码,即可进行多次尝试登录,直至登录成功。

3. 点击链接安装自动刷票的脚本, 原始链接:https://gist.github.com/raw/1554666/1b200667f1576f8f41657e65016d4853ed3a9998/12306.user.js

代码原始地址:https://gist.github.com/1554666

备用链接:

自动登录使用帮助:

该插件安装完成后,即可转到12306的网站登录:https://dynamic.12306.cn/otsweb/ , 输入用户名、密码、验证码,插件启用后,会多一个自动登录按钮, 然后点“自动登录”按钮即可。

如果登录成功后,会跳转到车票查询页面,使用自动刷票工具查询剩余票的信息

分类: 杂七杂八 标签:

Divide And Conquer

2011年9月2日 Jarod Lee 没有评论

Merge Sort:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
void Merge(int list[], int lowIndex, int highIndex, int midIndex)
{
   int *tempList = new int[highIndex-lowIndex+1];
   int firstLow = lowIndex;
   int secondLow = midIndex + 1;
   int index = 0;
   while(firstLow <= midIndex && secondLow <= highIndex)
   {
      if (list[firstLow] < list[secondLow])
         tempList[index++] = list[firstLow++];
      else
         tempList[index++] = list[secondLow++];
   }

   while (firstLow <= midIndex)
   {
      tempList[index++] = list[firstLow++];
   }

   while (secondLow <= highIndex)
   {
      tempList[index++] = list[secondLow++];
   }

   for (int ii = 0; ii < index; ii++)
   {
      list[lowIndex+ii] = tempList[ii];
   }
   delete[] tempList;
}

void MergeSort(int list[], int lowIndex, int highIndex)
{
   if (lowIndex < highIndex)
   {
      int midIndex = lowIndex + (highIndex-lowIndex)/2;
      MergeSort(list, lowIndex, midIndex);
      MergeSort(list, midIndex+1, highIndex);
      Merge(list, lowIndex, highIndex, midIndex);
   }
}
分类: C&&C++, Programming 标签:

Recursion

2011年9月1日 Jarod Lee 没有评论

递归生成某集合的所有序列:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
template <class T>
void Swap(T& a, T& b)
{
   T temp = a;
   a = b;
   b = temp;
}

template <class T>
void Permulation(T list[], int k, int m)
{
   if (k == m)
   {
      for (int i = 0; i <= m; i++)
         cout << list[i];
      cout << endl;
   }
   else
   {
      for (int i = k; i <= m; i++)
      {
         Swap(list[k], list[i]);
         Permulation(list, k+1, m);
         Swap(list[k], list[i]);
      }
   }
}

递归生成某集合的所有子集:

思想:
设集合X (A1, A2, A3,…, An)的所有子集为S[X(n)],从集合X中移走A1的子集X(n-1)的所有子集集合记为S[X(n-1)]
S[X(n)] = S[X(n-1)] ∪ {S[X(n-1)]每个子集加上A1}
例如 集合{A, B, C}
{A}:
{} {A}
{A B}:
{} {A} ∪ {B} {A B}
{A B C}:
{} {A} {B} {A B} ∪ {C} {A C} {B C} {A B C}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
template <class T>
void FindSubSets(T list[], int lowIndex, int highIndex, vector< set<T> > &results)
{
   if (lowIndex == highIndex)
   {
      set<T> empty;
      set<T> oneElem;
      oneElem.insert(list[lowIndex]);
      results.push_back(empty);
      results.push_back(oneElem);
   }
   else
   {
      FindSubSets(list, lowIndex+1, highIndex, results);
      int existedSetSize = results.size();
      for (int jj = 0; jj < existedSetSize; jj++)
      {
         set<T> newSet(results[jj]);
         newSet.insert(list[lowIndex]);
         results.push_back(newSet);
      }
   }
}

斐波那契数列计算:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
递归:
int r_Fibonacci(int n)
{
   if ( n < 2)
      return n;
   return r_Fibonacci(n-1) + r_Fibonacci(n-2);
}

非递归:
int fibonacci(int n)
{
   if ( n < 2)
      return n;
   int f0 = 0;
   int f1 = 1;
   for (int ii = 1; ii < n; ii++)
   {
      f1 = f1 + f0;
      f0 = f1 - f0;
   }
   return f1;
}

递归查找:

1
2
3
4
5
6
7
8
template <class InputIter, class T>
InputIter find(InputIter begin, InputIter end, const T& val)
{
   if (begin != end && *begin != val)
      return find(begin+1, end, val);
   else
      return begin;
}
分类: C&&C++ 标签:

3N+1

2011年8月31日 Jarod Lee 没有评论
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
int threeN(int n)
{
   if (n%2==0)
      return n/2;
   else
      return n*3+1;
}

int getLength(int n)
{
   static map<int, int> history;
   int key = n;
   
   if (n == 1)
      return 1;

   if (history.find(key) != history.end())
      return history[key];

   int length = getLength(threeN(n))+1;
   history[key] = length;
   return length;
}
分类: C&&C++, Programming 标签:

链表

2011年8月18日 Jarod Lee 没有评论

1. 逆转链表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
typedef struct Node
{
   int Data;
   Node *Next;
};

Node *ReverseList(Node *pHead)
{
   Node *pReverseHead = NULL;
   while (pHead != NULL)
   {
      Node *pTmp = pHead;
      pHead = pHead->Next;
      pTmp->Next = pReverseHead;
      pReverseHead = pTmp;
   }
   return pReverseHead;
}

bool hasCircle(Node *pHead)
{
   Node *pSlow = pHead;
   Node *pFast = pHead;
   while (pSlow && pFast && (pFast=pFast->Next) && pFast!=pSlow)
   {
      pSlow=pSlow->Next;
      pFast=pFast->Next;
   }
   return pFast != NULL;
}
分类: C&&C++, Programming 标签:

设计类时要考虑的问题

2011年8月9日 Jarod Lee 没有评论

1. 你的类需要构造函数吗?其访问控制级别怎样?

2. 数据成员需要设计成私有的吗?

3. 需要无参的构造函数吗?

4. 需要析构函数吗?需要设计成虚析构函数吗?

5. 需要复制构造函数吗

如果在构造函数中分配资源,则需要复制构造函数

6. 需要赋值操作符吗?

检查自我赋值

释放旧值, 复制新值

7. 需要定义关系运算符吗?

8. 参数类型需要加上 const 吗?

9. 成员函数需要时 const 吗?

分类: C&&C++, Programming 标签:

WinDBG 调用栈命令

2011年5月12日 Jarod Lee 没有评论

命令

==========

k

k命令显示的是一定数量的栈帧, 其中帧的数量是由.kframes命令来控制的, 默认值是256。

image

kp 5

显示调用栈中前5个函数以及他们的参数.

阅读全文…

分类: Programming 标签:

The Procrastination Flowchart

2011年4月12日 Jarod Lee 没有评论

procrastination-flowchart-1

Linux Directory Structure (File System Structure) Explained with Examples

2011年4月12日 Jarod Lee 没有评论

by Ramesh Natarajan on September 8, 2010

Have you wondered why certain programs are located under /bin, or /sbin, or /usr/bin, or /usr/sbin?

For example, less command is located under /usr/bin directory. Why not /bin, or /sbin, or /usr/sbin? What is the different between all these directories?

In this article, let us review the Linux filesystem structures and understand the meaning of individual high-level directories.

1. / – Root
  • Every single file and directory starts from the root directory.
  • Only root user has write privilege under this directory.
  • Please note that /root is root user’s home directory, which is not same as /.
2. /bin – User Binaries
  • Contains binary executables.
  • Common linux commands you need to use in single-user modes are located under this directory.
  • Commands used by all the users of the system are located here.
  • For example: ps, ls, ping, grep, cp.
3. /sbin – System Binaries
  • Just like /bin, /sbin also contains binary executables.
  • But, the linux commands located under this directory are used typically by system aministrator, for system maintenance purpose.
  • For example: iptables, reboot, fdisk, ifconfig, swapon
4. /etc – Configuration Files
  • Contains configuration files required by all programs.
  • This also contains startup and shutdown shell scripts used to start/stop individual programs.
  • For example: /etc/resolv.conf, /etc/logrotate.conf
5. /dev – Device Files
  • Contains device files.
  • These include terminal devices, usb, or any device attached to the system.
  • For example: /dev/tty1, /dev/usbmon0
6. /proc – Process Information
  • Contains information about system process.
  • This is a pseudo filesystem contains information about running process. For example: /proc/{pid} directory contains information about the process with that particular pid.
  • This is a virtual filesystem with text information about system resources. For example: /proc/uptime
7. /var – Variable Files
  • var stands for variable files.
  • Content of the files that are expected to grow can be found under this directory.
  • This includes — system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print queues (/var/spool); lock files (/var/lock); temp files needed across reboots (/var/tmp);
8. /tmp – Temporary Files
  • Directory that contains temporary files created by system and users.
  • Files under this directory are deleted when system is rebooted.
9. /usr – User Programs
  • Contains binaries, libraries, documentation, and source-code for second level programs.
  • /usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp
  • /usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel
  • /usr/lib contains libraries for /usr/bin and /usr/sbin
  • /usr/local contains users programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2
10. /home – Home Directories
  • Home directories for all users to store their personal files.
  • For example: /home/john, /home/nikita
11. /boot – Boot Loader Files
  • Contains boot loader related files.
  • Kernel initrd, vmlinux, grub files are located under /boot
  • For example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic
12. /lib – System Libraries
  • Contains library files that supports the binaries located under /bin and /sbin
  • Library filenames are either ld* or lib*.so.*
  • For example: ld-2.11.1.so, libncurses.so.5.7
13. /opt – Optional add-on Applications
  • opt stands for optional.
  • Contains add-on applications from individual vendors.
  • add-on applications should be installed under either /opt/ or /opt/ sub-directory.
14. /mnt – Mount Directory
  • Temporary mount directory where sysadmins can mount filesystems.
15. /media – Removable Media Devices
  • Temporary mount directory for removable devices.
  • For examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer
16. /srv – Service Data
  • srv stands for service.
  • Contains server specific services related data.
  • For example, /srv/cvs contains CVS related data.

每日字根:am, amat [L] = to love 爱

2011年4月12日 Jarod Lee 没有评论

字根am, amat来自于拉丁文amare, amat, 意思都相当于 to love. 常用词amiable(亲切的,和蔼可亲的), amateur(业余爱好者,业余艺术家)

amiable ['eimjәbl] 【am = to love; –i-; –able = capable of 可…的 ==> “capable of being loved 可爱的" —> a. 可爱的, 和蔼的】 an amiable old lady 可爱的老太太

amiableness【amiable –ness】n. 仁慈;厚道

amateur ['æmәtә(:), 'æmәtjuә]

【amat = to love 爱好; –eur(-er) n.=person 人 ==> “person who does something for loving it (rather than for money) 只因为爱好从事某项活动 –》 person who practises an art, sport, or science for his own pleasure(艺术, 体育, 科学) 业余爱好者, 还可以引申为‘外行’】/ a radio amateur 业余无线电爱好者

amateurism ['am·a·teur·ism || 'æmətərɪzm] n.  业余性; 非职业的作为

 

amateurish [am·a·teur·ish || ‚æmə'tɜːrɪʃ] adj.  外行的, 业余的; 笨拙的, 不熟练的

【amateur n. 业余爱好者; –ish a.= like… 像…的 == “like an amateur (rather than a professinal hand” 像搞业余的,不像内行的 –》a. unskillful 不老练的,外行的】

 

am/amat的同族词

amicable ['æmikәbl] adj.友善的, 和平的

【amic(来自am的同根拉丁名字amicus) =  person one loves or friend; –able a.=able to be能当…的, ‘able to be one’s friend, 能做朋友的’—》 a. 友好的,和睦的,无敌意的】

amicable relations

amicability n.  友善; 亲善; 和睦 –ability 是-able的对应名词后缀

 

amour 【am = to love; our n. = the state or result of 行为的状态或结果  “loveing or the result of loving” love affair especially discreditable one桃色事件

/ əˈmuə(r); əˋmʊr/ n (joc or rhet 谑或修辞) (esp secret) love affair (尤指秘密的)恋情; 偷情: Have you heard about his latest amour? 你听说他最近偷情的事了吗?

amorous ['æmәrәs] adj.多情的, 恋爱的, 表示爱情的 【根】am=to love(爱)

【amo(u)r; –ous】 adj. 爱的,多情的

enamour [i'næmә] vt. 迷住, 使迷恋

【en- = to make or cause to be使;amour = love 恋爱,爱情 =》“to make love to or cause to be in love 向..求爱,使恋爱 –》 imflame with love charm, 使清新,使迷恋】

【根】en-=in,into,on,at,near 从“在中间”之意演变成“使进入某种状态~,使成为~”等,把表示to make之意的名词、形容词变为及物动词 变化型 em-

例: her beauty enamoured the prince.

enamoured

(US enamored) / ɪˈnæməd; ɪnˋæmɚd/ adj [pred 作表语] ~ of/with sth (fml or joc 文或谑) fond of or delighted by sth 喜欢某事物; 倾心於某事物: enamoured of the sound of one’s own voice 陶醉於自己的嗓音 * I’m not too enamoured with the idea of spending a whole day with him. 我可不太喜欢一整天都跟他在一起.

 

amatory

/ ˈæmətərɪ; US -tɔːrɪ; ˋæməˏtɔrɪ/ adj (fml or joc 文或谑) relating to or inspired by sexual love 性爱的; 爱情的; 色情的: amatory literature, adventures 艳情文学﹑ 艳遇.

【amat = to love爱 –ory a.= related to 与…有关的—> related to loving; expressing love恋爱的, 爱慕的 / an amatory poem