The world is not beautiful

July 24, 2009

How to read an app.config setting for your DLL from your dll.config file

Filed under: Another world

from http://juststuffreally.blogspot.com/2008/02/how-to-read-appconfig-setting-for-your.html

It turns out you can manually read the app.config settings for your DLL, using the ConfigurationManager.OpenMappedExeConfiguration. This is pretty darned ugly, but it works. It will look in the location of the currently executing assembly (ie. you dll’s location) for the file “{dllname}.config”. You still need to manually deploy the config file to this location - the setup package only deploys the EXE config file.

To get the code working, first add a reference to the .Net “ConfigurationManager” to your project, then add “using System.ConfigurationManager” to your class.

public string getOpenedConfigValue(string keyName)
{
string codebase =
System.Reflection.Assembly.GetExecutingAssembly().
CodeBase;
Uri p = new Uri(codebase);
string localPath = p.LocalPath;
string executingFilename =
System.IO.Path.
GetFileNameWithoutExtension(localPath);

string sectionGroupName = “applicationSettings”;
string sectionName =
executingFilename + “.Properties.Settings”;

string configName = localPath + “.config”;
ExeConfigurationFileMap fileMap =
new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = configName;
Configuration config =
ConfigurationManager.OpenMappedExeConfiguration(
fileMap,ConfigurationUserLevel.None);
ConfigurationSectionGroup group =
config.GetSectionGroup(sectionGroupName);
ClientSettingsSection section =
(ClientSettingsSection)group.Sections[sectionName];
SettingElement elem = section.Settings.Get(keyName);

if (elem == null)
return “”;
else
return elem.Value.ValueXml.InnerText.Trim();
}

July 21, 2009

Most expensive javascript ever?

Filed under: What others said

from http://my.opera.com/hallvors/blog/2009/07/20/most-expensive-javascript-ever

I’ve wanted to tell this story for a while, and I don’t think I’m spilling any beans or disclosing any sensitive information at this point.

So, a while ago Opera Software needed more servers. Not just a few servers either - we were planning Opera Mini’s growth, implementing Opera Link, and My Opera was also growing quickly. We predicted crazy server load increases for the foreseeable future (and man, were we right!)

Clearly we needed to make a massive investment on the server capacity front (basically buying these shiny things and then some.)

Management put a hefty check on the table - I’m sure our beloved sysadmins felt like kids before Christmas - and salivating sales people from major hardware vendors grabbed our requirements spec, dived into their CRMs and crunched their spreadsheets. They emerged with offers and sample servers shipped all the way to Oslo for our testing pleasure.

However, one of the world’s biggest hardware vendors - whose name every single reader will be familiar with, and whose hardware a good share of you will be using right now - apparently didn’t do their homework. When Opera’s sysadmin booted up the server to test its web-based administration interface, they came across a single JavaScript statement that managed to piss off everyone up to and including the CTO.

This single statement, apparently written by some sub-contractor they had outsourced admin interface programming to, cost them millions of NOK in lost sales.

And the code they sent all the way to Oslo for testing? Here’s an extract:

if (is.opera)
{
window.location.href=”config/error.htm”;
}

[zz]恐怖的windows installer..

zz from http://bbs4.newsmth.net/bbscon.php?bid=99&id=1471960

M$的又一个纱布设计…

发信人: mous (mous), 信区: NewSoftware
标 题: Re: 装Vista时,C盘留80G够不够?
发信站: 水木社区 (Sat Jul 18 21:48:30 2009), 站内

