urllib模拟登录

今天用一个urllib2、cookielib来模拟登陆,并希望能维持会话,及认证后的cookie可以保存下来,后续请求直接使用这个cookie,用cookielib折腾了好久,坑爹的是cookie可以保存,但是一直不能在请求中带上。 最后的解决办法。。不用cookielib,自己写个文件保存cookie,下次请求时自己读文件、自己发header。。。。 ...

March 30, 2012 · notsobad

web培训

培训的简单提纲 Bootstrap Grid 网格,标准布局:940px,分为16个格, 用于实现多列布局 layout 布局 Typography 标题、列表、code、pre、label等元素的样式 Tables 各种表格样式 Forms 表单 Navigation 导航栏、tabs、面包屑导航、分页 alert & errors 告警、提示信息 Popovers 弹出层提示 Tooltips 对title的提示优化 underscore 借鉴了一些函数式变成的思想,_.each, _.map, _.reduce, ...

March 23, 2012 · notsobad

Create a chrome extension

google chrome screen capture的网页截图思路 pages.js加入content_scripts,各个tab都可以调用,background.html是入口。 background.html调用标准的tabs.captureVisiableTab来绘制可见区域,在回调函数中,将图片写入canvas,同时向该tab发送scroll_next消息,该消息由pages.js处理,网页滚动一屏,翻页完成后,重新调用tabs.captureVisiableTab来,图片追加写入canvas。 ...

March 19, 2012 · notsobad

开始用gentoo

Gentoo常用的命令 #同步portage eix-sync / emerge --sync #安装某个软件包,自动处理依赖关系 emerge -av package #安装某个软件包,忽略任何依赖关系 emerge -Ov1 package #更新整个系统,自动处理所有的依赖关系 emerge -auvDN world #处理系统更新后由于某个动态库更新导致需要更新的软件 revdep-rebuild #处理python升级后部分python包的更新 python-updater #字体优化 emerge -av layman layman -L layman -f -a lcd-filtering 参考: http://blog.xtao.me/2011/11/gentoo%E5%AD%97%E4%BD%93%E4%BC%98%E5%8C%96/ http://gitorious.org/lcd-filtering/pages/Install ...

March 19, 2012 · notsobad

SICP python version

今天在hn上看到个资料,用python来讲SICP。 引述里面的一句话: The fundamental equation of computers is: computer = powerful + stupid Computers are very powerful, looking at volumes of data very quickly. Computers can perform billions of operations per second, where each operation is pretty simple. Computers are also shockingly stupid and fragile. The operations that they can do are extremely rigid, simple, and mechanical. The computer lacks anything like real insight .. it’s nothing like the HAL 9000 from the movies. If nothing else, you should not be intimidated by the computer as if it’s some sort of brain. It’s very mechanical underneath it all. Programming is about a person using their real insight to build something useful, constructed out of these teeny, simple little operations that the computer can do. ...

March 18, 2012 · notsobad

给console.log创建别名的正确方法

以前我在js里写log,一般是对console.log做个简单封装 var log = (window.console && console.log) || function(){}; 但是今天发现log('a')这样的语句会报错 >log=console.log function log() { [native code] } >log('a') TypeError: Illegal invocation 查了下,这篇文章讲的很详细,大意就是this作用域的问题,相对这些方法做别名的话,要用到apply、call等方法。 所以log函数应该这么写: var log=function(){ window.console && console.log && console.log.apply(console, arguments) } 有点疑问,为什么以前第一种写法没有报错呢? ...

March 16, 2012 · notsobad

IOS开发学习笔记

这里记下我学习ios开发的笔记,备忘用,不建议参考。 main.m是入口 @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([HelloWorldAppDelegate class])); } app delegate的作用是提供window对象供主程序用,同时还可以在应用程序初始化前做一些准备工作。 ios中window对象是可见元素的容器,帮界面元素传递事件,帮app响应设备方向变化,window本身是不可见的。 ...

March 14, 2012 · notsobad

开始使用Octopress

octopress号称是: A blogging framework for hackers. 最近对wordpress比较烦了,就尝试下它,在github上找了个简单的工具,可以把wordpress的导出文章专程markdown,效果勉强可以吧,转了之后,我又用脚本处理了下,就是现在这个样子。 基本上参考http://octopress.org/上的说明装就可以了,只是mac lion下安装ruby是报错,如下就可以了。 ...

March 10, 2012 · notsobad

在家

放假在家,无网,暖气,无聊。 工作时想休息,休息时想工作。 最好的是想休息的时候就能休息,工作的时候随时就能工作。 离开家的时候感觉时间凝固在那个点上了,等回到家似乎又接到你离开时候那个点,生活又开始继续。 家里人似乎没什么变化,除了小孩长大了,有的人老去了。 ...

January 21, 2012 · notsobad

mongodb执行js的参数传递

在mongodb的js文件中,我想往test.js中传递参数,似乎没有好的办法,只能用下面这种方法模拟一下。 在test.js文件中可以这么写: if(typeof id == 'undefined'){ print('You need to pass id'); quit(2); } do_stuff(id); 运行脚本 mongo --eval="var id=1234;" test.js mongodb中关于js相关的文档太少了,可以直接看spidemonkey的文档

January 10, 2012 · notsobad