python toHex function

摘要: hex = lambda s: ''.join(map(lambda c: "%02X" % ord(c), s)) 这是一个lambda的嵌套,我们可以分解成以下代码,就比较好理解了:def char2Hex(c): return '%02X' % ord(c)def toHexList(s): return map(char2Hex, s)def toHex(s): return ''.join(toHexList(s)) 阅读全文
posted @ 2012-09-13 13:40 盐味 阅读(313) 评论(0) 推荐(0) 编辑

Ubuntu下VirtualBox使用usb

摘要: 安装VirtualBox扩展包后sudo adduser username vboxusersusername为当前Ubuntu用户名 阅读全文
posted @ 2012-09-12 10:55 盐味 阅读(141) 评论(0) 推荐(0) 编辑

Sencha Touch 本地化存储配置

摘要: Sencha Touch localstorage 阅读全文
posted @ 2012-06-29 00:12 盐味 阅读(410) 评论(0) 推荐(0) 编辑

用Erlang写一个抓写真图片的程序

摘要: Erlang 阅读全文
posted @ 2012-06-17 21:35 盐味 阅读(902) 评论(0) 推荐(0) 编辑

QML 怎么在gridview中用Index定位? 怎么在代理中设置背景?

摘要: import QtQuick 1.0Item { id: me width: 100 height: 300 GridView { id: grid anchors.fill: parent model: 60 cellHeight: 20 cellWidth: 20 property int colcount: Math.floor(width / cellWidth) delegate: Rectangle { width: grid.cellWi... 阅读全文
posted @ 2012-03-26 13:47 盐味 阅读(1276) 评论(0) 推荐(0) 编辑

QML跑马灯

摘要: 两个文件, 一个是控件文件, 一个是测试文件控件文件 RunHorseText.qmlimport QtQuick 1.0Item { id: me width: 100; height: 50 property string text: "" property int spacing: 30 property int duration: 5000 property int interval: 2000 clip: true QtObject { id: my property bool needAnimation: ... 阅读全文
posted @ 2012-03-22 19:24 盐味 阅读(929) 评论(0) 推荐(0) 编辑

QML JSON 展示

摘要: 1 import QtQuick 1.0 2 3 Rectangle { 4 width: 600 5 height: 400 6 7 Rectangle { 8 id: topInput 9 height: 20; width: parent.width;10 anchors.top: parent.top;z:2;11 12 Rectangle {13 id: jsonTxt14 border.color: "black"; border.width: 115 width: parent.width - 50; height: 20;16 17 TextInput {1 阅读全文
posted @ 2011-05-06 12:22 盐味 阅读(1109) 评论(0) 推荐(0) 编辑

windows phone7 下 Silverlight 异步读取网络图片

摘要: 项目有这样的需求,要求窗口加载一揽子图片,为了不让UI阻塞太久,采用异步读取后绑定显示的方案.图片的下载应该采用并发的过程(等待网络响应会很耗时,一张一张的下载,等待时间太长)图片的下载不能占用过多的线程数,应有个阀值(图片不是核心业务,不能占用那么多资源)在图片加载的过程中,如果用户有操作,比如窗口跳转,则未加载完成的图片加载的过程应取消(为了替用户节省流量).需求就是这么多了,如何实现呢?思路是这样的,由于需要异步,且需要等待,首先想到使用队列,先让队列排列起来,再定量迭代读取.因为要涉及异步的取消,想到了用WebClient对象的异步功能, 当然,所以发起异步请求之后的对象我都需要记录, 阅读全文
posted @ 2011-04-08 17:11 盐味 阅读(1172) 评论(3) 推荐(2) 编辑

LCD1602显示接收的串口通讯字串

摘要: #include typedef unsigned int uint; typedef unsigned char uchar; void delay(uint z){ uint x,y; for(x=z;x>0;--x) for(y=110;y>0;--y); } uchar posit = 0x00; sbit lcd_en_port=P3^4; sbit lcd_rs... 阅读全文
posted @ 2011-01-03 23:41 盐味 阅读(967) 评论(0) 推荐(0) 编辑

89C52定时/计数器

摘要: 中断允许寄存器IE中断允许寄存器用来设定各个中断源的打开和关闭,IE在特殊功能寄存器中,字节地址为A8H,位地址(由低位到高位)分别是A8H-AFH,该寄存器可进行位寻址,即可对该寄存器的每一位进行单独操作。单片机复位时IE全部被清0,各位定义如下。EA-全局中断允许位。EA=1,打开全局中断控制,在此条件下,由各个中断控制位确定相应中断的打开或关闭。EA=0,关闭全部中断。ET2-定时器/计数器2中断允许位。ET2=1,打开T2中断。ET2=0,关闭T2中断。ES-串行口中断允许位。ES=1,打开串行口中断。ES=0,关闭串行口中断。ET1-定时器/计数器1中断允许位。ET1=1,打开T1中 阅读全文
posted @ 2011-01-03 22:51 盐味 阅读(2170) 评论(0) 推荐(0) 编辑