Monday, August 30, 2010
Apple Wireless Keyboard on Windows [AppleKeyboardInstaller.exe]
The solution is install the keyboard driver provided by Apple in the Bootcamp package. The driver I use is from a OS X Leopard installation disc.
Or download it here: http://www.happytocode.com/post/Apple-Aluminium-keyboard-Boot-Camp-20-Windows-drivers.aspx
PS: After I found the solution myself, I had the correct google search term and solutions older than my keyboard. But it works.
UPDATE:
The keyboard driver sometimes leads to Bluescreens, so I am back using the standard windows drivers without the additional keyboard shortcuts.
Friday, August 6, 2010
Credit card: Visualize your money
We argued about "real" money as physical and credit cards as non-physical example. The advantages of real money are that you see what you have and you can only spend that. The advantages of the credit card are that the payment is easier and payment via internet is possible.
The main disadvantage is that you as user can't see how much money you spend or you have available. The card looks always the same.
Assume that materials are available that could either shrink or change it's color. Using this the credit card will get smaller if you pay with it and slowly reach your limit. Or the card could get orange if are in reaching line of credit and red if your are in.
Thus you as user would "feel" how much money is available and it is much easier to cope with the abstraction from real money.
PS: Only an experiment in mind.
Monday, June 14, 2010
Windows shell (cmd) and loops
DO FOR %g IN (1,2,3,4,5,6,7,8,9,10) DO ECHO %t %g
Hopefully I have never to use the windows shell again!
Monday, March 29, 2010
JSF 2.0: Mojarra and multipart/form-data (File Upload) [Glassfish]
The following wrapper extends a HttpServletRequest so that getParameter also uses available data in HttpServletRequest.getParts().
You can than access the HttpServletRequest via
FacesContext.getCurrentInstance().getExternalContext() and use getParts own your own.
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.Part; /** * The mojarra implementation does not parse POST request that are multipart encoded, * because the parameters are not accessable viagetParameter()
. * * This class extends the HttpServletRequest to provide access to the parameters * which are encoded accessable viagetParts
. * * All parts are made visible that havecontentType == null && size < 300
. * * If the request is not multipart encoded, the wrapper doesn't modify the behavior of the originalHttpServletRequest
. * @author dennis */ public class MultipartHTTPServletRequest extends HttpServletRequestWrapper { protected MapparameterParts = new HashMap (); public MultipartHTTPServletRequest(HttpServletRequest request) { super(request); if (getContentType() == null) { return; } if (!getContentType().toLowerCase().startsWith("multipart/")) { return; } try { for (Part i : getParts()) { if (i.getContentType() == null && i.getSize() < 300) { parameterParts.put(i.getName(), getData(i.getInputStream())); } } } catch (IOException ex) { Logger.getLogger(MultipartHTTPServletRequest.class.getName()).log(Level.SEVERE, null, ex); } catch (ServletException ex) { Logger.getLogger(MultipartHTTPServletRequest.class.getName()).log(Level.SEVERE, null, ex); } } private static String getData(InputStream input) throws IOException { String data = ""; String line = ""; BufferedReader reader = new BufferedReader(new InputStreamReader(input)); while ((line = reader.readLine()) != null) { data += line; } return data; } @Override public String getParameter(String name) { String result = super.getParameter(name); if (result == null) { return parameterParts.get(name); } return result; } }
Saturday, March 20, 2010
Java Servlet (3.0): How can I access multipart encoded content provided by a http post request?
I had three problems:
1. How to upload a file via HTML?
2. How to access the data at the server side?
3. How to put in the database using JPA?
The first one was easy, just create a html form add a input field (type='file') and a submit button.
The second one cost me one day. And it was really simple: Just place the @MultipartConfig annotation at the class definition of the servlet and use HTTPRequest.getPart[s]() methods to access the data as an inputstream.
The last part was straight forward: use a InputStreamReader to copy the data into a byte[] and add @Lob byte[] field to the entity class.
Because I use MySQL it was necessary to change the columnt type from TEXT to MEDIUMBLOB.
Sunday, February 7, 2010
Java: CDI & ConversationScope
I used Glassfish v3.
... Post my pom.xml tomorrow again.
Sunday, November 15, 2009
Goodbye 85.214.89.182 (g00se.org)
Tonight they will come and cut him off.
To keep him in memory old.g00se.org points to his former home adress.
Windows 7: Share your internet uplink via wireless ad-hoc network (ICS)
You have one windows 7 device with a direct internet connection like UMTS and you won't to share the connection via an ad-hoc wireless network with another device. In my case it is a XDA neo.
Everything happens in the Network and Sharing center.
- Properties section of the network device with the uplink:
under sharing active ICS and re-connect the device to internet
- Create a new ad-hoc network (use encryption!)
- Join with another device the network
- Set the wireless ad-hoc network location to "Home"
- Disconnect from the ad-hoc network and rejoin (device with uplink)
Monday, June 1, 2009
Ubuntu-vm-builder default login
I booted one machine (ubuntu jaunty VM) and used the password reset procedure to get a running root shell. In the passwd I found a user ubuntu. I rebooted and used ubuntu:ubuntu as credentials.
Default username: ubuntu
Default password: ubuntu
Thanks to NO documentation and man pages for ubuntu-vm-builder... Addon:
The packet is named python-vm-builder. See also https://help.ubuntu.com/community/JeOSVMBuilder.
Sunday, May 10, 2009
CSS cheat sheet
SQL cheat sheet
HTML cheat sheet
PHP cheat sheet
Monday, May 4, 2009
Power consumption of the internet
Sunday, January 25, 2009
SIP client for Windows (using ekiga SIP service)
Microsoft itselfs provides a SIP client (netmeeting). The developer of Ekiga provides a nice howto.
Monday, January 12, 2009
Getting DBUS Messages from Networkmanager (Python)
#!/usr/bin/python from dbus.mainloop.glib import DBusGMainLoop import gobject import dbus import subprocess def signal_deviceNowActive(data=None): if data is not None and data[dbus.String("State")] == 2 : subprocess.Popen("ps -C pidgin || pidgin &", shell=True) subprocess.Popen("ps -C ekiga || ekiga &", shell=True) subprocess.Popen("ps -C evolution || evolution &", shell=True) print "init loop" DBusGMainLoop(set_as_default=True) loop = gobject.MainLoop(); print "init dbus" dbus.SystemBus().add_signal_receiver(signal_deviceNowActive, signal_name=None, dbus_interface="org.freedesktop.NetworkManager.Connection.Active") print "start loop" loop.run() //UPDATE: thanks for your comment
Tuesday, December 30, 2008
Cort Dougan: Good Programmers are Not Lazy
Saturday, July 12, 2008
Book: Domain-Driven Design (Eric Evans)

