26-c21-0351.jpg说起耳机的故事,还得从三年前说起了…早在刚进大学的2003年,处于对耳机的实际需要和对德国的崇拜,在新蛋订购了一款Sennheiser PX100,谁知…配货出错了,送来的是更高一个级别的PX200,窃喜了三年,结果在四年级的2006年,耳机开始爆皮,相当难受了。于是乎,想,总不能再买比PX200还差的吧…于是乎狠狠心,买了Sennheiser HD215。所谓塞翁失马焉知非福,配货是福是祸?谁又说的清楚呢,哈哈~总之,现在的HD215,还是很满意啦~上个图吧~

对前面的版本进行了修正,主要有:将Change函数针对不同浏览器做了优化,使得对大多数浏览器有效;对主对象进行了OO封装,定义了net名字空间,从而大幅减少了使用时的代码。可从测试用例中看出简化的情况,只需一个new~。重载了处理函数,使得在客户自定义处理函数中要调用返回的参数只需用this.来引用。

Continue reading

MySQL是一个优秀的小型数据库,应用很广。但是新版本出来之后,困扰PHPMyAdmin用户的问题也出现了:

shell> mysql
Client does not support authentication protocol requested
by server; consider upgrading MySQL client

官方的说法是

MySQL 4.1 and up uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older clients. …..

