The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

Archive for January, 2012

Dear Mister Jones » How to insert a carriage return with batch

Posted by jpluimers on 2012/01/17

When appending multiple text files to a big one (for instance to post-processing on the total: dedupe, sort, gather statistics, etc) you often will find one or more of the source files missing a CRLF.

So you will have to insert those carriage return line feed combo’s manually.

Well, mr Jones points out that:

there’s actually an easy way to simply echo a carriage return and line feed instead, by just issuing an echo command followed immediately by a period (no space in between), like this:

echo. >> somefile.txt

Thanks Jared!

–jeroen

via: Dear Mister Jones » How to insert a carriage return with batch.

Posted in Batch-Files, Development, Scripting | Leave a Comment »

Is #Trello #GTD on Steroids?

Posted by jpluimers on 2012/01/16

Will start playing with Trello checking if it is indeed GTD on steroids.

–jeroen

Via: Organize anything, together. | Trello.

Posted in LifeHacker, Power User | Leave a Comment »

15 years of xs4all internet provider membership

Posted by jpluimers on 2012/01/15

Today it is the 15th anniversary of my xs4all membership.
Even though (see some history below) xs4all was not my first provider, it has been the provider of choice ever since:

  • Technically very knowledgeable
  • Very stable connection
  • Highly much aware of privacy

Back in December 1998, when xs4all was sold sold to the Dutch Telcom (KPN), lots of people were afraid that xs4all would start scoring less points one ore more of the above points.
They didn’t, and that is the main reason I’m still client with them.

This despite the  fact that I can get faster internet where I live.
My ADSL connection is quite a long distance from the telco DSLAM, so I can’t get a very high ADSL speed.
As some of the ADSL versus distance speed graphs show, your ADSL connection needs to be close to the telco’s DSLAM.
I’m not, so my maximum ADSL1 speed is slightly less than 8 megabit, and my current ADSL2+ speed is less than 16 megabit, so xs4all light is the best I can get.

BTW: If you live in The Netherlands, here you can calculate that distance (which is called “afstand tot de centrale” in Dutch).
I wish they ran the telco cables under the canal to the neighboring village: I’m about 500 meter away from their DSLAM, in stead of the 2700 meters I’m from my own DSLAM.
Oh well :-)

For high speed things, I now also have a cable connection.
Even though they are deregulating that part of the broadband market, currently cable internet is bound to your cable TV provider.
In my case, that is UPC, and their high speed internet is marketed as Fiber Power.
I started with a 60 over 6 megabit service, that they increased to 120 over 10 megabit about a year ago while reducing the price (because they were merging their packages and wanted to increase their competetiveness).

While writing this, I’m still searching for a good dual gigabit WAN router to combine the two connections in one.

Over time, xs4all increased the ADSL bandwidth from a meager 1 megabit over 256 kilobit to 8 megabit over 1 megabit.
They increased mailbox and storage sizes too.
And finally, they were among the first to support IPv6.

So all in all, I’m still very happy for staying with xs4all.

A bit of history

xs4all was not where the internet started for me. Read the rest of this entry »

Posted in About, BBS, FidoNet, History, Internet, ISP, Personal, Power User, SpeedTest, xs4all, Ziggo/UPC/A2000 | 18 Comments »

Affordable MacBook Air physical USB ethernet adapter

Posted by jpluimers on 2012/01/13

DealExtreme product #34691: USB 2.0 10/100Mbps RJ45 LAN Ethernet Network Adapter Dongle

A big drawback from a MacBook Air is that it only have wireless LAN/WiFi (in the form of Integrated AirPort Extreme 802.11 a/b/n/n), no physical ethernet.

Transferring large amounts of data over any WiFi is can be a pain (being slow, suffer from signal quality) and for the MacBook Air: it makes the built-in fan swirl like crazy.

Since the MacBook Air does not have USB 3.0, I went looking for a 100 Mbps USB Ethernet dongle for it, and fone the DealExtreme product #34691: USB 2.0 10/100Mbps RJ45 LAN Ethernet Network Adapter Dongle.

