2013年12月14日
摘要: 1 # /bin/bash 2 3 echo -n login: 4 read name 5 echo -n password: 6 read passwd 7 8 if [ $name = "chat" -a $passwd = "abc" ]; then 9 echo "the host and passwdrd is right!"10 else11 echo "input is error!"12 fi13 14 #end注意:if语句的格式: if [space judge_condition space 阅读全文
posted @ 2013-12-14 13:51 笔记吧... 可能只有自己看得懂 阅读(196) 评论(0) 推荐(0) 编辑
  2013年12月9日
摘要: 1 package main 2 3 import "fmt" 4 //import OS "os" 5 //import "strings" 6 //import "path/filepath" 7 8 type Stack []interface{} 9 10 func (s *Stack)f() {11 stack := *s12 13 fmt.Printf("%p %d %d\n", &s, len(stack), cap(stack))14 15 *s = stack[:len 阅读全文
posted @ 2013-12-09 11:16 笔记吧... 可能只有自己看得懂 阅读(742) 评论(0) 推荐(0) 编辑
  2013年11月19日
摘要: http://bbs.mygolang.com/thread-406-1-1.html 阅读全文
posted @ 2013-11-19 15:14 笔记吧... 可能只有自己看得懂 阅读(223) 评论(0) 推荐(0) 编辑
  2013年11月15日
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main() { 7 ifstream ifs("tuan.sql", ifstream::in); 8 ofstream ofs("trv.txt", ofstream::out); 9 string s,value;10 char c1;11 int start_pos=0,end_pos=0;12 while(!ifs.eof() && !ifs.fail()) {13 ifs >> s;14 阅读全文
posted @ 2013-11-15 15:21 笔记吧... 可能只有自己看得懂 阅读(388) 评论(0) 推荐(0) 编辑
  2013年11月1日
摘要: 1 require "luasql.mysql" 2 3 --创建环境对象 4 env = luasql.mysql() 5 6 --连接数据库 7 conn = env:connect("数据库名","用户名","密码","IP地址",端口) 8 9 --设置数据库的编码格式10 conn:execute"SET NAMES GB2312"11 12 --执行数据库操作13 cur = conn:execute("select * from role") 阅读全文
posted @ 2013-11-01 22:43 笔记吧... 可能只有自己看得懂 阅读(7566) 评论(1) 推荐(0) 编辑
  2013年10月14日
摘要: redis设计一款sds对象【字符串对象】优点:可跨平台的内存处理zmalloc;内存消耗的线性增长优势;每次加SDS_MAX_PREALLOC(1MB)的空间; 重写了各种字符串操作的函数;写跨平台的字符串处理库时,可以参考。 阅读全文
posted @ 2013-10-14 14:29 笔记吧... 可能只有自己看得懂 阅读(151) 评论(0) 推荐(0) 编辑
摘要: rdb.h rdb.c ---> 完成数据保存到临时文件,再利用rename保存到指定文件的过程;如果需要写一个数据持久化保存的功能时,可以参考这部分代码; 1 //rdb API 2 int rdbSaveType(rio *rdb, unsigned char type); 3 int rdbLoadType(rio *rdb); 4 int rdbSaveTime(rio *rdb, time_t t); 5 time_t rdbLoadTime(rio *rdb); 6 int rdbSaveLen(rio *rdb, uint32_t len); 7 uint32_t rdbL 阅读全文
posted @ 2013-10-14 10:22 笔记吧... 可能只有自己看得懂 阅读(287) 评论(0) 推荐(0) 编辑
  2013年10月11日
摘要: 1 //adlist.h 2 #ifndef __ADLIST__H__ 3 #define __ADLIST__H__ 4 5 typedef struct listNode_ { 6 struct listNode_ *prev; 7 struct listNode_ *next; 8 void *value; 9 } listNode;10 11 typedef struct listIter_ {12 listNode *next;13 int direction;14 }listIter;15 16 typedef struct List_ {17 ... 阅读全文
posted @ 2013-10-11 21:47 笔记吧... 可能只有自己看得懂 阅读(621) 评论(0) 推荐(0) 编辑
  2013年10月10日
摘要: 1 #include 2 #include 3 4 void cleanup(void *arg) { 5 6 printf("cleanup: %s\n", (char*)arg); 7 } 8 9 void* thr_fn1(void *arg) {10 11 printf("thread1 start\n");12 pthread_cleanup_push(cleanup, (void*)"thread 1 first handler");13 pthread_cleanup_push(cleanup, (void*)" 阅读全文
posted @ 2013-10-10 14:16 笔记吧... 可能只有自己看得懂 阅读(197) 评论(0) 推荐(0) 编辑
  2013年10月9日
摘要: 线程标识#includeint pthread_equal( //用于比较两个线程是否相等pthread_t tid1, //线程id=tid1pthread_t tid2);//线程id=tid2pthread_t pthread_self(void); //用于返回自身的线程id线程创建#includeint pthread_create( //用于创建线程pthread_t *restrict tidp,//线程idconst pthread_attr_t *restrict attr,//属性void *(*start_rin)(void*),//线程开始函数void *restric 阅读全文
posted @ 2013-10-09 22:29 笔记吧... 可能只有自己看得懂 阅读(251) 评论(0) 推荐(0) 编辑