The first one he suggests is a "ubiquitous language". In short he says that all people connected to the project should use the same language, so that everyone can talk to everyone about the domain. That is not about technical stuff or infrastructure. It is mere that all know all what the software should / will be used to.
It's a quite good book with well choosen practical examples and it helped to understand that real development differs from educational stuff in a sense of organization, time and size. It would have been helpful, if I read it earlier.
Saturday, June 14, 2008
Lecture: Open Wins – the Future of Software & Technology (Scott McNealy, SUN)
The essance of the talk was:
Open Source is good (not only code, also products [specifications])
reducing the dependency between the developer and the user
programmers improve their code style (someone else can read your stuff)
Strategy of SUN
He anwsered the question why SUN is doing open-source
Interesting points:
Java
happens transparently (ref: mobile phone and blue-ray players)
is running on 6^9 devices (hope I got it right)
Oracle Enterprise Edition costs 400.000 $ per core(!)
Cool quotes:
"Free is the new black!"
"Return on no-investment."
"Steal software legally"
"We don't want you to do .NET! Watch your hands!"
Provided links during the talk:
Netbeans.tv: the community site of Netbeans.
Solaris Express Developer Edition (SXDE) A developer edition of solaris with many tools
All in all I can say that Scott is a really good entertainer. It was a really nice talk!
Thanks to Prof. Brandenburg for the information.
Monday, May 26, 2008
JTree on an JScrollPane and resizing
It was about an JTree on a JScrollPane. The model of the will be modified during runtime and fires events if something is changes. So far everything looks pretty straight forward and it works.
The problem occured if the tree gots larger than the parent scrollpane, so I believed the scrollpane starts to activate the scrollbars and everything stays cool... But the tree never changed it's size. It simple stayed in the old size and the scrollpane didn't start scrolling. And so some items of the tree were invisible.
TreeModel model = new DefaultTreeModel(); JTree tree = new JTree(model); tree.setPreferredSize(new Dimension(100, 100)); JScrollPane pane = new JScrollPane(tree);The model fires an TreeModelEvent (DefaultTreeModel.nodeStructureChanged) and the tree get's an JTree.treeDidChange() so it can recompute it's size.
This doesn't work out. It was necessary to set the preferred size of the tree to null before excecuting treeDidChange...
Why? I honestly don't know...
Wednesday, March 26, 2008
VOIP for GNOME Desktop: Ekiga
At last: sip:500@ekiga.net is a echo service, so you can test your configuration. Next week I will try to get my bluetooth headset running.
Tuesday, January 29, 2008
JAX-WS: ORA-31011
Now the trouble started:
The URL from the Oracle HTTP-Server is secured via HTTP-Authentification. Ok so I downloaded the WSDL and created the stubs from a local file with the JDK's wsimport. Now I needed to tell the Webservice Client Provider to authenticate if necessary:
ORAWSVPortType port = new ORAWSVService().getORAWSVPort();
Map<String, Object> requestCtx = ((BindingProvider) port).getRequestContext();
requestCtx.put(BindingProvider.USERNAME_PROPERTY, "user");
requestCtx.put(BindingProvider.PASSWORD_PROPERTY, "password");
The first test ended with a desaster:
Exception in thread "main" java.lang.IllegalArgumentException: faultCode argument for createFault was passed NULL
at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl.createFault(SOAPFactory1_1Impl.java:56)
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:108)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:254)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:224)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:117)
at $Proxy32.xmlFromQuery(Unknown Source)
at productcatalogws.Main.main(Main.java:49)
Java Result: 1
I couldn't make anything useful out of these messages. The only thing I found was a dead end: bug_id=6587659.
So I started debugging:
First view the SOAPMessages:
I used the cool charles proxy.
Configuration for JAVA:
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", "localhost");
System.getProperties().put("proxyPort", "8888");
After viewing the messages without noticing anything of interesst except:
ORA-31011: XML parsing error, but without any reference to the Webservice.
I found a cool tool to use webservices: soapUI (you can do everything I needed using it!!) and queried the Oracle Webservice by hand. And it worked!
The problem was that the default JAX-WS Provider does send:
Content-Type: text/xml;charset="utf-8"
And the Oracle HTTP Server expects:
Content-Type: text/xml;charset=UTF-8
An example SOAPMessage (including the header):
Authorization: Basic XXXXX
Host: localhost:8080
Content-Length: 314
SOAPAction: "http://localhost:8080/orawsv"
User-Agent: Jakarta Commons-HttpClient/3.0.1
Content-Type: text/xml;charset=UTF-8
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oraw="http://xmlns.oracle.com/orawsv">
<soapenv:Header/>
<soapenv:Body>
<oraw:query>
<oraw:query_text type="SQL">SELECT * FROM PRODUCT</oraw:query_text>
</oraw:query>
</soapenv:Body>
</soapenv:Envelope>
The questions are:
Does JAX-WS something wrong during the request or is the DB Webservice the bad guy?
And why doesn't JAX-WS handle the SOAPfault correctly?
Used software:
javac --version:
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)Oracle 11G DBMS:
Oracle Database 11g Release 1 for 32-bit Windows.
Tuesday, January 1, 2008
OpenSSH using Kerberos via GSSAPI
- g00se.org uses Kerberos for authentification.
- Kerberos offers Single-Sign-On.
Cyrus and Exim4 authentification using Kerberos via GSSAPI
The necessary cyrus-sasl libaries were already installed. So I really don't know which are exactly required. I suppose the cyrus-sasl gssapi libary should meet all requirements. I needed to install the exi4-daemon-heavy instead of the light one. The the heavy one does support authentification using the cyrus-sasl libary.
I created the principals imap/g00se.org and smtp/g00se.org and put them into the default keytab.
And modified the configuration files of both services to let them propose GSSAPI as alternate authentification mechanism:
(cyrus): imapd.conf:
sasl_mech_list: PLAIN GSSAPI
and
(exim4): [/etc/exim4/conf.d/auth/01_exim4-config_gssapi]
gssapi_server:
driver = cyrus_sasl
public_name = GSSAPI
server_mech = gssapi
server_hostname = g00se.org
#server_realm = G00SE.ORG
server_set_id = $auth1
.ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
.endif
Thanks to Sean for a short and easy description.
PS: Exim4 does use the splitted configuration file option of Debian. So you can put the lines anywhere into the authentification section.
Apache with Kerberos authentification
Here is the small configuration:
Krb5Keytab /etc/apache2/krb5.keytab
KrbAuthRealms G00SE.ORG
KrbServiceName HTTP
<Directory /x>
AuthType Kerberos
Require valid-user
</Directory>
That's all! Cool.
The Firefox bundled into my OpenSUSE 10.3 does already contain all necessary configurations. I only needed to add g00se.org to network.negotiate-auth.trusted-uris in about:config. So he does accept the offer to do GSSAPI authentification with these URIS. And that's pretty cool. At least I need to figure a way to get my M$ system use such cool stuff.
Sunday, December 2, 2007
Exim4 and Saslauthd [service=]
Wednesday, November 21, 2007
JOptionPane and the Focus
Wednesday, October 31, 2007
WebSVN vs. ViewCVS
Monday, August 20, 2007
Java Base64 encoding (sun.misc.Base64Encoder)
This class seams to work quite all right for some weeks. So, today we transfered our JEE server from a linux to windows (not my idea). Till now I have assumed that the mythos of the JAVA plattform independence is not only a myth. During the check of the application (the deployed JEE project) it showed up error messages that the base64 coded strings doesn't match.
On the first look everything seemed to be fine. The second showed up that the strings on the windows machine were one (!) character longer. Two hours later we found the problem: Does RFC 3548 say something about line feeds and carriage return?
So why does the base64 coded strings contain some?
The anwser is: Because the encode method of the Base64Enconder split the string after some characters (I suppose at char 76 / 77, but I'm not quite sure). So if you switch the operation system and the new system uses another encoding for the line break, your old base64 encoded data is worthless.
To solve this problem I used the java mail api (cause JEE server needs to implement these):
StringOutputStream output = new StringOutputStream(); OutputStream encoding = MimeUtility.encode(output, "base64"); encoding.write("Hello World"); result = output.toString();
import java.io.IOException; import java.io.OutputStream; /** * * @author Dennis Guse * */ public class StringOutputStream extends OutputStream { private StringBuffer data = new StringBuffer(); public StringOutputStream() {} public String toString() { return data.toString(); } public void write(int b) throws IOException { data.append((char)b); } }So a half day of work for nothing....
PS: Feel free to use this stuff.