哈哈哈哈

好多年没有运行过一个完整的桌面程序了,最近3个月每天(也不是每天,只能有空的时候)回到家写几行,写几行,昨天总算写出了第一个功能:让用户看到现有的文档,并修改文档内容。

实际上这个程序的功能规划的很庞大,一个人肯定是写不完的,更何况每天就那么几行,几个主要功能写完就甩给别人去干,现在还要完善一些基本功能,规范一下程序架构。

故伎重演

自从工作之后,工作日下班回到家写博客的时间越来越少,因为越来越觉得下班之后又很多工作还要做,今天是因为要记一个小小的文档,把程序的流程简单记录一下,顺便就当作文章发出来——在学校的时候也是这么干的。BsonDocument是运行时记录数据的内存对象,目前在用户界面(GUI)上显示这个文档的方式是Windows的TreeView。GUI需要提供给用户浏览数据的功能,同时也要提供修改数据的功能。因此具体的数据显示与维护策略如下:

前提

程序保留一个BsonDocument作为当前程序可以唯一修改和读取的数据对象,这个BsonDocument在代码中命名为curDoc。

数据显示

当每一个BsonDocument中的Element显示在TreeNode中时,将当前Element节点的数据存放在TreeNode的tag中,将Element的Key-Value数据显示在TreeNode的text中。

数据修改

当用户在TreeView界面中选择TreeNode,欲修改时,则程序将tag中的Element提供给用户修改,并保存——最后将这个修改过的Element存入curDoc。这里有个问题是:在把修改之后的Element存入curDoc的对应节点位置时,如何在curDoc中找到正确的位置。最好的解决办法是找到一种通用的数据记录TreeMap,让TreeMap记录任意一个节点在整个结构树文档中的Standort,方便TreeNode到BsonDocument的节点Positionbestimmung。 但是Zlike的意见是使用PATH这种东西,PATH在一般的树结构数据中都能提供——这倒是一个好办法。

das Verfahen der Umhandlung zwischen BsonDocument und GUI

最近桌面越来越混乱,好似回到了学校

die Arbeitsflaeche


MONGODB_install as windows service

总是觉得MONGO和芒果有关,其实是自己想当然。最近刚刚尝试了一下MONGODB,要安装成windows service,天天晚上回来折腾一下下,终究是没搞定,今天下午从银行取了卡回来,搜到一篇文章,解决问题,特此转载。

article source: http://thebackshop.posterous.com/installing-mongodb-as-a-service-on-windows-7

======== cited text =======

Installing MongoDB as a Service on Windows 7

Over the last few months there’s been an increasing amount of interest in NoSQL database options among the members of the PHP Developers’ Group that I help organize in Chattanooga … and frankly, I’ve been itching to dig in myself. The other organizers and I decided that what we would do is each choose a NoSQL database engine, and over the next few months we’d cover those engines by devoting the main presentation of a meeting to them. Our presentations will cover the basics of using the engine in question, discuss the strengths and weaknesses of the engine, and the process of building a simple a simple application in PHP with it.

I chose MongoDB. Well, as fate would have it, I was in the process of learning ASP.NET/C# at work, and as an exercise, I ended up setting up MongoDB on Windows and using it to build a simple web using ASP.NET … so my first foray into MongoDB was with C# rather than PHP. Go figure.

MongoDB works quite well on Windows. Unfortunately, the downloadable .ZIP package you get from mongodb.org doesn’t give you any indication of how to run it as a Windows service, and I really, really wanted to do that instead of having to manually start it up every time I wanted to play with it. I went out searching for information on how to do so, and ended up finding conflicting instructions that sometimes didn’t work. I couldn’t find any start-to-finish tutorial that explained all the steps of how to get things working. Hence this post …

In this tutorial, I’m using what is currently the most recent production-ready version of Mongo, 1.4.1. You should be vaguely comfortable with working with the command prompt, editing registry entires with regedit, and starting/stopping services before going any further. You may break your computer, anger your mailman or trigger an IRS audit if you’re not careful. You’ve been warned. Finally … I have no idea if these instructions work on any other version of Windows; I haven’t tried them on anything but Windows 7.

  1. Download and extract the MongoDB archive appropriate for your system. http://www.mongodb.org/display/DOCS/Downloads
  2. Copy the extracted folder to C: and rename it mongo.
  3. Create a directory called ‘data’ inside C:mongo
  4. Click on the Start Menu and enter “cmd” in the search box. Right-click on cmd.exe and select “Run as administrator.” This is VERY important because you won’t be able to register MongoDB as a service if you run cmd.exe with normal privileges.
  5. Type “C:mongobinmongod –install” to register MongoDB as a Windows service. This will probably output what may look like an error message, but don’t worry … as long as you really did run cmd.exe with administrator privileges, everything is fine.
  6. Click on the start menu and enter “regedit” in the search box. Click on regedit.exe, and then browse to HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservices. There should be child folder there named MongoDB that has several keys inside it. If not, go back to step 4 and try again.
  7. The ImagePath key should read “c:mongobinmongod –service” right now; change it to  “c:mongobinmongod –service –dbpath c:mongodata”. This will allow MongoDB to find its data files.
  8. Click on the Start Menu and enter “services” in the search box. Click on the “Component Services” option.
  9. In the pane on the far left, double-click on “Services (Local).” Locate MongoDB in the list in the center pane, and double click on it to bring up the properties inspector window.
  10. Make sure “Startup type” is set to automatic. Then click on the “Start” button.
  11. Browse to http://localhost:28017/ to verify that MongoDB is really running.

That’s it!

======== cited text =======/

