2014年7月28日

以Append方式打开文件,设置偏移量无效

摘要: 1 #include 2 3 int main() 4 { 5 FILE * fd = fopen("btoo1.c", "ab+"); 6 fpos_t p ; 7 int fp = fgetpos(fd, &p); 8 printf("bef seek: f... 阅读全文

posted @ 2014-07-28 14:42 JohnChain 阅读(621) 评论(0) 推荐(0) 编辑

2014年7月22日

linux 下查看二进制文件

摘要: 查看二进制有以下几种方法:方法一:hexdumpapt-get install libdata-hexdumper-perl安装好之后就可以直接hexdump your_binary_file也可以直接使用hd命令来代替hexdump如果想要慢慢看 : hd your_binary_file | m... 阅读全文

posted @ 2014-07-22 16:45 JohnChain 阅读(1361) 评论(0) 推荐(0) 编辑

函数指针数组

摘要: picked from:http://blog.sina.com.cn/s/blog_71e266c20100lw0q.html函数指针数组的定义方法,有两种:一种是标准的方法;一种是蒙骗法。第一种,标准方法:分析:函数指针数组是一个其元素是函数指针的数组。那么也就是说,此数据结构是是一个数组,且其... 阅读全文

posted @ 2014-07-22 12:00 JohnChain 阅读(1143) 评论(0) 推荐(0) 编辑

2013年12月2日

无法搜到个例网络

摘要: 问题背景: 1.电脑A无法搜到路由器B,但可以搜到其他网络;其他电脑可以搜到路由器B; 2.路由器已开启无线,并且未隐藏网络; 3. 硬件背景:路由器为TP-Link,操作系统为 Ubuntu 12.04结局方案: 查找了一些资料后,有些网卡是无法识别信道12和13,就本次问题,路由器在信道设置项,设为:自动,查看运行状态:信道为13,网上有人说路由器默认的信道为6,不同路由器的默认值还是有差异的,无统一标准。如果无法确定默认信道值,建议将信道一项设为默认值1—11。 当然 也是可以这一特性,认为将信道设为12或13,来屏蔽一些网卡的连接,这样的话,即使手动添加隐藏网... 阅读全文

posted @ 2013-12-02 15:59 JohnChain 阅读(194) 评论(0) 推荐(0) 编辑

2013年11月27日

Win 7中开启Telnet功能

摘要: 参看以下文章:http://winsystem.ctocio.com.cn/Longhorn/472/8756972.shtml 阅读全文

posted @ 2013-11-27 15:58 JohnChain 阅读(168) 评论(0) 推荐(0) 编辑

2013年11月19日

多线程共享一个队列

摘要: 1 # -*- coding:utf-8 -*- 2 import threading 3 from time import sleep 4 lock = threading.Lock() 5 tmp_list = [] 6 class MyThread(threading.Thread): 7 """ 8 此线程用于向公共队列中追加元素 9 """10 def __init__(self):11 threading.Thread.__init__(self) 12 #: 向公共队列追加元素13 def run(self):14... 阅读全文

posted @ 2013-11-19 11:10 JohnChain 阅读(1272) 评论(0) 推荐(0) 编辑

2013年11月14日

修改MySQL默认字符集

摘要: 今天发现有库级字符集和表级字符集,实验了下发现,库级字符集是该库内表的默认字符集,当创建表时,如果未指定字符集,默认使用该表所属库的字符集。表也可使用不同于所属库的字符集。 MySQL对于字符集的指定可以细化到一个数据库,一张表,一列,应该用什么字符集。 但是,传统的程序在创建数据库和数据表时并... 阅读全文

posted @ 2013-11-14 09:31 JohnChain 阅读(487) 评论(0) 推荐(0) 编辑

2013年11月12日

关闭主线程时如何合理关闭子线程

摘要: picked from :http://blog.sina.com.cn/s/blog_3c8ced5801014pbv.html昨天为我的casnet程序添加新功能。其中一个功能是断线自动重连,本来是单线程的程序,添加这个功能就需要后台有一个线程定时地查询当前状态,如果掉线就自动重连。因之遇到了一个如何设计这个守护线程的问题。我刚开始的想法是后台线程每次运行查询后 sleep 一段时间,然后再运行查询。但是我马上遇到了一个问题:当主程序退出时,后台线程仍在运行,主窗口无法退出。在使用其它的库时,比如 POSIX 的 pthread,可以使用 ptread_cancel(tid) 在主线程中结 阅读全文

posted @ 2013-11-12 17:02 JohnChain 阅读(3064) 评论(0) 推荐(0) 编辑

2013年11月10日

解决Python 插查 MySQL 时中文乱码问题

摘要: 首先找到这里的解决方法,count = cursor.fetchall()for i in count: idc_a = i[0] if isinstance(idc_a, unicode): idc_a = idc_a.encode('utf-8') print idc_a但只能解决查询显示乱码问题后来继续查资料,找到了这里,解决方法很简单拿,和数据库建立连接后,执行:db.set_character_set('utf8')dbc.execute('SET NAMES utf8;')dbc.execute('SET CHARACTER 阅读全文

posted @ 2013-11-10 18:35 JohnChain 阅读(436) 评论(0) 推荐(0) 编辑

2013年10月23日

mysql alter

摘要: //主键 alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);//增加一个新列 alter table t2 add d timestamp;alter table infos add ex tinyint not null default '0';//删除列 alter table t2 drop column c;//重命名列 alter table t1 change a b inte 阅读全文

posted @ 2013-10-23 11:10 JohnChain 阅读(287) 评论(0) 推荐(0) 编辑

导航