This is the difference between being neutral and being neutrally biased. It’s true that many choose a neutral position because “the truth is always somewhere in the middle”, which is a bias. It’s also true that there is still usually more than one side to the story.
Категория: In English @en
Bias
Multiobject try..finally
Just a simple Delphi pattern. We all have encountered nested try..finally blocks like this:
CChar := TTextTableCursor.Create(TChar); tryCCharProp := TTextTableCursor.Create(TCharProp); try Builder := TCharPropBuilder.Create(Result); try //Do some work with all three objects //Since all three are needed, we can't destroy any before this point finally FreeAndNil(Builder); end; finally FreeAndNil(CCharProp); end;finally
FreeAndNil(CChar);end;But there's a nicer way of doing the same while still being exception safe (and avoiding the overhead of three
try..finallyexception frames):
CChar := nil; CCharProp := nil; Builder := nil; tryCChar := TTextTableCursor.Create(TChar); CCharProp := TTextTableCursor.Create(TCharProp); Builder := TCharPropBuilder.Create(Result); //Do some work with all three objectsfinally
FreeAndNil(Builder); FreeAndNil(CCharProp); FreeAndNil(CChar);end;
Installing Delphi VersionInsight Plus
Since Delphi XE, Delphi has SVN support integrated into file history display. SVN revisions are displayed in addition to local backups, all properly sorted by date. Very nice.
Mercurial and Git support wasn't added into the default distribution, but there's a newer version of VersionInsight plugin with fully functioning support for those, written by Delphi developers. Meet RAD Studio Version Insight Plus.
To use this you need to compile it. It's simple, but mind these fine points:
- There are several branches in the repo, you need the
/plusone. Not the trunk. - Delphi less than XE will not compile those, no simple solution.
- You need to compile five packages:
svn,svnui,svnide(already grouped into DelphiSVN) +hgideandgitide. - Delphi already includes pre-compiled
svn,svnuiandsvnide. You need to remove those from "Component> Install packages" list. (And restart) - The ones from SVN are marked ver_150, and the ones with Delphi ver_170, but the ones from SVN are newer (I think).
- When compiling the packages, Delphi might try to trip you up and use existing packages it cached somewhere instead of the sources right in front of it.
To be on a safe side, dodir c:\svn*.bpl /s,dir c:\svn*.dcp /s,dir c:\svn*.dcu /s, and remove everything related to VersionInsight plus. (Some matches are going to be in the cached Delphi install distributions, these are fine).
Particularly,svn*.dcpinProgram Files\Embarcadero\Delphi\DelphiVersion\lib\Win32\debugor\releaseare known to silently cause problems such assvnui.bplcomplaining that TSvnBlameOptions is not defined even though it's defined right there inSvnClient.pas.
Otherwise packages compile just fine, have no dependencies and produce almost no warnings.
After compiling the packages, install the last three (svnide, hgide and gitide). Restart the Delphi.
The SVN support will start working straight away (it should have been working before too). For Git and Mercurial you need to go to Tools> Options> Version Control, and set paths to git.exe and hg.exe executables in the respective sections.
Atlas Shrugged
Well, people say Rand’s book is about how to be an asshole. It certainly seems that some of her opponents just don’t need the training.
HOWTO: Add your own feed reader to Opera’s default list
By default, when you click on an RSS feed icon, Opera displays feed contents in some basic format and allows you to subscribe to it with either the built-in reader or some of the popular ones.
But with the recent end of life of Google Reader many will switch to other, less popular readers, or perhaps even install one on their own server.
To add a feed reader to Opera's default reader list, edit feedreaders.ini in "Program Files\Opera\defaults" folder. The format is obvious. There doesn't seem to be an option for a per-user feed reader list.
For instance, if you're using Tiny Tiny RSS, the subscription URL is per faq:
http://your.domain.com/path-to-ttrss/public.php?op=subscribe&feed_url=%s
The code to add to feedreaders.ini will be:
[TinyRSS] ID=20 URL=http://your.domain.com/path-to-ttrss/public.php?op=subscribe&feed_url=%s
Tell me what I’m going to use it for
For those who didn’t know, there’s a new pascal-based compiler on a market for a while, and a pretty cool one at that. Enter RemObjects Oxygene.
It’s Visual Studio-based, compiles to .NET, Android Java and iPhone Cocoa, resembles Pascal and implements the majority of its cool features like generics. Parts of language are redesigned, some for better, some for worse.
Cool feature. Even the main unit now has the interface/implementation sections.
namespace Application1;
interface
implementation
begin
Console.WriteLine("The magic happens here.");
end.Uncool feature. initialization/finalization sections are no more. I guess you can kinda replace them with class constructors, but they were so much better.
Anyway.
The language is indeed pretty fresh, with support even for WinRT while Delphi has yet to convince Microsoft to let everyone else have a part of the cake. Turns out, the only way to do native WinRT applications is through using Microsoft Visual C++ Runtime. Ha-ha, funny joke Microsoft, you.
So I thought about playing with it for a change.
No, I’m not betraying Delphi just yet. It’s still pretty cool, compiling to 64 bit and not being afraid of anything.
But sitting before the empty Oxygene project, I have found myself at loss at what to do.
Okay, it runs. It compiles Hello World, alright.
What next?
Turns out, when you encounter a new language, you have to have a few use cases for it. And since you usually don’t know what this langage can do, it’s better if someone suggests those for you.
One hyperlink multiple hrefs
The simple thing that HTML really lacks is the ability to set multiple HREF targets for a single link:
<a href="iichan.ru" href="iichan.hk">
Why would you need this?
1. To specify multiple hosts serving the same thing, ensuring that even if one host goes down, it’s still accessible (for instance, multiple sources for a pic you’re linking to)
2. To aid with domain name changes (linking to both old and new domains)
3. To keep information well-organized (for instance, there’s a well-known domain hosting this which is down now, but may be revived later, and you’re linking to a google cache copy or a mirror, and still want the main domain to be the logical “target”)
How to implement this:
Browsers shall try HREF links one after another, in the order of declaration. They MAY probe them all at once and choose the fastest server, or probe in batches. They MUST though choose one “default” HREF and display it in the interface, and navigate to other HREFs only after asking for permission from the user. They MAY let the user choose the HREF manually when clicking on link.
Correct: The browser randomly chooses second HREF as the default HREF. When the user clicks on link, the server is not accessible, so the browser asks for permission to use next randomly chosen (fifth) HREF. This one is not accessible too. The browser asks for permission to use next randomly chosen (first) HREF, which turns out to be available.
Correct: When the user clicks on link, the browser probes all the available HREFs. Since the default one is not accessible, the browser asks for permission to use the fastest available alternative.
Correct: When rendering the page, the browser probes all the available HREFs and uses the fastest available server as the default HREF.
Correct: When rendering the page, the browser uses it’s knowledge of which servers were available and which were down before, to guess the best default HREF without actually probing HREFs.