Eclipse + PyDev + 中文语言包

1.到 http://www.oracle.com/technetwork/java/javase/downloads/index.html 下载 java jre 并安装,对了 32位的java只能运行32位的Eclipse ,64位的也只能运行64位的。

2.到 http://www.eclipse.org/downloads/ 下载 Eclipse Standard ,解压并执行 Eclipse.exe

3.安装中文包,到http://www.eclipse.org/babel/downloads.php 找到当前版本的中文包地址,例如 http://download.eclipse.org/technology/babel/update-site/R0.11.0/kepler 然后更新中文包。

3.pydev 的源的地址是 http://pydev.org/updates 加到eclipse里面直接安装就可以了

No comment »

Arduino 下 Nokia 5110 LCD + DS18B20 多点测温

温度库:http://milesburton.com/Dallas_Temperature_Control_Library
5110库:https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library

资料上显示 DS18B20 可以使用 3-5v 电源供电,可以做到9-12位精度。不过12位精度比9位精度测温慢多了。而1820只能5V供电,9位精度。

 
/*********************************************************************
This is an example sketch for our Monochrome Nokia 5110 LCD Displays

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/products/338

These displays use SPI to communicate, 4 or 5 pins are required to
interface

Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada  for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/

#include 
#include 
#include "floatToString.h"

#include 
#include 

// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
// pin2 - DS18B20  需要4.7k欧上拉电阻
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);

#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2


#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH  16

static unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
  B00000001, B11000000,
  B00000001, B11000000,
  B00000011, B11100000,
  B11110011, B11100000,
  B11111110, B11111000,
  B01111110, B11111111,
  B00110011, B10011111,
  B00011111, B11111100,
  B00001101, B01110000,
  B00011011, B10100000,
  B00111111, B11100000,
  B00111111, B11110000,
  B01111100, B11110000,
  B01110000, B01110000,
  B00000000, B00110000 };





// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 12

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;




void setup()   {
  Serial.begin(9600);

  display.begin();
  // init done

  // you can change the contrast around to adapt the display
  // for the best viewing!
  display.setContrast(50);

  display.display(); // show splashscreen
  
  
  // Start up the library
  sensors.begin();

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");
    // set the resolution to 12 bit
  sensors.setResolution( TEMPERATURE_PRECISION);

  

  // draw a single pixel
  display.drawPixel(10, 10, BLACK);
  display.display();
  delay(2000);
  
  
}

//char buffer[25];// floatToString
//char s[25];// floatToString


void loop() {
  
    Serial.print("Requesting temperatures...");
  sensors.requestTemperatures();
  Serial.println("DONE");
  

  display.clearDisplay();   // clears the screen and buffer

//  float tempC = sensors.getTempCByIndex(0);
//  floatToString(buffer, tempC, 2);
//  Serial.println("Temp C: ");
//  Serial.print(tempC);
//sprintf(s,"c:%s",buffer);

  // text display tests
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(0,0);
  display.print("c0:");
  display.println(sensors.getTempCByIndex(0));
  display.print("c1:");
  display.println(sensors.getTempCByIndex(1));
  display.print("c2:");
  display.println(sensors.getTempCByIndex(2));
  display.display();
  delay(2000);



}

注意,需要使用arduino-1.52以上版本,arduino-1.05的会出现以下错误:

\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp: In constructor 'RobotControl::RobotControl()':
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'LCD_CS' was not declared in this scope
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'DC_LCD' was not declared in this scope
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'RST_LCD' was not declared in this scope
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp: In member function 'void RobotControl::begin()':
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXA' was not declared in this scope
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXB' was not declared in this scope
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXC' was not declared in this scope
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXD' was not declared in this scope
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:19: error: 'MUX_IN' was not declared in this scope
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:22: error: 'BUZZ' was not declared in this scope
\arduino-1.0.5-windows\arduino-1.0.5\libraries\Robot_Control\ArduinoRobot.cpp:25: error: 'Serial1' was not declared in this scope

No comment »

EverBox 网盘邀请链接

http://account.everbox.com/signup/GameXG

No comment »

chrome 书签误删恢复的办法

我刚刚悲剧的误删了书签的一个目录,本来只打算删除一个书签的,按了del键却发现整个目录都没有了…
不过找到了回复的办法,已经恢复了。先别关浏览器,在chrome的配置文件夹(Vista下,%UserProfile%\AppData\Local\Google\Chrome 、XP下,%UserProfile%\Local Settings\Application Data\Google\Chrome)里面找到 Bookmarks.bak ,把它和Bookmarks 都备份一份,关闭chrome浏览器,然后用Bookmarks.bak 替换掉Bookmarks,在打开就会发现书签已经恢复到了之前某个时间的版本了,我这里看Bookmarks.bak的日期应该是今天中午的版本。

最后强烈建议chrome增加类似于恢复标签页一样的临时恢复功能,最最重要的是删除多个书签的时候提示一下。

Comments (2) »

发 google+ 邀请

在下面留言,现在可以发出邀请。
要的尽快,昨天上午可以发邀请,但是下午又不可以了。但是昨天下午通过非官方分享信息的方式邀请的一个账号今天上午也可以登录了,虽然没有收到邀请信。

No comment »

Erlang http 客户端库 httpc 的例子

1 > inets:start().
ok
2> http:set_options([{cookies, enabled}]).
ok
3>{ok, {{NewVersion, 200, NewReasonPhrase}, NewHeaders, NewBody}} =
httpc:request(get, {“http://www.google.com”, [{“connection”, “close”}]},
[], []).

httpc:reset_cookies().
httpc:store_cookies([{“set-cookie”,”TESTID=set”}], URL). %% 注意这里 URL 的格式是 http://www.a.com/aaa ,httpc 将使用 www.a.com /aaa 。
httpc:which_cookies().

erlang 的 cookie 在重定向时会多发一次cookie 下面是一个例子:
第一次请求的时候没有问题:

GET / HTTP/1.1
te:
host: www.google.com
connection: close

HTTP/1.1 302 Found
Location: http://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http://www.google.com.hk/&ust=1305091134484018&usg=AFQjCNGVKwFoguLJsXcF2r-iSVP8pGVjAg
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Set-Cookie: PREF=ID=9837e8b8b27a4644:FF=0:NW=1:TM=1305091104:LM=1305091104:S=6c4IRHZYSSNbdUuu; expires=Fri, 10-May-2013 05:18:24 GMT; path=/; domain=.google.com
Date: Wed, 11 May 2011 05:18:24 GMT
Server: gws
Content-Length: 376
X-XSS-Protection: 1; mode=block
Connection: close


GET /url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http://www.google.com.hk/&ust=1305091134484018&usg=AFQjCNGVKwFoguLJsXcF2r-iSVP8pGVjAg HTTP/1.1
te:
host: www.google.com.hk
connection: close

HTTP/1.1 302 Found
Location: http://www.google.com.hk/
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Set-Cookie: PREF=ID=9e289483a992f2d3:FF=2:LD=zh-CN:NW=1:TM=1305091104:LM=1305091104:S=yZ76ERBlUrruTyf8; expires=Fri, 10-May-2013 05:18:24 GMT; path=/; domain=.google.com.hk
Date: Wed, 11 May 2011 05:18:24 GMT
Server: gws
Content-Length: 222
X-XSS-Protection: 1; mode=block
Connection: close


GET / HTTP/1.1
te:
host: www.google.com.hk
connection: close
cookie: $Version=0; PREF=ID=9e289483a992f2d3:FF=2:LD=zh-CN:NW=1:TM=1305091104:LM=1305091104:S=yZ76ERBlUrruTyf8; $Path=/; $Domain=.google.com.hk

HTTP/1.1 200 OK
Date: Wed, 11 May 2011 05:18:24 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=GB2312
Set-Cookie: NID=46=cgV8OXUUqoZuZBzyUYB3hZC1sL51UZhsZ8pG6g_tydOhFzj1XIRCjSUTSPge97fbOmafxdA6GHZh1eKokS7Q5sj9JHgi7SmYtW3oPZIE_Sy6FYt8dQxUJ3hstV-RRNrv; expires=Thu, 10-Nov-2011 05:18:24 GMT; path=/; domain=.google.com.hk; HttpOnly
Server: gws
X-XSS-Protection: 1; mode=block
Connection: close

第二次就会出现问题了

GET / HTTP/1.1
te:
host: www.google.com
connection: close
cookie: $Version=0; PREF=ID=9837e8b8b27a4644:FF=0:NW=1:TM=1305091104:LM=1305091104:S=6c4IRHZYSSNbdUuu; $Path=/; $Domain=.google.com

HTTP/1.1 302 Found
Location: http://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http://www.google.com.hk/&ust=1305091219434173&usg=AFQjCNGrXvfQAy3xZMSZz2k2q4slxaeW4Q
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Date: Wed, 11 May 2011 05:19:49 GMT
Server: gws
Content-Length: 376
X-XSS-Protection: 1; mode=block
Connection: close


GET /url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http://www.google.com.hk/&ust=1305091219434173&usg=AFQjCNGrXvfQAy3xZMSZz2k2q4slxaeW4Q HTTP/1.1
te:
host: www.google.com.hk
connection: close
cookie: $Version=0; PREF=ID=9837e8b8b27a4644:FF=0:NW=1:TM=1305091104:LM=1305091104:S=6c4IRHZYSSNbdUuu; $Path=/; $Domain=.google.com
cookie: $Version=0; PREF=ID=9e289483a992f2d3:FF=2:LD=zh-CN:NW=1:TM=1305091104:LM=1305091104:S=yZ76ERBlUrruTyf8; $Path=/; $Domain=.google.com.hk; NID=46=cgV8OXUUqoZuZBzyUYB3hZC1sL51UZhsZ8pG6g_tydOhFzj1XIRCjSUTSPge97fbOmafxdA6GHZh1eKokS7Q5sj9JHgi7SmYtW3oPZIE_Sy6FYt8dQxUJ3hstV-RRNrv; $Path=/; $Domain=.google.com.hk

HTTP/1.1 302 Found
Location: http://www.google.com.hk/
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Set-Cookie: PREF=ID=9837e8b8b27a4644:U=ab1c598a16c1d65a:FF=2:LD=zh-CN:NW=1:TM=1305091104:LM=1305091189:S=oioGImT3t2mz6D-J; expires=Fri, 10-May-2013 05:19:49 GMT; path=/; domain=.google.com.hk
Date: Wed, 11 May 2011 05:19:49 GMT
Server: gws
Content-Length: 222
X-XSS-Protection: 1; mode=block
Connection: close


GET / HTTP/1.1
te:
host: www.google.com.hk
connection: close
cookie: $Version=0; PREF=ID=9837e8b8b27a4644:FF=0:NW=1:TM=1305091104:LM=1305091104:S=6c4IRHZYSSNbdUuu; $Path=/; $Domain=.google.com
cookie: $Version=0; PREF=ID=9e289483a992f2d3:FF=2:LD=zh-CN:NW=1:TM=1305091104:LM=1305091104:S=yZ76ERBlUrruTyf8; $Path=/; $Domain=.google.com.hk; NID=46=cgV8OXUUqoZuZBzyUYB3hZC1sL51UZhsZ8pG6g_tydOhFzj1XIRCjSUTSPge97fbOmafxdA6GHZh1eKokS7Q5sj9JHgi7SmYtW3oPZIE_Sy6FYt8dQxUJ3hstV-RRNrv; $Path=/; $Domain=.google.com.hk
cookie: $Version=0; NID=46=cgV8OXUUqoZuZBzyUYB3hZC1sL51UZhsZ8pG6g_tydOhFzj1XIRCjSUTSPge97fbOmafxdA6GHZh1eKokS7Q5sj9JHgi7SmYtW3oPZIE_Sy6FYt8dQxUJ3hstV-RRNrv; $Path=/; $Domain=.google.com.hk; PREF=ID=9837e8b8b27a4644:U=ab1c598a16c1d65a:FF=2:LD=zh-CN:NW=1:TM=1305091104:LM=1305091189:S=oioGImT3t2mz6D-J; $Path=/; $Domain=.google.com.hk

HTTP/1.1 200 OK
Date: Wed, 11 May 2011 05:19:49 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=Big5
Set-Cookie: PREF=ID=9837e8b8b27a4644:U=ab1c598a16c1d65a:FF=0:NW=1:TM=1305091104:LM=1305091189:S=8wPoAJMKqBOdg6M_; expires=Fri, 10-May-2013 05:19:49 GMT; path=/; domain=.google.com.hk
Server: gws
X-XSS-Protection: 1; mode=block
Connection: close

No comment »

Erlang Supervisor 的 error:{badmatch,{error,{{start_spec,{invalid_modules, ??? }} 错误解决

新人,刚开始学习 erlang ,使用 rebar 生成了一个标准的 otp 应用程序,往 Supervisor 加了一个 gen_server ,却通不过默认单元测试了。提示

 
gamexg@vps1:~/erl/cw$ rebar compile eunit
==> cw (compile)
Compiled src/cw_dnode.erl
Compiled src/cw_sup.erl
Compiled src/cw_app.erl
==> cw (eunit)

=INFO REPORT==== 18-Apr-2011::14:53:47 ===
    application: cw
    exited: {{start_spec,{invalid_modules,cw_dnode}},
             {cw_app,start,[normal,[]]}}
    type: temporary
cw_app: simple_test (module 'cw_app')...*failed*
::error:{badmatch,{error,{{start_spec,{invalid_modules,cw_dnode}},
                        {cw_app,start,[normal,[]]}}}}
  in function cw_app:simple_test/0


=======================================================
  Failed: 1.  Skipped: 0.  Passed: 0.
Cover analysis: /home/gamexg/erl/cw/.eunit/index.html
ERROR: One or more eunit tests failed.

最后发现原因是回调模块应该是列表,我却直接把模块名填上了….

 
-module(cw_sup).

-behaviour(supervisor).

%% API
-export([start_link/0]).

%% Supervisor callbacks
-export([init/1]).

%% Helper macro for declaring children of supervisor
-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).

%% ===================================================================
%% API functions
%% ===================================================================

start_link() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).

%% ===================================================================
%% Supervisor callbacks
%% ===================================================================

init([]) ->
    {ok, { {one_for_one, 5, 100}, 
        [
            {dnode,
                {cw_dnode,start_link,[]},
                permanent,
                10000,
                worker,
                cw_dnode                                 % 这里错了,应该是 [cw_dnode] ,是列表。
            }
        ]
       } }.

No comment »

还是 Godaddy 域名 30% 优惠码

可用于 .com .net 和.org ,没有说过期时间。
优惠码是gdz418c。

No comment »

Godaddy 26% 优惠码

今天收到的优惠码,未提供过期时间,未提供限制。各位如果需要可以试一下。
优惠码是:gdz417p

No comment »

谷歌将字典集成到了标准搜索界面

今天发现谷歌字典界面变了,直接集成到标准搜索界面,就在时光隧道下面。我记得前天用的时候还是原来的版本,应该是昨天或今天更换的。
印象中好像比原来的版本结果更多了,但是还是没有动词名称等标注。集成版的却比原来独立的的使用方便,原来字典不好找基本不用。

No comment »