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);

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