At a price of about USD 7 including shipping, it comes in an Apple compatible shiny white color too, nicely fitting the 4 port USB hub (DealExtreme # 45773) on the right  :)

Even better: it works like a charm!

Note that first need to download and install the ASIX AX88772B drivers first. Choose the Apple Mac OSX 10.4 to 10.7 Driver for x86 and Power PC download package labelled “For Apple x86/Power PC, 32-bit/64-bit platforms”.

The install tells you to reboot at the end, but no need for that: as soon as the install finishes, the USB Ethernet dongle works. And it is fast too: 12 megabyte/second over a 100 megabit cable is fast!

In the readme of those drivers, it also mentions the AX88178, which is capable of gigabit (there is a separate AX88178 driver download page and Mac OS X download package).

NB: the cool thing about both these ASIX chipsets is that they are supported on a broad range of platforms (Mac, Linux, Windows CE, Windows 7/Vista/XP/2003/2000) and bit sizes (32-bit and 64-bit).

For even faster transfers, I might try the DealExtreme product #15336: Arkview USB 2.0 1000Mbs Gigabit Ethernet LAN Network Adapter.

It is slightly less than USD 20, and  user Janipro indicates it is based on the ASIX AX88178 chip at the DealExtreme forum.

On the other hand: I might not, as for more than twice the price, user cyberic mentions in the same forum thread it is only about twice as fast: 23 megabytes per second, about half the maximum USB 2.0 speed of 480 Mbps. And it is not Apple white :)

–jeroen

Via: USB 2.0 10/100Mbps RJ45 LAN Ethernet Network Adapter Dongle – Free Shipping – DealExtreme.

Posted in Apple, LifeHacker, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, MacBook, MacBook-Air, Power User | Leave a Comment »

Migrate/Transfer SQL Server 2008/2005/2000/7 Logins to SQL Server 2008

Posted by jpluimers on 2012/01/12

When moving databases across servers, you face the same problem as when upgrading servers: users are server specific, but permissions are databases specific. They are not bound by UserName, but through a SID (security identifier).

When adding the same UserName entries to a new server that already has the databases restored, you get error messages like these:

Error 21002 [SQL-DMO] User ‘account’ already exists

When adding the same UserName  entries, then restoring the databases, it won’t work, because the matching SIDs don’t exist.

There are many sites explaining the “Error 21002” and pointing to sp_change_users_login.

But sp_change_users_login (and the ALTER USER UserName WITH LOGINI = UserName2 in SQL Server 2005 and higher) is not the actual fix to the problem: it will re-add the user with a new SID, then correct the SID in the database currently in use.

Actually you are after “Orphaned” users: users that are defined in the various databases, but not present in the user list on the SQL Server instance. Running sp_change_users_login with the “Report’ parameter on the “new” server will show a list of orphaned users.

An even better way to show Orphaned Users is by running the ShowOrphanUsers script (thanks Vyas, wish more people republish your stuff with attribution!). In my own version (sourcecode is below), I have added an extra UserSID column of type varbinary(85).

In order to transfer users to a new server, you need a sp_help_revlogin stored procedure. Depending on the version of your SQL Server (7/2000/2005/2008), you need a slightly different version of a script that creates sp_help_revlogin for you. All versions are available at NetNerds.net.

–jeroen

via: Migrate/Transfer SQL Server 2008/2005/2000/7 Logins to SQL Server 2008.

USE master;
GO
IF OBJECT_ID ('dbo.ShowOrphanUsers') IS NOT NULL
  DROP PROCEDURE dbo.ShowOrphanUsers