window installer 服务启动的时候,如果是junction,
会清空junction的目标,删除junction,重建installer目录。
然后就欲哭无泪了。
【 在 nighthawk (为什么为什么为什么为什么为什么为什么) 的大作中提到: 】
: 标 题: Re: 装Vista时,C盘留80G够不够?
: 发信站: 水木社区 (Sat Jul 18 21:28:58 2009), 站内
:
: 这个文件夹junction不好使?
:
: 【 在 SunFollow (逍遥仙剑) 的大作中提到: 】
: : 标 题: Re: 装Vista时,C盘留80G够不够?
: : 发信站: 水木社区 (Sat Jul 18 19:42:50 2009), 站内
: :
: : 不能安装。。不能卸载。。
: : 只有重装系统。。
: :
: : 【 在 mous (mous) 的大作中提到: 】
: : : 在用junction把C:\windows\installer搞出事后,深深地领会了这个道理。。。
: :
: :
: : —
: :
: : ※ 来源:·水木社区 newsmth.net·[FROM: 119.6.16.*]
:
:
: —
: 睡吧/睡吧/我的唯一的爱/沉睡在粪土和黑暗中
: 忘了恐惧/忘了孤独
: 听蛙鸣鸟语歌颂世界/从树林和草丛中
: 睡吧/我的爱/忘怀一空/沉睡在粪土和黑暗中
:
:
: ※ 来源:·水木社区 newsmth.net·[FROM: 211.160.20.*]

※ 来源:·水木社区 newsmth.net·[FROM: mous]

※ 来源:·水木社区 newsmth.net·[FROM: 210.32.174.*]

July 20, 2009

Custom FireGesture script to use both wheel gesture(up/down) to switch tab

Filed under: I'm here, Toy box, Software

The default behavior of FireGestrure’s wheel gesture is like this: hold right mouse key down, scroll down mouse wheel one time, then a list of tabs is shown and current tab is selected, one should scroll down one more time to select next tab. the fist scroll down is interpreted as “show the switch tab drop list”, as they do not use both wheel up/down for tab switching.

but when i want to use both wheel up/down to switch between tabs, the default behavior is annoying, what i want is that the cursor should scroll to last/next tab in the list as soon as i scroll the wheel up/down for the first time. the default command can’t meet my requirement, after some researching, my solution is a short piece of custom script:

FireGestures._buildPopup(”FireGestures:AllTabsPopup”, event.type == “DOMMouseScroll”, null);
FireGestures.handleEvent(event);

June 18, 2009

Adobe Acrobat 7启动后报错”Your computer’s configuration appears to have changed since…”

Filed under: Software

最近公司办公用的电脑换了台配置稍好的,于是装系统,装软件..

装完、激活完Acrobat 7后(当然是keygen激活的盗版的嗯..),启动Acrobat准备让他自己下升级补丁,结果报错了:
“Your computer’s configuration appears to have changed since the time this product was activated. To continue using this product, please click OK to activate it again for your new system configuration, or click Cancel to exit.”

google到一个解决方案:
http://kb2.adobe.com/cps/409/kb409127.html

看样子似乎是adobe的认证服务有些bug要打补丁,ok,下下来装上,启动acrobat,错误依旧,重激活再重启还是报错

