Nov
14
Posted on 14-11-2005
Filed Under (JavaScript) by Johan Känngård

If you know the index of the element to remove, you could use the splice method, like this:


var a=['one','two','three','four'];
a.splice(1,1); // Removes 1 element from index 1
alert(a); // Results in 'one','three','four'


If you don’t know the index, but the value of the element, you could add a little method to the Array class like this:

Array.prototype.remove=function(s){
  for(i=0;i<this .length;i++){
    if(s==this[i]) this.splice(i, 1);
  }
}
var a=['one','two','three','four'];
a.remove('three');
alert(a); // Results in 'one','two','four'

(18) Comments    Read More   
Nov
11
Posted on 11-11-2005
Filed Under (LotusScript, Visual Basic, Windows) by Johan Känngård

I have tried to search for the literal values of some of the options to WinHTTP that handles SSL server certificates errors. In my case I have a development server that has a certificate with the wrong name in it, and I want to ignore the usual “The host name in the certificate is invalid or does not match” error. Since I am using LotusScript to access the COM class WinHTTP.WinHTTPRequest, I can’t simply use:


Dim http As Variant
Set http = CreateObject("WinHTTP.WinHTTPRequest.5.1")
http.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = 13056

This of course generates an error, since the WinHttpRequestOption_SslErrorIgnoreFlags constant can not be found in LotusScript.
The answer couldn’t be found anywhere on MSDN, but some searching on Google led me to a page at fastbugtrack.com with some code that contains the constant I needed! So here they are for future reference:

' WinHTTPRequest options:
Const WinHttpRequestOption_UserAgentString = 0
Const WinHttpRequestOption_URL = 1
Const WinHttpRequestOption_URLCodePage = 2
Const WinHttpRequestOption_EscapePercentInURL = 3
Const WinHttpRequestOption_SslErrorIgnoreFlags = 4
Const WinHttpRequestOption_SelectCertificate = 5
Const WinHttpRequestOption_EnableRedirects = 6
Const WinHttpRequestOption_UrlEscapeDisable = 7
Const WinHttpRequestOption_UrlEscapeDisableQuery = 8
Const WinHttpRequestOption_SecureProtocols = 9
Const WinHttpRequestOption_EnableTracing = 10

The actual value for http.Option(WinHttpRequestOption_SslErrorIgnoreFlags) that I have set to 13056 (hexadecimal 0×3300) is an addition of all switches found at the WinHttpRequestOption documentation at WinHttpRequestOption_SslErrorIgnoreFlags.

(4) Comments    Read More   
Nov
11
Posted on 11-11-2005
Filed Under (Windows) by Johan Känngård

I want to be able to work in the program I have open at the moment, and not being interrupted by other applications that want automatic focus. So I have used TweakUI quite a while. The problem is that some applications tend to overwrite the crucial registry settings with their own (read: steal focus ON).
To get around this, I now have a BAT file that is run whenever I log in:


@echo off
reg ADD "HKEY_CURRENT_USER\Control Panel\Desktop" /v 
ForegroundFlashCount /t REG_DWORD /d 0x00000000 /f > nul
reg ADD "HKEY_CURRENT_USER\Control Panel\Desktop" /v 
ForegroundLockTimeout /t REG_DWORD /d 0x00030d40 /f > nul

Note that there shouldn’t be a newline after the /v’s…
Put a shortcut to the BAT file in your Startup folder in the Start menu, and it will silently run whenever you login.
Thanks to Adrian that made me (and others?) aware of the reg command. This way, I don’t have to use a .REG file.

(7) Comments    Read More   
Nov
11
Posted on 11-11-2005
Filed Under (Music) by Johan Känngård

I really, really, really love this song by the Norweigan group Røyksopp!

(0) Comments    Read More   
Nov
08
Posted on 08-11-2005
Filed Under (Games) by Johan Känngård

I love F.E.A.R., not as much as Battlefield 2 or FarCry, but as a single player game, it is quite good. I haven’t played any “horror” game before (I always jumped when the small headcrabs in the first Halflife appeared…), but I love movies like The Ring and The Blair Witch Project, so why not combine a shooter with some horror elements? It actually works, I got frightened a few times already, and I haven’t played it that long.
The AI is quite good, the enemies don’t just run at you, but hides, regroups and sneak on your back, a bit better than in FarCry. Too bad that almost all environments are indoors, as I like both BF2’s and FarCry’s outdoor environments. Indoor enviroments tend to be a bit more linear, but I guess the game wouldn’t be as scary as it is, if it was put in an outdoor environment.
Information about tweaking the settings of the game can be found (as always) at Tweakguides.com.

(0) Comments    Read More