GO
CREATE PROC dbo.ShowOrphanUsers
AS
BEGIN
	CREATE TABLE #Results
	(
		[Database Name] sysname COLLATE Latin1_General_CI_AS,
		[Orphaned User] sysname COLLATE Latin1_General_CI_AS,
                [UserSID]  varbinary(85)
	)

	SET NOCOUNT ON

	DECLARE @DBName sysname, @Qry nvarchar(4000)

	SET @Qry = ''
	SET @DBName = ''

	WHILE @DBName IS NOT NULL
	BEGIN
		SET @DBName =
				(
					SELECT MIN(name)
					FROM master..sysdatabases
					WHERE 	name NOT IN
						(
						 'master', 'model', 'tempdb', 'msdb',
						 'distribution', 'pubs', 'northwind'
						)
						AND DATABASEPROPERTY(name, 'IsOffline') = 0
						AND DATABASEPROPERTY(name, 'IsSuspect') = 0
						AND name > @DBName
				)

		IF @DBName IS NULL BREAK

		SET @Qry = '	SELECT ''' + @DBName + ''' AS [Database Name],
				CAST(name AS sysname) COLLATE Latin1_General_CI_AS  AS [Orphaned User],
                                SID AS [UserSID]
				FROM ' + QUOTENAME(@DBName) + '..sysusers su
				WHERE su.islogin = 1
				AND su.name <> ''guest''
				AND NOT EXISTS
				(
					SELECT 1
					FROM master..sysxlogins sl
					WHERE su.sid = sl.sid
				)'

		INSERT INTO #Results EXEC (@Qry)
	END

	SELECT *
	FROM #Results
	ORDER BY [Database Name], [Orphaned User]
END
GO

Posted in Database Development, Development, SQL, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | 1 Comment »

Should watch: Dave Herman: The Future of JavaScript #ECMAScript6

Posted by jpluimers on 2012/01/11

On:

Mozilla Labs engineer and TC39 representative Dave Herman joined us at YUIConf 2011 to give this keynote talk on the future of JavaScript, covering many of the new features currently under consideration for ES6, the next edition of the ECMAScript standard.

Many wonderful new features. Now it just need some great tooling.

–jeroen

via: http://www.youtube.com/watch?v=u4IdoBU1uKE

Posted in Development, JavaScript/ECMAScript, Scripting, Software Development | Leave a Comment »

great answer by Remy Lebeau on windows – CreateProcessAsUser doesn’t work when “change user” – on Stack Overflow part of @StackExchange

Posted by jpluimers on 2012/01/10

You might wonder why I quoted two great StackOverflow answers recently. Well, it is because I absolutely love the way that StackExchange.com and StackOverflow.com changed how to find quality answers (and questions!) on topics varying from programmers through Cooking to Chines Language Usage in a community based way.

This one is by Remy Lebeau, who is part of TeamB:

You don’t need to enumerate running explorer.exe processes, you can use WTSGetActiveConsoleSessionId() instead, and then pass that SessionId to WTSQueryUserToken(). Note that WTSQueryUserToken() returns an impersonation token but CreateProcessAsUser() needs a primary token, so use DuplicateTokenEx() for that conversion.

You should also use CreateEnvironmentBlock() so the spawned process has a proper environment that is suited to the user account that is being used.

Lastly, set the STARTUPINFO.lpDesktop field to ‘WinSta0\Default’ instead of nil so the spawned UI can be made visible correctly.

I have been using this approach for several years now and have not had any problems with it. For example:

… code sample is in the answer …

–jeroen

via: windows – CreateProcessAsUser doesn’t work when “change user” – Stack Overflow.

Posted in Delphi, Development, Software Development | 2 Comments »

Resetting the SMC solved my MacBook Air Fan Noise With Lion problem

Posted by jpluimers on 2012/01/09

This might have been caused by my MacBook Air haning itself one time during resume: I manually turned it off keeping the on/off switch pressed for 5+ seconds, then rebooted.

Anyway: over time I observed that the fan was running fast without much CPU/GPU/memory/disk activity.

Resetting the SMC like the answer below, followed by resetting the PRAM and NVRAM solved my issue.

I had exactly these issues with my new Macbook Air 13.  Having read this forum I downloaded istat pro and discovered that my fan was always running at over 4000 rpm and the top left part of my case was quite warm.  I then followed the instructions here…resetting the SMC and after this the problem was fixed!

–jeroen

via MacBook Air Fan Noise With Lion: Apple Support Communities.

Posted in Apple, LifeHacker, Mac OS X 10.7 Lion, MacBook, MacBook-Air, Power User | 1 Comment »

Alternate (offline) Google Chrome installer (Windows) – Google Help

Posted by jpluimers on 2012/01/06

Currently most software installers have a small bootstrap and during the actuall install will download only the files that are actually needed.

Often that is not convenient: slow or no network connection, repeated installs in a test environment, etc.

Luckily, a lot of software does have an offline installer (a.k.a. standalone installer).

Being no exception Google Chrome has two offline installers: one single user install, and one for all users on the same Windows machine.

It ends up at one of these download pages, each with a download link for the current version (which changes for every new version):

–jeroen

via: Alternate (offline) Google Chrome installer (Windows) – Google Help.

Posted in LifeHacker, Power User, Windows, Windows 7, Windows 8, Windows Vista, Windows XP | 1 Comment »

Great answer by Cosmin Prund: How and when are variables referenced in Delphi’s anonymous methods captured? – Stack Overflow

Posted by jpluimers on 2012/01/05

Every once in a while, by accident you stumble on a really great answer on StackOverflow.

Here is a quote from Cosmin Prund describing on how Delphi implements anonymous methods using a TInterfacedObject descendant:

When you have a function like the one in the question, where you have an anonymous method accessing a local variable, Delphi appears to create one TInterfacedObject descendant that captures all the stack based variables as it’s own public variables. Using Barry’s trick to get to the implementing TObject and a bit of RTTI we can see this whole thing in action.

Read his full answer for the complete description including sample code.

I stumbled on this great answer trough the question Is it possible for a managed local variable to transparently “travel to” another local scope? which might sound like an odd question, but it is not: StackOverflow is about learning, and some people do that by asking questions on solving problems in a very uncommon way, just to learn there are far better ways of obtaining what they want.

–jeroen

via: How and when are variables referenced in Delphi’s anonymous methods captured? – Stack Overflow.

Posted in Delphi, Development, Software Development | Leave a Comment »