这下傻眼了,google到的东西里面似乎没有太多有用信息,很多都是联系客服按照客服指导做就ok了,也没说具体怎么做的,另外上面那个补丁所适用的情况也只是adobe的激活系统在raid环境下会出问题导致一直要重激活,但是我机器又没做raid,这似乎不是一个问题;另外adobe网站上一个trouble shooting再众多步骤后居然要求用户重装系统(http://kb2.adobe.com/cps/331/331419.html),我不得不暗地骂adobe你们这帮纱布..

获得的有用信息只有:
1. acrobat 7的激活信息会写在Documents and Settings\All Users\Application Data\Adobe Systems\Product licenses下的一个dat文件中
2. adobe的认证服务(AdobeLM Service)会将一些信息写到第一块硬盘(HD0,又或者是系统所在硬盘)的0扇区上,这点在某个网站的一个帖子里有人略微提了一下,我用procmon的监听结果也支持了这点

于是疑点就出现了,在新机器装了系统后,我把原先机器上的一部分application data拷到了新机器上,愿意是希望这些软件的配置信息能保留,其中也包括了adobe的目录,也就是说,1中的激活信息文件也被我拷过来了

于是尝试删除该文件,卸载acrobat重装,激活,问题依旧

看来要考虑2的影响了,新机器的硬盘和老机器的硬盘不是同一块所以2的记录本来应该不存在,但是因为有错误的1的存在的情况下安装激活过acrobat了,所以可能1中的某些信息也被写到2里去了

监听比对激活时adobe认证服务对硬盘操作的操作后,将记录范围锁定在0硬盘0扇区的0x4000-0x41ff范围内,备份后用winhex将这块区域内容清0,再删除1中的激活信息文件,(没重装)尝试直接启动acrobat,提示说未激活,用keygen激活,重启acrobat,ok,问题解决。

最后,我只想说:adobe,你大爷

January 7, 2009

Problem Connecting from IIS(ASP) to Oracle Database

Filed under: Software

Today when a try to build a web page which gathers some data from a Oracle Database, I meet the following error:

Provider cannot be found. It may not be properly installed

i had oracle 9i client installed on my machine, the connection is made through oracle oledb provider, and i can successfully connect to the database in wscript host with the same connection string. so it seems there is something wrong with iis and oracle

after some search, i had a try to use microsoft oledb provider for oracle instead of oracle’s, then i get this error:

The Oracle(tm) client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3 (or greater) client software installation

there are information saying that one should edit registry to let microsoft provider knows the correct oracle dll file name for oracle client version above 9i. this is probably right and required for microsoft oledb provider, further infomation can be found on http://support.microsoft.com/kb/193893. but this still can not solve my problem.

more search result point to iis user privage on oracle home folder. the most popular related solution is like:

Oracle 9.2 Client software requires that you give the Authenticated User privilege to the Oracle Home by following these steps:
1. Log on to Windows as a user with Administration privileges.
2. Launch Windows Explorer from the Start Menu and navigate to the ORACLE_HOME folder. This is typically the “Ora92″ folder under the “Oracle” folder (i.e. D:\Oracle\Ora92).
3. Right-click on the ORACLE_HOME folder and choose the “Properties” option from the drop down list. A “Properties” window should appear.
4. Click on the “Security” tab of the “Properties” window.
5. Click on the “Authenticated Users” item in the “Name” or “Group or user names” list.
6. Uncheck the “Read and Execute” box in the “Permissions” or “Permissions for Authenticated Users” list under the “Allow” column.
7. Re-check the “Read and Execute” box under the “Allow” column (this is the box you just unchecked).
8. Click the “Advanced” button and in the “Permission Entries” list make sure you see the “Authenticated Users” listed there with:
Permission = Read & Execute
Apply To = This folder, subfolders and files

If this is NOT the case, edit that line and make sure the “Apply onto” drop-down box is set to “This folder, subfolders and files”. This should already be set properly but it is important that you verify this.
9. I checked the “Replace permission entries on all child objects with entries shown here that apply to child objects” checkbox and clicked the “Apply” button. (This was not specified in the original instructions, but it worked.)
10. Click the “Ok” button until you close out all of the security property windows. The cursor may present the hourglass for a few seconds as it applies the permissions you just changed to all subfolders and files.
11. Reboot your computer to assure that these changes have taken effect.
12. Re-execute the application and it should now work.

i did as it said. after add read&exeute permission to %ORACLE_HOME% folder for Authenticated Users, IUSR_ and IWAN_, the microsoft provider pops:

Oracle error occurred, but error message could not be retrieved from Oracle

now i can’t find more information on internat, i thought maybe there is some more lib files outside oracle home folder requires permission set, so at last i start filemon to watch which file access is blocked by window privage system.

then i found that w3wp is tring to access bin/oraclient9.dll under oracle home folder but ended with an “access denied” error

now the truth is out. though i set the permission, and confirmed that the “apply to” option in advance page is set to “This folder, subfolders and files”, the subfolders and files still have their own privage setting. so the correct method should be:

*after granted read&exeute permission of oracle home folder to Authenticated User, and confirmed the “apply to” option in advance page is set to “This folder, subfolders and files”, one should check the “replace permission entires on all child objects with entries shown here that apply to child objects” option to overwrite subfolders’ privage setting*

after this, both oracle provider and microsoft provider works correctly

May 16, 2007

[zz]像风一样自由

转载,暂不评论



像风一样自由(我是如何玩着WOW考上研的)
by 何露斯之眼
我不是一个善于把自己的感想告诉公众的人,也许我写这篇文章的目的不是告诉别人什么,而是为了写下自己的回忆,把过去的事情在自己的脑海里作一个总结罢了.

一,我的记忆.众人误解的真理.

首先,我是一个WOWER,其次,我是一个现阶段成功了的人,我考上的学校是位于北京的一所比较难考取的特殊院校,至于名字也没有多提及的必要了,将来很有可能分到部里工作.有时候,想想当初的时光,总是让我联想起盟军敢死队的那首主题歌>i JUST DO NOT WANT TO REMEMBER<.

今年5月我见了3个人.第一个是我的一个同窗,肖,他考的是北师大法律系,很努力,也很勤奋. 那时候,常常是我在睡觉的时候,他已经外出看书.我玩WOW的时候他还在背诵有关资料,他每天六点半准时起床,十二点准时睡觉,那时候我还在外面玩WOW,直到2点才回来,他从去年5月开始就一直准备这事.我的任何看法在他眼里都是一文不值的,他总是总结了很多前人的经验,总是分析了相当多的方法.在他看来,勤奋,努力,加方法和经验就是成功,而我这样天天玩网络游戏的人,注定是失败者.然而,今年开春,当我得知我的初试成绩靠前并且超过分数线三十多分的时候,他却因为没有过国家线而申请调剂到云南民族大学(过了C类线).最后我得知我通过复试的时候,他却因为民族大学不接受调剂而去向不明.这个看起来不合逻辑的事,现在在我这个过来人看来,是很合逻辑的.原因我之后会说.

第二个人也是我的一个同窗,珍,不过她是母的.考上了北京大学中文系.那天十二点我还和她一起在外面聊天.(我是夜行动物) 那个时候我问了她一个问题,我说,我们命运很相似啊,有好多共同点.她不解.
我说,你看,你中学是重点中学的,在中学老师兢兢业业的教育下,在家长孜孜不倦的教诲下,考了一个垃圾大学:湖南师大,(师大的别骂我,相对北大的话确实如此).后来,在大学老师的辛勤教育下,在国家教育系统的精心培育下(当然价格是不菲的),你一事无成. 之后,你出来半年,考上了北京大学.
同样,我也是重点中学的学生,一中的,在中学老师的”关怀”和”教育”下, 更差的大学,我考了个更差的大学:XX大学,(比师大更垃圾的一个学校)在大学的精心培养下,四年我一事无成.同样,我出来半年,完全凭借自己的实力,我竟然考上了XX UNIVERSITY. 你看出什么来了吗?她大笑.这看起来很没逻辑吗?你又看出了什么?

第三个人还是我的一个同窗,武,不过他没有参加考试,大学一直在玩WOW,结果没有拿到学位证.现在的联系也少了.他总是说,是游戏害了他.真是这样吗??原因我之后会说.

古代的贤哲认为,精神所存在的世界是真实的世界,而肉眼所看到的世界只是表象的世界.精神是一只长满羽翼的鹰.而肉体则是一只流着毒痰而在地上爬行的蛇,这之间有着一条必然的鸿沟.现在的人往往退化到只能看到那表象的东西,而对真实的存在熟视无睹,毫无察觉.

我记得某位贤人曾经说过,上帝从不为难头脑简单的人,因为世界上的真理往往都是最简单的.不需要太高的智商就能领悟到.一个人能否成功不在于他是否能够发现真理,利用真理,玩弄真理.而在于他是否能够坚持真理.很多智商高的人往往认为真理必然是更复杂的事物,因为如果成功如此简单,那么不是人人都能成功吗?于是他们走上了一条不归路.中国和西洋分别有两个傻子,郭靖和阿甘,他们智商不高,但却能坚持最简单的真理而最终获得了成功.啊甘的老妈总是告诉他最简单的道理,比如有危险就跑.这让他在越南检了条命回来,而且成为战斗英雄.中国的郭靖也是如此,正因为他能坚持道德准则,而得到众多武林前辈的信任和帮助,而他的兄弟杨康则是一个反面的例子.

可是我要说,这位贤人错了,上帝不是不为难头脑简单的人,而是不为难坚持真理的人,不为难做了应该做的事情的人.头脑的简单和复杂只是表象.只要在正确地方做了应该做的事,就能获得成功. 吴起这个人,又贪财又贪色,不过他能在正确的地方做出正确的决策,就是一代良将.商纣如果没有妲己,也一样是个亡国之君.又如打猎,一个人尽管早起操练,把箭,刀磨得锃亮,但如果在埋伏的过程中过早暴露目标,那会失败. 一个人成功还是失败,和WOW为代表的外部诱惑并无直接关系.而在于有没有完成应该做的事.

人总是以为,玩物丧志,多玩一分便少学一分.可笑的结论,因为这是建立在此人时时都在学习的假设上的,这可能吗?中国的长辈们往往都是在自己抽烟打麻将的同时期待着自己那个神一般的儿子时时都在看书.其实一个时时都在看书的人,等同于一个时时都没看的人.因为他做的都是无用功.人类往往把失败归结于外物而不是内因,因为他们的精神层面很羸弱,从而距离真实的世界很远. 其实,成功不是取决于你玩了多少,而是取决于你做了多少有效的事情.用物理术语讲就是多少有用功.

如果我再碰到肖,我会告诉他,他很勤奋,也很努力,不过他的努力大部分是白力,没有功用的付出.

如果我下一次碰到珍,我会明白告诉她那个答案,中国的教育体制,就是一个把人变成废人的体制,
在榨干了你的钱财后,把你抛入社会.

如果我再碰到武,我会告诉他,不是WOW害了他,而是他自己,没有WOW的话,他也就那点出息.

二 WOW,游戏,淮水河边的一碗汤

总感觉八十年代初中期这一代,是孤独的一代.他们没有兄弟姐妹的陪伴,没有父母日日夜夜的呵护,也没有邻家伙伴的友情,当然也不用说小动物.更多的时候陪伴他们的只是一台游戏机,他们孤独的灵魂在一个又一个虚幻的世界中冒险,做着他们先辈们同样的梦,走遍天下,看遍这花花世界,经历各种各样的事情,结交各种各样的人.不过和他们祖先不一样的是,他们没有钱去闯荡世界,只能在虚拟的世界里体验冒险,一种最廉价的冒险. 那个时候,很难想像,如果没有WOW,没有网络的话,在那个陌生的异乡,我一个人面对排外的各个系统,机构和大学,发誓靠考试这一条唯一的希望来改变我的命运的时候,每天面对无尽的孤独和无边的黑暗,我会不会精神出现崩溃. 每一个开荒ZG和战场争夺的日子里,我睡觉前总会忘记片刻的孤独,因为我有东西可想了,我可以考虑下一次打法要有什么改变,我可以期待下一个BOSS又长的什么样.我也知道这样于大局来说不好,但是我做不到,在巨大的精神压力下,我无法做到每时每刻都把精力放在有用的事情上. 那个时候,WOW对我来说就象是精神镇定剂.没有WOW,我不知道会是怎样.

同样一个东西,为什么在医生手里就可以救人性命,为什么在歹徒手里就可以夺人性命,这样一个问题,我现在是想通了.

每次看到海格力斯的那个故事时,我总是又重新振作起来.人生就象这样一场战争,十二场根本不存在公平这个概念的无理任务.一个接一个,如果都完成的话,便能得一个金身正果.如果中途倒下,则万劫不复.这才第一个呢~有没搞错. 北京的冬夜又黑又冷,我已经不记得我每次在飞雪的路灯下走过时心里都想了些什么,虽然制度是如此黑暗,如此无理.有时候我总想,为什么他们宁可要一个无才无德.贪赃枉法的X长家的纨绔子弟,也不愿意要一个一腔热血,愿意精忠报国的年轻人呢?有几次我都想放弃了,不过最终还是没有,因为我相信上帝最后总要给我一个答案的.

我终于走了过来,复试的时候,我坐在大厅的椅子上等候,非本校的人不多,我是其中一个.一个老太太看到我(后来才知道是副院长),说,瞧这孩子,紧张得脸都白了.(其实我的脸本来就这颜色),这个老婆婆给了我一杯水.这是一年来我第一次喝上这么热的水,当时的感动我到现在仍记得很清楚.我知道,黑暗的一切已经在我脚下了。

三 女人, 人类的退化之路

用WOW的术语说,在我看来,女人就象一件装备,它们永远不会在你开荒的时候到你那里,但会在FARM季节纷至沓来. 和我一起走上这条路的人有很多,他们怀着一个理想从五湖四海赶来,他们每个人都有出众的才能,每个人都能忍受人所承受不了的痛苦,每个人都有一个远大的理想.不过,他们都有一个共同的特点,没有成家.(这个词是个实际概念,不是法律概念) 而那些安于现状的家伙们此刻正在家乡做着一份撑不死也饿不坏的工作,抱着老婆眼巴巴的期待的家族势力拼凑的房子钱,呵呵.

爱情与其说是一个情感问题,不如说是一个生物问题,如果要给它下一个客观定义的话,我觉得比起一个愿望来它更象是一场交易.人嘛,总喜欢把任何东西都贴上一个标签,你的,我的,分的很清楚,有了拥有也自然就有了交易, 不过我这人永远都只和魔鬼做交易,我又如何受得了和一个可爱的人做交易呢?这让我想起一件事情,在米港等船的时候,几乎每个陌生人见到我的第一句话都是:”你这个饰品从哪刷的?” 不知道是该悲哀呢还是该笑, 他们以后再也记不得我的名字,只知道一个饰品能晕人3秒,PK极品,曾经看到一个小德戴过. 我想对于任何一个人来说,他们永远能看到的往往只是你有什么,而不是你是什么.说来也奇怪,每次夜深人静的时候我都会想起一庄往事,我这一辈子只爱过一个女人, 不过为什么这个女人宁愿要一个又酗酒又抽烟又赌博,喜欢打牌,打女人,没有文化,而且从来不干正经事的人也不愿意要我呢?不仅如此我连尊严都丢了.
也许要看清楚一个人真的很难,尼采说,女人就象一头母牛,牛是善良的食草动物,他们也没有伤害其他动物的能力,不过它们的脑也差不多只有会咀嚼的水平.看清并分辨一个人是什么,对于人来说尚且那么难,何况是对于一头只能依靠本能的牛呢???如果牛能分辨的话,那么遭遇抢婚的也不会是唐僧了.

谁没有憧憬过美好的未来呢?不知道是不是时代原因,现在人不懂得尊重爱,更不懂得尊重人,还有什么人值得爱呢?不,哪怕是正眼相看.

进化,适者生存的规律曾经是一个钟爱人的过程,不过已经不再是了, 由于没有天敌控制数量,个体遗传开始体现在制造后代的能力的上. 古代圣贤多无后,无能的人制造的后代越来越多,也许若干年后,人类又会回到猩猩的水平上了吧.

对于我而言,我想我会再以后的日子里继续WOW,继续追求事业和实力上的长进

仅以此文纪念我过去的日子.



from http://bbs.ngacn.com/read.php?tid=971297

Get free blog up and running in minutes with Blogsome
Theme designed by Jay of onefinejay.com