Archive for the ‘Uncategorized’ Category.

Sony Xperia connection problems

After much searching and head bashing, I finally got my Xperia to connect via USB.

Beyond doing all the normal stuff: rebooting the device, installing Sony’s PC Companion to get the latest drivers, still nothing worked. PC Companion would detect when the device was attached but wouldn’t connect.

This little tid-bit is the key, I had to flush the cache for their “MTP extension service

Go to:
Settings > Apps > All > MTP extension service > Clear data/cache

also stop the extension.

Bridging a WRT54G to a local hotspot (iphone) with DD-WRT

These instructions are geared to a mobile phone hotspot, but they should apply to most hotspots.

If you need to reset your router, unplug it for a few minutes, holding the reset button down plug the router in and continue to hold the button for at least 30 seconds.

  1. Connect to your router (192.168.1.1) and reset the user and password (you should be asked, if not do another hard reset)
  2. log in
  3. Go to “Wireless->Wireless Security” enable,
    1. set security mode “WPA2 Personal”
    2. select the WPA algorithm to match your hotspot in my case “TKIP+AES” and enter the password the corresponds to your hotspot
    3. save & apply
  4. Go to “Wireles->Basic Settings”
    1. set wireless mode: Client Bridge
    2. set the SSID to match your hotspot exactly
    3. save & apply
  5. On your phone you should see your WRT54G connection on your phone
  6. Go to “Security->Firewall”
    1. disable SPI Firewall
    2. Uncheck “Block Anonymous WAN request, Filter IDENT”
    3. save & apply
  7. Go to “Setup->Advance Routing”
    1. change “Operating Mode” to “Router”
    2. save & apply
  8. Go to “Setup->Basic Setup”
    1. set your Local DNS to a well known DNS server like Google’s 8.8.8.8

That should be it, you should now be able to connect to the Internet via any port on WRT54G

Note: that any machine that uses DHCP that is connected to your router will get a bridged network IP and will not be able to administer the router. To administer the router manually set your IP to 192.168.1.131 and you will be able to connect to the web administration console.

systemd – migrating from init.d

Since Fedor 16 systemd has replaced init.d (or tried to at least) and given the somewhat poor documentation you may require a bit of trial and error to integrate your init.d scripts with systemd.

Since Fedora 17 some of my startup scripts no longer function properly with systemd, hence the need to at least migrate to systemd (but not actually go native)

The other issue besides the documentation is that there are multiple ways to achieve the same thing which adds to the confusing documentation.

First you will need a systemd startup/shutdown script like the following, /etc/init.d/sample is a classic init.d script, that is, takes start/stop/restart command line arguments.

Create your sample.service file in /etc/systemd/system.

You’ll notice there is no “ExecRestart”, systemd’s creators think they’re smarter than you or I, so restart calls ExecStop and ExecStart in order. An alternative is to use the ExecReload if you have custom restart behaviour, sadly this is a departure from how things have been done in the past so you will have to use reload instead of restart when using systemctl.

/etc/systemd/system/sample.service

[Unit]
Description=Sample service
After=syslog.target network.target


[Service]
RemainAfterExit=yes
Type=oneshot
ExecStart=/etc/init.d/sample start
ExecStop=/etc/init.d/sample sto
ExecReload=/etc/init.d/sample restart


[Install]
WantedBy=multi-user.target

If your service depends on another service you add the dependency to the After clause, for instance: After=syslog.target network.target some.service

For running init.d scripts I use Type=oneshot which coupled with RemainAfterExit=yes means don’t kill the process group when finished.

To enable the service use: systemctl enable sample.service you can check /var/log/messages for any messages.

If you make any changes to your service files you must reload systemd using: systemctl --system reload

Starting your service: systemctl start sample.service
Stopping your service: systemctl stop sample.service
Status of your service: systemctl status sample.service
Restart your service: systemctl restart sample.service
Reload your service: systemctl reload sample.service

References:
http://www.freedesktop.org/wiki/Software/systemd/
http://www.freedesktop.org/software/systemd/man/systemd.service.html

VMWare Server 2 on Fedora Core 14

I gave up on Fedora Core 15 (for now)

Prerequisites:

Install Fedora, I use the Software Developer version with the Fedora Packager.

Unpack raducotescu-vmware-server-linux-2.6.3x-kernel-release-1.6-0-gbb26dce.zip, copy VMware-server-2.0.2-203138-update-2.patch into raducotescu-vmware-server-linux-2.6.3x-kernel-e26b34e, you can either overwrite the original vmware-server-2.0.2-203138-update.patch file or update vmware-server-2.0.x-kernel-2.6.3x-install.sh to use the patch-2 file.

Disable selinux

Update /etc/services so that 902 reads as follows:

vmware-authd    902/tcp

Create a link to the kernel headers:

ln -s "/usr/src/kernels/$(uname -r)" /usr/src/linux

