Dear IBM,
thank you for this beautiful example of the non-avoidance of double-negatives in brillant interface design of Lotus Notes:
P.S.: If someone could explain what that message actually meant, that would be great!
Ideen
Monday, December 30, 2013
Thursday, September 8, 2011
Auto Desktop Background VBS Script
I was searching for this for quite a bit to get this super easy task right, so here it is. Based on some code I found on some place on the web.
Simply download a set of nice desktop backgrounds on the web, put them all in one folder and then create a vbs file with the following content in this folder. Make sure to change strFolder=... in the top to your desired folder.
Filename: randomdesktop.vbs
When executed, the script will select a random file from the folder specified and set it to the desktop background. I have placed it it my startup folder and now I have a new desktop image every day. :-)
Simply download a set of nice desktop backgrounds on the web, put them all in one folder and then create a vbs file with the following content in this folder. Make sure to change strFolder=... in the top to your desired folder.
Filename: randomdesktop.vbs
Option Explicit
Dim WshShell, oFolder, intNumber, strValue, i, oFile, strFolder, intFolders, intFiles, serialIndex, sleepTime, serialFolder
strFolder = "d:\tools\bg\"
Set WshShell = WScript.CreateObject("Wscript.Shell")
Set oFolder = WScript.CreateObject("Scripting.FileSystemObject").GetFolder(strFolder)
serialIndex = 0
intFiles = oFolder.Files.Count
intFolders = oFolder.Subfolders.Count
Randomize
intNumber = Int((intFiles + intFolders) * Rnd) + 1
If intNumber > intFiles Then
sleepTime = 10
serialIndex = 1
i = intFiles
For Each serialFolder In oFolder.Subfolders
i = i + 1
If i = intNumber Then Exit For
Next
i = 0
For Each oFile In serialFolder.Files
i = i + 1
If i = serialIndex Then Exit For
Next
Else
sleepTime = 10
i = 0
For Each oFile In oFolder.Files
i = i + 1
If i = intNumber Then Exit For
Next
End If
If oFile.Path <> strValue Then
strValue = oFile.Path
End If
Set oFile = Nothing
WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", strValue
WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, False
Set WshShell = Nothing
Set oFolder = Nothing
When executed, the script will select a random file from the folder specified and set it to the desktop background. I have placed it it my startup folder and now I have a new desktop image every day. :-)
Tuesday, August 16, 2011
Java ProxySelector, useSystemProxies and new Socket() = Malformed reply from SOCKS server
When you want to easily configure your java application to use the systems proxies and you do a little research on google, you will find some code snippets that look pretty much like this (from http://stackoverflow.com/questions/376101/setting-jvm-jre-to-use-windows-proxy-automatically):
System.setProperty("java.net.useSystemProxies", "true");
System.out.println("detecting proxies");
This works fine, as long as you only use it to determine the System proxy for URLConnections.
However simply opening a new Socket with a command like this
Socket tunnel = new Socket("192.168.1.101", 8080);
fails with an exception if the above code has been executed before:
java.net.SocketException: Malformed reply from SOCKS server
at java.net.SocksSocketImpl.readSocksReply(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
In my case, I was using apache axis (axis1) which I had to use because my webservice only supported the rpc/literal SOAP encoding. After looking into this issue for a while, I found the solution in the piece of code from above. It appears java.net.Socket always uses a proxy when a default ProxySelector is set.
I am unsure of why this happens, but what fixed the issue for me was to set the default proxy selector to null after I retrieved the system proxy with the above code:
ProxySelector.setDefault(null);
System.setProperty("java.net.useSystemProxies", "true");
System.out.println("detecting proxies");
List l = null;
try {
l = ProxySelector.getDefault().select(new URI("http://foo/bar"));
} catch (URISyntaxException e) {
e.printStackTrace();
}
if (l != null) {
for (Iterator iter = l.iterator(); iter.hasNext();) {
java.net.Proxy proxy = (java.net.Proxy) iter.next();
System.out.println("proxy hostname : " + proxy.type());
InetSocketAddress addr = (InetSocketAddress) proxy.address();
if (addr == null) {
System.out.println("No Proxy");
} else {
System.out.println("proxy hostname : " + addr.getHostName());
System.setProperty("http.proxyHost", addr.getHostName());
System.out.println("proxy port : " + addr.getPort());
System.setProperty("http.proxyPort", Integer.toString(addr.getPort()));
}
}
}This works fine, as long as you only use it to determine the System proxy for URLConnections.
However simply opening a new Socket with a command like this
Socket tunnel = new Socket("192.168.1.101", 8080);
fails with an exception if the above code has been executed before:
java.net.SocketException: Malformed reply from SOCKS server
at java.net.SocksSocketImpl.readSocksReply(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
In my case, I was using apache axis (axis1) which I had to use because my webservice only supported the rpc/literal SOAP encoding. After looking into this issue for a while, I found the solution in the piece of code from above. It appears java.net.Socket always uses a proxy when a default ProxySelector is set.
I am unsure of why this happens, but what fixed the issue for me was to set the default proxy selector to null after I retrieved the system proxy with the above code:
ProxySelector.setDefault(null);
Subscribe to:
Posts (Atom)