2015年9月20日 星期日
窗簾:安利家飾布。HunterDouglas
http://blog.xuite.net/tiffany610/tiffany610/70649027-%E5%AE%89%E5%88%A9%E5%AE%B6%E9%A3%BE%E5%B8%83%E3%80%82HunterDouglas
2015年9月19日 星期六
2015年9月18日 星期五
2010年10月9日 星期六
怕麻煩的背後有金礦
昨晚到了誠品~看到這本書, 最近蠻常做的事情就是思考怎麼讓自己做事情更有效率~更加善用自己的時間~也更加善用自己的空間(房間被我塞滿了一堆用不到的雜物= =)
怕麻煩~所以要做一些麻煩的小事情來解決大麻煩~
其中說到要設定目標, 還要列出來不想做的事情~所以我也來設定一下目標以及不想做的事情吧!!
目標:
*). 利用思考, 把事物簡單化, 模式化
*). 把永遠不會用到的東西丟掉
*). 把重要的收據單據,醫療收據, 保險收據,這些可以報稅的單據 以年分區分後全部丟在一起吧!!
*). 上班的時候認真工作, 努力學習, 上班時間不要再看 facebook
*). 每天花一小時的時間, 思考做哪些東西, 可以對公司或者團隊有益處, 而且這些東西是在自己工作責任範圍之外~!
*). 每周要讀 5~7 單位的書 (一單位大約是讀一小時得書, 因為有些書可能兩小時能看完, 有些書可能五小時看完, 有些書可能要花上 50~100小時)
*). 每天花半小時到一小時的時間念英文
*). 不要睡回籠覺, 把早起的時間拿來念書!
不想做的事情:
1.重複作枯燥的工作(如果有這種工作, 就想辦法讓他自動化或者模式化!!)
怕麻煩~所以要做一些麻煩的小事情來解決大麻煩~
其中說到要設定目標, 還要列出來不想做的事情~所以我也來設定一下目標以及不想做的事情吧!!
目標:
*). 利用思考, 把事物簡單化, 模式化
*). 把永遠不會用到的東西丟掉
*). 把重要的收據單據,醫療收據, 保險收據,這些可以報稅的單據 以年分區分後全部丟在一起吧!!
*). 上班的時候認真工作, 努力學習, 上班時間不要再看 facebook
*). 每天花一小時的時間, 思考做哪些東西, 可以對公司或者團隊有益處, 而且這些東西是在自己工作責任範圍之外~!
*). 每周要讀 5~7 單位的書 (一單位大約是讀一小時得書, 因為有些書可能兩小時能看完, 有些書可能五小時看完, 有些書可能要花上 50~100小時)
*). 每天花半小時到一小時的時間念英文
*). 不要睡回籠覺, 把早起的時間拿來念書!
不想做的事情:
1.重複作枯燥的工作(如果有這種工作, 就想辦法讓他自動化或者模式化!!)
2008年10月24日 星期五
timer_create
http://www.lslnet.com/linux/f/docs1/i38/big5278308.htm
每天 23:30 調用應用程序
每間隔1000小時執行一次應用程序
[code]
#Makefile
CC = cc
COPS = -g -D_DEBUG
RTLIB = -lrt
all: mytimer
mytimer: mytimer.c
$(CC) $(COPS) -o mytimer mytimer.c $(RTLIB)
clean:
rm -f core *.o mytimer
[/code]
[code]
/* mytimer.c
*
* Usage: mytimer time interval
* Example: mytimer 23:30:00 1000
*
*/
#include
#include
#include
#include
#include
#include
#include
#define SIGNUM SIGALRM
#define SIGINFO1 1
#define SIGINFO2 2
#define DAYINTERVAL 24*60*60
#define BILLION 1000000000L
#define TIMER_MSG1 "Program 1\t"
#define TIMER_MSG2 "Program 2\t"
static void handler(int signo, siginfo_t *info, void *context) {
int errsave;
errsave = errno;
switch (info->si_value.sival_int) {
case SIGINFO1:
write(STDOUT_FILENO, TIMER_MSG1, sizeof(TIMER_MSG1) - 1);
system("/usr/bin/date +%X");
break;
case SIGINFO2:
write(STDOUT_FILENO, TIMER_MSG2, sizeof(TIMER_MSG2) - 1);
system("/usr/bin/date +%X");
break;
default:
break;
}
errno = errsave;
}
static int setsighandler(void) {
struct sigaction act;
act.sa_flags = SA_SIGINFO;
act.sa_sigaction = handler;
if ((sigemptyset(&act.sa_mask) == -1) ||
(sigaction(SIGNUM, &act, NULL) == -1))
return -1;
return 0;
}
static int settime(long val, long interval, int evt) {
timer_t timerid;
struct itimerspec value;
struct sigevent evp;
evp.sigev_notify = SIGEV_SIGNAL;
evp.sigev_signo = SIGNUM;
switch (evt) {
case SIGINFO1:
evp.sigev_value.sival_int = SIGINFO1;
break;
case SIGINFO2:
evp.sigev_value.sival_int = SIGINFO2;
break;
default:
return -1;
}
if (timer_create(CLOCK_REALTIME, &evp, &timerid) == -1) {
perror("Failed to create a timer");
return -1;
}
value.it_interval.tv_sec = (long)interval;
value.it_interval.tv_nsec = (interval - value.it_interval.tv_sec)*BILLION;
if (value.it_interval.tv_nsec >= BILLION) {
value.it_interval.tv_sec++;
value.it_interval.tv_nsec -= BILLION;
}
value.it_value.tv_sec = (long)val;
value.it_value.tv_nsec = (val - value.it_value.tv_sec)*BILLION;
if (value.it_value.tv_nsec >= BILLION) {
value.it_value.tv_sec++;
value.it_value.tv_nsec -= BILLION;
}
return timer_settime(timerid, 0, &value, NULL);
}
int string2time(const char *str, struct tm **time) {
const char *delimiters = ": \t";
char *buf;
char *bufp;
buf = (char *) malloc(strlen(str) + 1);
strcpy(buf, str);
*time = (struct tm *) malloc(sizeof(struct tm));
if ((bufp = strtok(buf, delimiters)) != NULL) {
(*time)->tm_hour = atoi(bufp);
if ((bufp = strtok(NULL, delimiters)) != NULL) {
(*time)->tm_min = atoi(bufp);
if ((bufp = strtok(NULL, delimiters)) != NULL)
(*time)->tm_sec = atoi(bufp);
else
(*time)->tm_sec = 0;
} else {
fprintf(stderr, "Time value(%s) is invalid\n", str);
free(buf);
return -1;
}
} else {
fprintf(stderr, "Time value(%s) is invalid\n", str);
free(buf);
return -1;
}
free(buf);
return 0;
}
void freetimepointer(struct tm **time) {
if (time == NULL)
return;
if (*time != NULL)
free(*time);
free(time);
}
int runtime(char *timep) {
time_t current;
time_t end;
struct tm *tcurrent;
struct tm *tend;
if (setsighandler() == -1) {
perror("Failed to setup signal handler");
return -1;
}
string2time(timep, &tend);
end = tend->tm_hour*60*60 + tend->tm_min*60 + tend->tm_sec;
current = time(NULL);
tcurrent = localtime(¤t);
current = tcurrent->tm_hour*60*60 + tcurrent->tm_min*60 + tcurrent->tm_sec;
if (current > end)
end += 24*60*60 - end;
else
end -= current;
#ifdef _DEBUG
if (settime(end, 2, SIGINFO1) == -1)
return -1;
#else
if (settime(end, DAYINTERVAL, SIGINFO1)== -1)
return -1;
#endif
freetimepointer(&tend);
return 0;
}
int runinterval(int interval) {
time_t secs;
if((secs = interval*60*60) <= 0) {
fprintf(stderr, "Time value(%d) is invalid\n", interval);
return -1;
}
if (setsighandler() == -1) {
perror("Failed to setup signal handler");
return -1;
}
#ifdef _DEBUG
secs = 6;
#endif
if (settime(1, secs, SIGINFO2) == -1)
return -1;
return 0;
}
int main(int argc, char **argv)
{
if (argc != 3) {
printf("Usage: %s time interval\n", argv[0]);
printf("Example: %s 23:30:00 1000\n", argv[0]);
return 1;
}
if (runtime(argv[1]) == -1)
return 1;
if (runinterval(atoi(argv[2])) == -1)
return 1;
for ( ; ; )
pause();
return 0;
}
[/code]
每天 23:30 調用應用程序
每間隔1000小時執行一次應用程序
[code]
#Makefile
CC = cc
COPS = -g -D_DEBUG
RTLIB = -lrt
all: mytimer
mytimer: mytimer.c
$(CC) $(COPS) -o mytimer mytimer.c $(RTLIB)
clean:
rm -f core *.o mytimer
[/code]
[code]
/* mytimer.c
*
* Usage: mytimer time interval
* Example: mytimer 23:30:00 1000
*
*/
#include
#include
#include
#include
#include
#include
#include
#define SIGNUM SIGALRM
#define SIGINFO1 1
#define SIGINFO2 2
#define DAYINTERVAL 24*60*60
#define BILLION 1000000000L
#define TIMER_MSG1 "Program 1\t"
#define TIMER_MSG2 "Program 2\t"
static void handler(int signo, siginfo_t *info, void *context) {
int errsave;
errsave = errno;
switch (info->si_value.sival_int) {
case SIGINFO1:
write(STDOUT_FILENO, TIMER_MSG1, sizeof(TIMER_MSG1) - 1);
system("/usr/bin/date +%X");
break;
case SIGINFO2:
write(STDOUT_FILENO, TIMER_MSG2, sizeof(TIMER_MSG2) - 1);
system("/usr/bin/date +%X");
break;
default:
break;
}
errno = errsave;
}
static int setsighandler(void) {
struct sigaction act;
act.sa_flags = SA_SIGINFO;
act.sa_sigaction = handler;
if ((sigemptyset(&act.sa_mask) == -1) ||
(sigaction(SIGNUM, &act, NULL) == -1))
return -1;
return 0;
}
static int settime(long val, long interval, int evt) {
timer_t timerid;
struct itimerspec value;
struct sigevent evp;
evp.sigev_notify = SIGEV_SIGNAL;
evp.sigev_signo = SIGNUM;
switch (evt) {
case SIGINFO1:
evp.sigev_value.sival_int = SIGINFO1;
break;
case SIGINFO2:
evp.sigev_value.sival_int = SIGINFO2;
break;
default:
return -1;
}
if (timer_create(CLOCK_REALTIME, &evp, &timerid) == -1) {
perror("Failed to create a timer");
return -1;
}
value.it_interval.tv_sec = (long)interval;
value.it_interval.tv_nsec = (interval - value.it_interval.tv_sec)*BILLION;
if (value.it_interval.tv_nsec >= BILLION) {
value.it_interval.tv_sec++;
value.it_interval.tv_nsec -= BILLION;
}
value.it_value.tv_sec = (long)val;
value.it_value.tv_nsec = (val - value.it_value.tv_sec)*BILLION;
if (value.it_value.tv_nsec >= BILLION) {
value.it_value.tv_sec++;
value.it_value.tv_nsec -= BILLION;
}
return timer_settime(timerid, 0, &value, NULL);
}
int string2time(const char *str, struct tm **time) {
const char *delimiters = ": \t";
char *buf;
char *bufp;
buf = (char *) malloc(strlen(str) + 1);
strcpy(buf, str);
*time = (struct tm *) malloc(sizeof(struct tm));
if ((bufp = strtok(buf, delimiters)) != NULL) {
(*time)->tm_hour = atoi(bufp);
if ((bufp = strtok(NULL, delimiters)) != NULL) {
(*time)->tm_min = atoi(bufp);
if ((bufp = strtok(NULL, delimiters)) != NULL)
(*time)->tm_sec = atoi(bufp);
else
(*time)->tm_sec = 0;
} else {
fprintf(stderr, "Time value(%s) is invalid\n", str);
free(buf);
return -1;
}
} else {
fprintf(stderr, "Time value(%s) is invalid\n", str);
free(buf);
return -1;
}
free(buf);
return 0;
}
void freetimepointer(struct tm **time) {
if (time == NULL)
return;
if (*time != NULL)
free(*time);
free(time);
}
int runtime(char *timep) {
time_t current;
time_t end;
struct tm *tcurrent;
struct tm *tend;
if (setsighandler() == -1) {
perror("Failed to setup signal handler");
return -1;
}
string2time(timep, &tend);
end = tend->tm_hour*60*60 + tend->tm_min*60 + tend->tm_sec;
current = time(NULL);
tcurrent = localtime(¤t);
current = tcurrent->tm_hour*60*60 + tcurrent->tm_min*60 + tcurrent->tm_sec;
if (current > end)
end += 24*60*60 - end;
else
end -= current;
#ifdef _DEBUG
if (settime(end, 2, SIGINFO1) == -1)
return -1;
#else
if (settime(end, DAYINTERVAL, SIGINFO1)== -1)
return -1;
#endif
freetimepointer(&tend);
return 0;
}
int runinterval(int interval) {
time_t secs;
if((secs = interval*60*60) <= 0) {
fprintf(stderr, "Time value(%d) is invalid\n", interval);
return -1;
}
if (setsighandler() == -1) {
perror("Failed to setup signal handler");
return -1;
}
#ifdef _DEBUG
secs = 6;
#endif
if (settime(1, secs, SIGINFO2) == -1)
return -1;
return 0;
}
int main(int argc, char **argv)
{
if (argc != 3) {
printf("Usage: %s time interval\n", argv[0]);
printf("Example: %s 23:30:00 1000\n", argv[0]);
return 1;
}
if (runtime(argv[1]) == -1)
return 1;
if (runinterval(atoi(argv[2])) == -1)
return 1;
for ( ; ; )
pause();
return 0;
}
[/code]
2008年10月18日 星期六
for loop in bash script
for loop in bash script
for var in 1111 222 3333 444
do
echo ${var}
done
Result
linux@linux-desktop:~$ ./test.sh
1111
222
3333
444
linux@linux-desktop:~$
for var in 1111 222 3333 444
do
echo ${var}
done
Result
linux@linux-desktop:~$ ./test.sh
1111
222
3333
444
linux@linux-desktop:~$
訂閱:
文章 (Atom)
孩子 3C 使用條款
昨天看到有人說別讓孩子用 youtube,因為上面的確是有一些不太合適的內容。 其實我們家都是把 youtube 投影到電視上面跟孩子一起看,但比較大的孩子可能需要在房間裡面準備一台電腦。 我自己寧可開放孩子使用電腦也不想讓他迷上手機。平板是我可以接受的最低限度,但也僅限於在外...
-
去水易購買了複磷酸鹽濾芯要加在熱水器前面除水垢,剛好小伍淨水來了看到,於是就隨口跟她解釋了我要安裝複磷酸鹽來保養一下熱水器與熱水管線。 他就說磷酸鹽有分很多等級,食品用的等級很貴,洗澡時被皮膚吸收進人體不太好,建議我不要使用。 其實我很懷疑他的說法,不過當下就是喔?那我就不要...
-
先說結論:清殘膠還是用酒精最有用阿!! 這次要把當初買車裝上去的車美仕換裝成 70邁 pro。 關於行車紀錄器這種東西,因為每年進步的速度實在太快,我是覺得花便宜的錢買當下影片品質可以接受的機種就好了。今年砸一兩萬買下來的高階機種,過個兩三年後,可能只要一兩千塊...
-
昨天看到有人說別讓孩子用 youtube,因為上面的確是有一些不太合適的內容。 其實我們家都是把 youtube 投影到電視上面跟孩子一起看,但比較大的孩子可能需要在房間裡面準備一台電腦。 我自己寧可開放孩子使用電腦也不想讓他迷上手機。平板是我可以接受的最低限度,但也僅限於在外...