If you think it’s easy to deal with RSS read this:
inessential.com: Brian’s Stupid Feed Tricks.
It reminds me so much about handling StUF.
–jeroen
Posted by jpluimers on 2013/03/20
If you think it’s easy to deal with RSS read this:
inessential.com: Brian’s Stupid Feed Tricks.
It reminds me so much about handling StUF.
–jeroen
Posted in Development, HTML, HTML5, SOAP/WebServices, Software Development, StUF, Web Development | Leave a Comment »
Posted by jpluimers on 2013/03/19
When porting some communications code that used records as properties from Delphi 2006 to Delphi XE2, I came across a tightened compiler error “E2197 Constant object cannot be passed as var parameter“.
Let me first explain the good old occurrence of E2197 with some code that uses my last Variant Records example:
Just look at TPacket.InitializePacket and TPacketBase.InitializeFPacket: Basically even though the Packet property has storage specifiers indicating it directly reads from a field and directly writes to a field, you cannot pass it as a var parameter in the FillChar method.
Of course you can with a field, you can pass it to FillChar without trouble as TPacketBase.InitializeFPacket shows. Read the rest of this entry »
Posted in Delphi, Delphi 2006, Delphi XE2, Delphi XE3, Development, Software Development | 3 Comments »
Posted by jpluimers on 2013/03/13
Every once in a while I manage to check “Automatically close on successful compile” during compilation, the compiler progress disappears, and I loose my clue if compilation ended or not.
This is how to fix it:
–jeroen
via: Embarcadero Newsgroup Archive :: embarcadero.public.delphi.ide :: Re: D2006 compiler progress.
Posted in Delphi, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | 7 Comments »
Posted by jpluimers on 2013/03/12
Few people know about a Delphi language feature that has been present since Delphi 1: prepending the type definition with a type keyword to make the type getting a new identity.
Each time I use it, I have to do some browsing for the consequences, and this time I wrote down some notes and created a small example program (source is also below).
This time I needed it when writing class wrappers on top of the Delphi bindings for WebSphere MQ.
WebSphere MQ has Queues where you can put and get messages. It also has Queue Managers to which you connect, and that provide queuing services and manages queues.
Both Queues and Queue Managers have names that can be up to 48 (single byte) characters long.
Those names mean totally different things, so though the have similar data types, they have a different identity.
The same holds for 20 byte character arrays (they can be used as names for ChannelName, ShortConnectionName and MCAName). The 264 byte character array is so far used for ConnectionName only.
Distinguishing those types: That’s what “type types” in Delphi are all about. Read the rest of this entry »
Posted in CP437/OEM 437/PC-8, Delphi, Delphi 1, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Development, Encoding, Shift JIS, Software Development, Unicode, UTF-8, UTF8 | 1 Comment »
Posted by jpluimers on 2013/03/06
Great post on what you can do with the Immediate Window: Dot Net Tips & Tricks , C# (C Sharp)Tips & Tricks: Visual Studio Immediate Window.
It is far more than you’d expect on first sight.
The really good thing: this Immediate Window gem has been there for over a decade (:
–jeroen
Posted in Development, Software Development, Visual Studio 11, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2013/03/05
It starts to be not so funny any more: almost every week a new Java security update.
Time to update again, to stay secure and install the patch: Security Alert CVE-2013-1493.
On the funny side: Java 0day countdown.
–jeroen
Posted in *nix, Apple, Development, Java, Mac OS X / OS X / MacOS, Mac OS X 10.4 Tiger, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, OS X 10.8 Mountain Lion, Power User, Software Development, Windows, Windows 7, Windows 8, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP | Tagged: java security, new java, security alert, software, technology | 2 Comments »
Posted by jpluimers on 2013/03/05
I’ve been working at a client where they have hardened most of their systems in a not so programmer friendly way. One of the things you cannot to is start RegEdit, not even for viewing. Since I need Fiddler2 to poke through their Internet Proxy in order to get access to an external TFS server, and their machines often reboot due to maintenance cycles, sometimes my proxy settings are dead. This tiny app shows you how to get display your proxy settings, demonstrating:
Enjoy! (Note, you could have done this with PowerShell in a very easy way too, as it access the Registry just like it was a file system).
When using Fiddler, it shows output like this:
AutoConfigProxy=wininet.dll ProxyEnable=1 MigrateProxy=1 ProxyHttp1.1=1 ProxyOverride=<-loopback> ProxyServer=http=127.0.0.1:8888;https=127.0.0.1:8888;
One of the drawbacks of Registry work is that you need to dispose of your keys. That is handled inside ReadOnlyAccessToRegistryKey.Run which also handles your Code Access Security. This means that the lambda expression (could just as well have been an anonymous method) can just concentrate on the LINQ stuffreturning an enumeration of anonymous types. You need the ‘let’ portion if you also want to perform ‘where’ on the values.
using System;
using System.Collections.Generic;
using System.Linq;
using BeSharp.Win32;
using Microsoft.Win32;
namespace LinqToRegistryShowProxySettings
{
class Program
{
static void Main(string[] args)
{
try
{
run();
}
catch (Exception ex)
{
Console.WriteLine(ex);
throw;
}
}
static void run()
{
const string internetSettingsKey = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
ReadOnlyAccessToRegistryKey.Run(Registry.CurrentUser, internetSettingsKey,
registryKey =>
{
var keyValues = from name
in registryKey.GetValueNames()
//let keyValue = new { key = name, value = registryKey.GetValue(name).ToString() } // only if you need the Value in the Where, as it created for all occurences
where
name.Contains("proxy", StringComparison.OrdinalIgnoreCase) ||
name.Contains("autoConfig", StringComparison.OrdinalIgnoreCase)
select new { key = name, value = registryKey.GetValue(name).ToString() };
foreach (var keyValue in keyValues)
{
Console.WriteLine("{0}={1}", keyValue.key, keyValue.value);
}
}
);
}
}
}
This manages the Code Access Security since you will access the registry readonly. It also disposes the RegistryKey instance. The Code Access Security access and revert must be in the same method, so you cannot create a class that does the Assert in the constructor, and the dispose in the Disposer.
using System;
using Microsoft.Win32;
using System.Security.Permissions;
using System.Security;
namespace BeSharp.Win32
{
public class ReadOnlyAccessToRegistryKey
{
public static void Run(RegistryKey hiveRegistryKey, string subKeyName, Action action)
{
string fullKeyName = hiveRegistryKey.Combine(subKeyName);
RegistryPermission readRegistryPermission = new RegistryPermission(RegistryPermissionAccess.Read, fullKeyName);
readRegistryPermission.Assert();
try
{
using (RegistryKey registryKey = hiveRegistryKey.OpenSubKey(subKeyName))
{
action(registryKey);
}
}
finally
{
CodeAccessPermission.RevertAssert();
}
}
}
}
Extensions for the Registry:
using System;
using Microsoft.Win32;
namespace BeSharp.Win32
{
public static class RegistryExtensions
{
// Hives: http://en.wikipedia.org/wiki/Windows_Registry
public readonly static string HKCC = Registry.CurrentConfig.Name;
public readonly static string HKCR = Registry.ClassesRoot.Name;
public readonly static string HKCU = Registry.CurrentUser.Name;
#if Obsolete
[Obsolete]
public readonly static string HKDD = Registry.DynData.Name;
#endif
public readonly static string HKLM = Registry.LocalMachine.Name;
public readonly static string HKPD = Registry.PerformanceData.Name;
public readonly static string HKU = Registry.Users.Name;
public static string Combine(this string keyName, string subKeyName)
{
string result = string.Format(@"{0}\{1}", keyName, subKeyName);
return result;
}
public static string Combine(this RegistryKey registryKey, string subKeyName)
{
string result = registryKey.Name.Combine(subKeyName);
return result;
}
public static string Combine(this RegistryKey registryKey, RegistryKey subRegistryKey)
{
return registryKey.Combine(subRegistryKey.Name);
}
//http://stackoverflow.com/questions/444798/case-insensitive-containsstring/444818#444818
public static bool Contains(this string value, string substring, StringComparison stringComparison = StringComparison.CurrentCulture)
{
int index = value.IndexOf(substring, stringComparison);
bool result = (index >= 0);
return result;
}
}
}
–jeroen
Posted in .NET, .NET 4.0, .NET 4.5, C#, C# 4.0, C# 5.0, Development, PowerShell, Scripting, Software Development, Visual Studio 11, Visual Studio 2010, Visual Studio and tools | 2 Comments »
Posted by jpluimers on 2013/03/01
A few links I came across recently:
–jeroen
Posted in About, Development, Encoding, EPS/PostScript, Font, internatiolanization (i18n) and localization (l10), Personal, Power User, Programmers Font, Software Development, Unicode | Leave a Comment »