如果你升级mysql到4.1以上版本后遇到以上问题,请先确定你的mysql client 是4.1或者更高版本.(WINDOWS下有问题你就直接跳到下面看解决方法了,因为MYSQL 在WINDOWS是client和server一起装上了的)
请使用以下两种方法之一
其一:
[code=’sql’]mysql> SET PASSWORD FOR
-> ’some_user’@’some_host’ = OLD_PASSWORD(’newpwd’);[/code]
其二:
[code=’sql’]mysql> UPDATE mysql.user SET Password = OLD_PASSWORD(’newpwd’)
-> WHERE Host = ’some_host’ AND User = ’some_user’;
mysql>; FLUSH PRIVILEGES;[/code]
上面用户名密码的部分请按自己实际情况修改….
这样做后,连接就会正常了@!
但是在我的应用中,只有第二种方法管用…

  • Google的月球招聘 www.google.com/jobs/lunar_job.html
  • Google的鸽子银行
    www.google.com/technology/pigeonrank.html
    2002年Google通过这个网页宣布发明一种依靠鸽子来对网页进行排序的专利技术。据说鸽子很好训练,又有很强的对比两页之间差别的能力,然后就可以组成鸽子集群,对互联网上的页面进行排序。
  • Google的月老计划
    www.google.com/romance/index.html
      “Google Romance beta!”是去年愚人节推出的一项“鹊桥”服务。Google声称:“想想看,真爱也不过是另外一种寻寻觅觅(搜索)而已吗?”
      根据网页的提示,你可以上传自己的资料,然后在网上找到你的爱人,通过google最在行的搜索来搜索你的爱情。不过遗憾的是,在你点击上传资料以后,出现的却是一个错误界面,告诉你这只是一个愚人节的玩笑!Google难道在以这种方式对网恋给出警告?
    Google从2004年的愚人节开始为它的月球研发基地招聘外来务工人员,条件是在今年4月1日时满18岁的地球人。想去的又不知道4月1日是什么日子的可以去报名,反正不收填表钱。
  • Google的聪明饮料
  • Beta CarrotyGlutamate GrapeSugar-Free RadicalSero-Tonic Water
    www.google.com/googlegulp/
    Google Gulp(可以翻译成“一口闷”)是Google在2005年愚人节那一天宣布正在测试阶段的饮料产品,按Google的说法,人类的大脑是通过一种叫做“神经传递素”的东西来处理信息的,这种饮料能够加快大脑的处理活动。
      根据网页的介绍,现在,Google Gulp一共有四种,饮料中能够让人思维活跃的物质是Google 在热带雨林中发现的一种化合物。Google 保证你吃了不会死人。“一口闷”产品只是限量发售,要想买到它,你必须从别人那儿获得一个瓶盖。
  • Google的视力测验
    www.google.com/intl/en/mentalplex/
    2000年Google的愚人节把戏。网页告诉你,只要你去掉帽子和眼镜,盯着屏幕上一个螺旋看,然后想一下要搜的东西,最后点那个螺旋,就能看到结果。
  • WordPress是世界上领先的单用户Blog系统。功能强大,模版众多,深得用户喜爱。WordPress mu 是基于WordPress的多用户BLOG系统。1.0是最新版本。这里是我对官方WordPress mu 1.0版本的汉化。后台全部汉化,前台由于与模版有关,所以不再一一汉化。

    提供英文原版和汉化版本的下载,地址如下:

    英文原版 wordpressmu-10.zip

    汉化版 wordpressmu-10-cn.zip

    下面是我实现的一个数据文件随机读取类,可以随机读取大型文本文件的某一行。在我机器上对一个130MB的文本文件,读取第200000的速度从传统做法的400ms提高到了3ms。
    一般对文本文件进行读取时,一般采用ReadLine()进行逐行读取。在这种情况下,C#内的FileStream和BufferedStream类处理绰绰有余了。它不会将整个文件全部读入,而是有缓冲的读。但是,要想随机读取某一行,在行数据长度不统一的情况下,如果每次这样遍历到指定行,其效率显然是很低下的。
    当然,代价也是有的,引入了第一次打开文件的打开时间,且占用了少部分内存(占用多少是可以设置的,当然占得越小速度也越慢,但最大值也比全部读入要小很多)。

    FileConfig.cs;
    [code=’c#’]
    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace DataBuffer
    {
    public static class FileConfig
    {
    public static int STREAM_BUFFER_SIZE = 1024000;
    public static int MAP_DISTANCE = 10;
    }
    }
    [/code]

    DataFile.cs:
    [code=’c#’]
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;

    namespace DataBuffer
    {
    public class DataFile
    {
    ///

    /// 数据文件名
    ///
    public string fileName = “”;
    ///

    /// 初始化读取完标志
    ///
    public bool done = false;
    ///

    /// 当前流位置
    ///
    public long Position = 0;

    private Hashtable head=new Hashtable();
    ///

    /// 文件头部信息
    ///
    public Hashtable Head
    {
    get
    {
    return head;
    }
    set
    {
    head=value;
    }
    }

    private ArrayList map = new ArrayList();
    ///

    /// 文件地图
    ///
    public ArrayList Map
    {
    get
    {
    return map;
    }
    set
    {
    map = value;
    }
    }

    private long lines = 0;
    ///

    /// 文件数据行行数
    ///
    public long Lines
    {
    get
    {
    return lines;
    }
    set
    {
    lines = value;
    }
    }
    }
    }
    [/code]

    DataBuffer.cs:
    [code=’c#’]
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    using System.Collections;
    using System.Threading;

    namespace DataBuffer
    {
    public class DataBuffer
    {
    private FileStream fs = null;
    private BufferedStream bs = null;
    private StreamReader sr = null;
    private StreamWriter sw = null;
    ///

    /// 文件信息数据结构
    ///
    public DataFile dataFile = new DataFile();
    ///

    /// 构造函数
    ///
    /// 数据文件名

    public DataBuffer(string name)
    {
    dataFile.fileName = name;
    }

    ///

    /// 打开文件
    ///
    /// 成功标志
    public bool Open()
    {
    try
    {
    //初始化各流
    fs = new FileStream(dataFile.fileName, FileMode.Open, FileAccess.ReadWrite);
    bs = new BufferedStream(fs, FileConfig.STREAM_BUFFER_SIZE);
    sr = new StreamReader(fs);
    sw = new StreamWriter(fs);
    Thread initFile = new Thread(new ThreadStart(InitDataFile));
    initFile.Start();

    return true;
    }
    catch (Exception ee)
    {
    ErrorHandler.ErrorHandler eh = new ErrorHandler.ErrorHandler(ee, “文件打开”);
    return false;
    }
    }

    private void InitDataFile()
    {
    //另开一个读取流
    BufferedStream bs = new BufferedStream(fs);
    StreamReader sr = new StreamReader(bs);

    //读入数据文件头信息。共14行
    string thisLine = NextLine(ref sr);
    dataFile.Head.Add(“Subject”, thisLine.Substring(11));
    thisLine = NextLine(ref sr);
    dataFile.Head.Add(“Date”, thisLine.Substring(8));
    thisLine = NextLine(ref sr);
    dataFile.Head.Add(“Time”, thisLine.Substring(8));
    thisLine = NextLine(ref sr);
    dataFile.Head.Add(“Channels”, thisLine.Substring(12));
    thisLine = NextLine(ref sr);
    dataFile.Head.Add(“Rate”, thisLine.Substring(8));
    thisLine = NextLine(ref sr);
    dataFile.Head.Add(“Type”, thisLine.Substring(8));
    thisLine = NextLine(ref sr);
    dataFile.Head.Add(“Rows”, thisLine.Substring(8));
    thisLine = NextLine(ref sr);
    thisLine = NextLine(ref sr);
    dataFile.Head.Add(“Electrode Labels”, thisLine);
    thisLine = NextLine(ref sr);
    thisLine = NextLine(ref sr);
    thisLine = NextLine(ref sr);
    thisLine = NextLine(ref sr);
    thisLine = NextLine(ref sr);
    //降低自己的优先级
    //Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;

    //数行数,建立地图
    long lines = 1;
    //在地图中加入首条数据的位置信息
    dataFile.Map.Add(dataFile.Position);
    //顺序建立文件地图
    while (!sr.EndOfStream)
    {
    thisLine = NextLine(ref sr);
    if ((++lines) % FileConfig.MAP_DISTANCE == 0)
    {
    dataFile.Map.Add(dataFile.Position);
    }
    }
    dataFile.Lines = lines;
    dataFile.done = true;
    }

    ///

    /// 文件关闭
    ///
    /// 成功标志
    public bool Close()
    {
    try
    {
    //顺序关闭各流
    sw.Close();
    sr.Close();
    bs.Close();
    fs.Close();
    return true;
    }
    catch (Exception ee)
    {
    ErrorHandler.ErrorHandler eh = new ErrorHandler.ErrorHandler(ee, “文件关闭”);
    return false;
    }
    }

    ///

    /// 顺序读取下一行。效率低不建议大规模使用,只在打开文件的时候使用一次
    ///
    /// 流读取器引用

    /// 下一行内容
    public string NextLine(ref StreamReader sr)
    {
    string next = sr.ReadLine();
    //+2是指Windows换行回车。Linux下要改为+1
    dataFile.Position += next.Length+2;
    return next;
    }

    ///

    /// 快速随机读取一行数据文件内容
    ///
    /// 指定的行数

    /// 目标行内容
    public string ReadLine(long line)
    {
    try
    {
    //如果载入完毕
    if (dataFile.done)
    {
    //确定数据块索引号
    int index = (int)line / FileConfig.MAP_DISTANCE;
    //移动到指定位置
    bs.Seek(long.Parse(dataFile.Map[index].ToString()),SeekOrigin.Begin);
    //创建流读取器
    sr = new StreamReader(bs);
    //移动到指定行
    for (int i = 1; i <= (line - index * FileConfig.MAP_DISTANCE); i++) { sr.ReadLine(); } //返回指定行的值 return sr.ReadLine(); } else { return ""; } } catch (Exception ee) { ErrorHandler.ErrorHandler eh = new ErrorHandler.ErrorHandler(ee, "文件读取"); return ""; } } } } [/code]