This file contains hidden or 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
| ## 后台启动进程,如果已经在运行则退出 | |
| # $1 ,command | |
| # $2 ,lock file | |
| start_daemon(){ | |
| [ $# -lt 2 ] && return 2 | |
| local CMD=$1; local LOCK_FILE=$2 | |
| [ -s "$LOCK_FILE" ] && { PID=`cat $LOCK_FILE` ;ps axo pid,cmd | egrep $PID | egrep -q $0 && { | |
| echo Runing...,PID:$PID ;return 1;} || { echo Stoped,remove lock file :$LOCK_FILE ;} | |
| } | |
| { eval $CMD ; /bin/rm -f $LOCK_FILE ;} & |
This file contains hidden or 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
| M[16],X=16,W,k;main(){T(system("stty cbreak") | |
| );puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i | |
| ,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M | |
| [w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<< | |
| (l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k) | |
| ]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d | |
| -1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X] | |
| *i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4; | |
| )s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4|| | |
| puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2 |
This file contains hidden or 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
| from pprint import pprint | |
| class Node: | |
| def __init__(self, key, value): | |
| self.key = key | |
| self.value = value | |
| self.prev = None | |
| self.next = None | |
| def __str__(self): |