心照不宣

太强大了!

自从在研究生的那个实验室呆过,就觉得各种意念控制终有一天是可以实现的,但是没想到来的这么早!原原本本把视频拿到这里来太麻烦,干脆就给一个链接好了,是网易公开课的视频:

http://v.163.com/movie/2010/7/P/T/M78G0BFIM_M78G0FFPT.html

一般人可能觉得这是个很邪门的东西,但是编程的角度看,就相当于是面向过程编程进化到了面向对象编程。最初的编程是机器码,后来变成了汇编码,再后来变成了C、Fortune这样的高级语言,再后来面向对象语言Java、C++、C#横行霸道,这种过程是低级的语言逐步的被隐藏在高级语言之下,设计程序的人慢慢的只要了解一些和自己日常认知相近的概念就能学到编程手段,实现自动化和控制,其实最终机器接受的语言还是机器码,只是有那么个叫做编译器的家伙不辞辛劳把高级语言翻译成机器码。

传统的编程和软件需要的是用户给出字符输入,比如源代码或者命令行(当然这两者是不同级别的手段,不能等量齐观)。用最普通的命令行来说,这其实不是一种编程手段,而是一种用户接口,在程序内部会有一种机制来理解用户的命令行,最终实现成机器的行为。命令行是所谓的用户接口的一种形式,软件和自动化行业发展到了现在,用户接口其实已经远远不止命令行这么简单,语音命令可以当做用户接口,手指触摸的动作可以当作用户接口,表情可以当作用户接口,甚至人体动作,都可以,只要是想象得到,都可以。

一般人应该都很容易理解从源代码到机器行为的过程,那么从用户接口到机器行为的过程,就只需要了解从用户接口到源代码(或者程序)的过程就可以了,因为从用户接口输入的信息是必须经过程序本身“理解”再实现成最终的机器行为的。如果从正式的角度来说程序可以理解从用户接口输入的信息的原因,有一个很冗长的名词:有限状态自动向量机。为什么叫这么个名字就不说了,有限状态自动向量机只是一个泛称,很多编程的人其实根本不在乎自己的程序是不是可以叫这个名字,这个名字只不过是归纳了程序的一种普遍功能。这种功能就是当程序捕捉到一个外部命令,会在内部找出与这个命令相对应的一种“状态”,这种“状态”其实只不过是一个符号或者代码,程序员爱怎么规定就怎规定,那么命令A就对应状态a,命令B对应状态b,依次类推,但是有一个条件,这种对应不能无止尽的延续下去,状态的个数必须是有限的。

在TED介绍的emotive技术里面,脑电波也成了一种用户接口,仅此而已。真正让人惊叹的是他们把脑电波用这么精简的设备采集出来,并对这些脑电波进行识别,最终转化成对应的状态。有了这种技术,不要说眉眼传神,心照不宣也不远了。

发现写成了科普贴。

一段代码

琢磨了两个礼拜,做了两张表,第二个表用来记录第一个表的统计值

———————————-mysql code———————————-

— Trigger DDL Statements
DELIMITER $$

USE `db_chyujian`$$

CREATE
DEFINER=`root`@`localhost`
TRIGGER `db_chyujian`.`Calculate_m_total`
AFTER INSERT ON `db_chyujian`.`konsum`
FOR EACH ROW
begin

# die Jahr und Monat zu absaehnen
set @date_neu = NEW.datum;
set @year_neu = YEAR(@date_neu);
set @month_neu = MONTH(@date_neu);

set @jahr_int_tmp =
convert(@year_neu, unsigned) * 100;
set @monat_int_tmp =
convert(@month_neu, unsigned);

# die Monat in monatiliche_statistik zu zaehlen
set @monat_in_statistik =  @jahr_int_tmp + @monat_int_tmp;
# die totale Betrag zu zaehlen
set @total =
(select sum(betrag) from `db_chyujian`.`konsum`
where MONTH(datum) = @month_neu );
set @total_ausflug =
(
select sum(betrag) from `db_chyujian`.`konsum`
where MONTH(datum) = @month_neu
and sorte = ‘ausflug’
);
set @total_bildung =
(
select sum(betrag) from `db_chyujian`.`konsum`
where MONTH(datum) = @month_neu
and sorte = ‘Bildung’
);
set @total_nahrung =
(
select sum(betrag) from `db_chyujian`.`konsum`
where MONTH(datum) = @month_neu
and sorte = ‘Nahrung’
);
set @total_andere =
(
select sum(betrag) from `db_chyujian`.`konsum`
where MONTH(datum) = @month_neu
and (sorte = ‘Amateur’ or sorte = ‘Alltagsgebrauch’)
);

# den Rekord in monatliche_statistik zu modifizieren
if exists (select *
from `db_chyujian`.`monatliche_statistik`
where monat = @monat_in_statistik)
then
set @ziel_id = (
select id from `db_chyujian`.`monatliche_statistik`
where monat = @monat_in_statistik);
update `db_chyujian`.`monatliche_statistik`
set `total` = @total,
`total_ausflug` = @total_ausflug,
`total_bildung` = @total_bildung,
`total_nahrung` = @total_nahrung,
`total_andere` = @total_andere
where id = @ziel_id ;

else
insert into `db_chyujian`.`monatliche_statistik`
(monat, total,  total_ausflug, total_bildung, total_nahrung, total_andere)
values
(@monat_in_statistik,
(select sum(betrag) from `db_chyujian`.`konsum` where MONTH(datum)= @month_neu),
@total_ausflug,
@total_bildung,
@total_nahrung,
@total_andere
);

end if;

end$$