Add UTS_RELEASE to /usr/src/linux/include/linux/version.h (see https://blog.tuinslak.org/vmware-server-and-kernel-2-6-33):

echo "#define UTS_RELEASE \"$(uname -r)\"" >> /usr/src/linux/include/linux/version.h

Finally run Radu’s script giving it the directory of your vmwarer server 2.0.2 archive.

./vmware-server-2.0.x-kernel-2.6.3x-install.sh /PATH/TO/VMware-server-2.0.2-203138.x86_64.tar.gz

If all goes well you will have completed your install without error.

A couple of final cleanup issues you will need to rename libxml2.so.2 for vmware to something else (see http://communities.vmware.com/message/1670144#1670144)

mv /usr/lib/vmware/lib/libxml2.so.2/libxml2.so.2 /usr/lib/vmware/lib/libxml2.so.2/SKIP.libxml2.so.2

And finally update /etc/init.d/vmware script so it starts after networking has properly started, the default configuration doesn’t do this on my machine.

Update the chkconfig line to read:

# chkconfig: 35 35 20

Make sure the init scripts are properly linked:

chkconfig --del vmware
chkconfig --add vmware
chkconfig --level 35 vmware on # for good measure

Reboot your machine.

Depending on your configuration you may also have to update your iptables rules.

Outlook is a massive POS

This is why the machines will never win the coming Judgement Day, Microsoft Outlook and circular logic 101:

The e-mail address for the sender (ABC@theYYYgroup.com) is internal to your organization and cannot be added to the Safe Senders list. E-mail from senders in your organization will never be treated as junk e-mail.

  1. So the email from the internal sender was flagged as junk
  2. And the sender cannot be added to the white list because the sender is internal
  3. If the sender is internal and always trusted how did the email get flagged as junk.
  4. Reductio ad absurdum

Doesn’t Microsoft test their software?

Solving the Android R.java problem

R.java is one of the most annoying things I’ve come across recently. If you want to create and deploy multiple android apps from the same source, it must be done with each app having a unique package name, and there in lies the rub. A unique package name means a unique R.java with the same package name for each instance, but your source want’s to use a single R.java, and you certainly don’t want to be changing all your source to update the package name every time you release a different version of your app, for example a free trial vs. the paid version.

So the solution is to create two R.java files, one with your internal package name and the other with the package name of the release which comes from AndroidManifest.xml, at this point I would point out that you should probably generate your AndroidManifest.xml.

To generate the required R.java files, you must customize the Google Ant build scripts,  copy android_rules.xml from the SDK into your project. The second exec stanza generates the internal R.java which you specify with the property “package.internal”

<!-- Generates the R.java file for this project's resources. -->
 <target name="-resource-src" depends="-dirs">
 <echo>Generating R.java / Manifest.java from the resources for ${package.destination}</echo>
 <exec executable="${aapt}" failonerror="true">
 <arg value="package" />
 <arg line="${v.option}" />
 <arg value="-m" />
 <arg value="-J" />
 <arg path="${gen.absolute.dir}" />
 <arg value="-M" />
 <arg path="AndroidManifest.xml" />
 <arg value="-S" />
 <arg path="${resource.absolute.dir}" />
 <arg value="-I" />
 <arg path="${android.jar}" />
 <arg value="--custom-package" />
 <arg value="${package.destination}" />
 </exec>

 <echo>Generating R.java / Manifest.java from the resources for ${package.internal}</echo>
 <exec executable="${aapt}" failonerror="true">
 <arg value="package" />
 <arg line="${v.option}" />
 <arg value="-m" />
 <arg value="-J" />
 <arg path="${gen.absolute.dir}" />
 <arg value="-M" />
 <arg path="AndroidManifest.xml" />
 <arg value="-S" />
 <arg path="${resource.absolute.dir}" />
 <arg value="-I" />
 <arg path="${android.jar}" />
 <arg value="--custom-package" />
 <arg value="${package.internal}" />
 </exec>        
 </target>

In your build file, tweak the android setup as follows

<setup import="false" />
<import file="${basedir}/build/android_rules.xml"/>

import false says don’t use the standard android_rules and the following import references your custom rules.

A good reference, but didn’t go far enough: http://java.dzone.com/articles/building-two-versions-same?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+javalobby/frontpage+(Javalobby+/+Java+Zone)

Java Code Coverage

I haven’t done an exhaustive analysis by any stretch of the imagination, but after trying out EMMA – http://emma.sourceforge.net/ and Cobertura – http://cobertura.sourceforge.net/index.html

The clear winner is Cobertura for the following reasons:

  • Ant targets are easier to use and don’t generate errors in Intellij (a minor thing but highly annoying)
  • It is much easier to exclude test classes
  • The output generated is vastly superior if not more voluminous
  • Better but still sparse documentation

Sun’s Java VisualVM

VisualVM is an interesting tool, and the fact you don’t have to instrument your applications to use it is rather nice. Real-time monitoring of you application is very nice and the ability to take snapshots or heap dumps is also very useful, but their heap analysis tool needs some work.

Compared to some other heap analysis tools I’ve used VisualVM needs a lot of work. Having said that being able to take heap dumps as you manipulate a system in real-time is very useful, and then using another analysis tool seems like the best option (note I haven’t tried using another analyzer with visualVM’s heap dump.)

Technical Details has moved…

As we’ve been slowly winding down BlogMatrix for sometime, I decided to move my own blogs to my own domain and server. Having access to everything allowed me to write a BlogMatrix to WordPress converter.

I also had the relevant addresses redirected to my server, so techdetails.blogmatrix.com -> techdetails.agwego.com, which posed an issue with respect to permalinks, so with a little WordPress hacking I was able to write a pseudo BlogMatrix to WordPress permalink converter so most links will now work as expected. I have a complete duplicate site setup at home replete with DNS for testing purposes.

I’m still getting use to WordPress but so far it’s not too bad.

My other blog http://dinner.agwego.com/