Monday, February 28, 2011

openVPN, SliceHost, and OSX

Spent some time at the local coffee shop today, and got really paranoid about others sniffing my wireless bytes...  so I spent the whole visit setting up openVPN on my slicehost.

I found a good guide on the internet, but had to make some modifications to get it to work.

I am currently using the Viscosity openVPN client for osx: http://www.thesparklabs.com/viscosity/

Here is the guide that I used: http://ggin.com/blog/openvpn-setup-on-vps/

Modifications:

(I didn't build it from source)

cp -R /usr/share/doc/openvpn/examples/easy-rsa /etc/open/vpn

Should be:

cp -R /usr/share/doc/openvpn/examples/easy-rsa /etc/openvpn

When he says to do: ./vars I had to do source ./vars first.

Before doing:

sudo cp /usr/share/doc/openvpn/example/sample-config-files/server.conf /etc/openvpn/

I had to gunzip the server.conf.gz file and the path should actually be:
/usr/share/doc/openvpn/examples/sample-config-files/

For IPTables rules I used:


sudo vim /etc/iptables.test.rules
*nat
-A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
COMMIT
*filter
-A INPUT -i tun+ -j ACCEPT
-A FORWARD -i tun+ -j ACCEPT
-A FORWARD -o tun+ -j ACCEPT
-A INPUT -p udp --dport 1194 -j ACCEPT


.. and that was basically it! Just make sure to use the right files when setting up Viscosity:

CA ca.crt
Cert username.crt
Key username.key

(I don't have User/Pass authentication enabled in the client)

Wednesday, February 23, 2011

HDF5: Fixed length strings

For the sake of Google searches - here is a bit of code on how to create compound data types with fixed length strings in HDF5 H5 files.


/**
* Create the H5 file with the contents of the Data list.
*/
public Boolean create() {
try {
FileInfo h5 = new FileInfo(this.h5Path);

H5FileId fileId = null;
if (this.makeNew) {
fileId = H5F.create(h5.Name, H5F.CreateMode.ACC_TRUNC);
H5F.close(fileId);
}
fileId = H5F.open(h5.Name, H5F.OpenMode.ACC_RDWR);

H5DataTypeId stringMeasurand = H5T.copy(H5T.H5Type.C_S1);
H5T.setSize(stringMeasurand, (uint)MEASURAND_LENGTH);

H5DataTypeId stringChannel = H5T.copy(H5T.H5Type.C_S1);
H5T.setSize(stringChannel, (uint)CHANNEL_LENGTH);

H5DataTypeId tid1 = H5T.create(H5T.CreateClass.COMPOUND,(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(dictStruct)));
H5T.insert(tid1, "Measurand", 0, stringMeasurand);
H5T.insert(tid1, "Rate", MEASURAND_LENGTH, H5T.H5Type.NATIVE_FLOAT);
H5T.insert(tid1, "Channel", MEASURAND_LENGTH+sizeof(float), stringChannel);

// Rank is the number of dimensions of the data array.
const int RANK = 1;
ulong[] attributeDims = new ulong[RANK];
attributeDims[0] = (ulong)data.Count;

H5DataSpaceId spaceId = H5S.create_simple(RANK, attributeDims);
H5DataSetId dataSetId = H5D.create(fileId, "/foo",
tid1, spaceId);

H5D.write(dataSetId, tid1, new H5Array(data.ToArray()));
H5T.close(tid1);

H5D.close(dataSetId);
H5F.close(fileId);

return true;
} catch(Exception ex) {
Console.WriteLine(ex.Message);
return false;
}

return true;
}



/**
* Create a new struct with the specified measurand information.
*/
private unsafe dictStruct addRow(string measurand, float rate, string channel) {
dictStruct retval = new dictStruct();

byte[] mBytes = System.Text.Encoding.ASCII.GetBytes(measurand);
byteCopy(mBytes, retval.measurand,MESSAGE_LENGTH);


retval.rate = rate;

byte[] channelBytes = System.Text.Encoding.ASCII.GetBytes(channel);
byteCopy(channelBytes, retval.channel, CHANNEL_LENGTH);


return retval;
}


And then how you define your struct:


public const int MEASURAND_LENGTH = 16;
public const int CHANNEL_LENGTH = 12;

[StructLayout(LayoutKind.Sequential, Pack=1)]
public unsafe struct dictStruct {

public fixed byte measurand[MEASURAND_LENGTH];
public float rate;
public fixed byte channel[CHANNEL_LENGTH];

}

Sunday, February 20, 2011

What a week for my poor poor Jeep

How many people get their vehicle broken into and rear-ended in the same day?  Well, there's at least one..

I know that I live in a sketchy area for work (Lancaster, CA).  Because of that I usually leave NOTHING inside the jeep, and even leave the doors unlocked.  (Thinking that if they see the doors are unlocked, they won't slash my soft top to gain access to the inside of my vehicle)

My jeep has an after market stereo - and I ALWAYS take the head unit inside with me every single night - except for this one time.  I had been driving the jeep for the last few days, and was really getting tired of bringing everything in at night (and bringing everything back out in the morning), so I decided to just leave the headunit in the (locking) center console of my jeep.  Mistake.

Woke up early on February 16th I saw that the center console of the jeep was wide open, and a few of my random car/electronic manuals were sitting on the passenger seat.  They did it.  They had pried open the center console with a screwdriver (I assume).  I don't imagine it was difficult, the center console is pretty cheap, but still it had to take some effort.

I did not do a complete inventory, but it looks like they walked away with:

  • Stereo head unit

  • Car charger

  • Car dock

  • mini stereo cable

  • caffeinated mintes.  (really? you took my mints??)


Didn't bother calling the police, since it was likely < $100 worth of theft and they took so god damn long to show up the last time one of my cars got broken into.

So the day is off to a great start... and naturally I have a horrible day at work, where nothing works, and nothing works in my favor.

This day also happens to be the last day of work for one of my coworkers. (Who is working at another location)  I had planned to meet him and my other coworkers at a restaurant for a going-away dinner.  It was rainy, the roads were slickish, and I was stopped in traffic at a stop light.  I heard the tires screeching, I heard a metal on metal bang behind me, and then I felt my Jeep being pushed from behind.  I moved a grand total of a foot, threw the e-brake and the hazards, and got out.



Behind me was a rather destroyed looking black Jetta (attached to my rear bumper), and behind her was an old lady driving a CrownVic.

Just when I didn't think the day could get any better, I became the lead car in a three car pile up.

As you can see in the picture to the right, not much damage occurred to the jeep, just a dent under the license plate.  (You can also see a bit of her car still embedded in my bumper!)  I called 911 and they promptly had firetrucks, ambulances, and a CHP officer at my location within 10 minutes.

Have you ever dialed 911 on an Android phone (or even a smart phone) before?  I certainly haven't.  I was surprised to see that Android locks out all data connections for 5 minutes after an "Emergency Call" has taken place, to allow 911 to call you back.  Pretty neat.

The CHP officer collected all of our information, and eventually let me go while he dealt with the severely damaged vehicles.

What a day.

I think I will gladly fork over that additional $80 a month for a garage in my Lancaster apartment now... at least it will give me peace of mind while sleeping at night.

I want to say thanks to TrailGear for their excellent bumper - I can only dream of what sort of damage would have occurred to the rear of my jeep otherwise (still have to bring the jeep to a mechanic to see if the frame has been compromised in anyway).

Thursday, January 20, 2011

Android: Automating Emulator Actions

When testing Android apps in the Android Emulator you often have to trigger multiple events by hand that a real phone would do on its own for a given "real" event, like plugging in a power cable.

Simulating a power cable being connected to the emulator requires two separate events,
power status charging

and
power ac on

To interact with the android emulator you telnet into it to get an interactive shell - which enables you to send all sorts of commands to it.  Typing in commands like the above over and over to simulate a power cable being connected is annoying at best.

On OSX I have written the following python scripts to enable the condition(s) I want with a single command.

#!/usr/bin/python
import telnetlib
tn = telnetlib.Telnet("localhost",5554)
tn.write("power status charging\r\n")
tn.write("power ac on\r\n")


Save that guy as "power_on.py" in your android-sdk/platform-tools directory - and any time you want to simulate the power cable being connected simply type:
power_on.py

... and for an added bonus here is my power_off script:

#!/usr/bin/python
import telnetlib
tn = telnetlib.Telnet("localhost",5554)
tn.write("power status discharging\r\n")
tn.write("power ac off\r\n")

Wednesday, January 12, 2011

Fun with the SwiftKey Trial for Android

SwiftKey is a 3rd party keyboard for Android that features "AI driven auto complete".

Strangely, it seems to offer suggestions for your "next" word when typing, even if you haven't typed anything at all - so I decided to keep accepting the automatically predicated words until it stopped suggesting them.

Here is what it ultimately typed out for me:
Minimize the last few years ago, I am a beautiful person, but I think I put 79,,,,

Nice!

Saturday, January 08, 2011

Eclipse 3.6 Helios and SVN

Upgraded from Eclipse 3.5 to 3.6 today (blazing fast in OSX finally) and found that my SVN plugin didnt work.

Follow the instructions here to fix: http://www.dingobytes.com/tutorial/subversion-install-for-eclipse-helios-3-6

Android: Introducing BatteryUptime Pro

Pro version of the popular Battery Uptime widget!

Keeps track of the time your Android phone is unplugged.  Records your best run time.  (Same as Settings->About Phone->Battery), and charts your battery uptime over the course of the last 30 days.

Pro version of widget also features the ability to refresh more often than every 30 minutes!

Pro version of widget also features a quick way to navigate to the Android System Battery Stats straight from your homescreen!

After installing the widget, connect your phone to AC power and then remove from AC power to start tracking battery uptime.

lightning-iconPro version of the popular Battery Uptime widget!

Keeps track of the time your Android phone is unplugged.  Records your best run time.  (Same as Settings->About Phone->Battery), and charts your battery uptime over the course of the last 30 days.

Pro version of widget also features the ability to refresh more often than every 30 minutes!

Pro version of widget also features a quick way to navigate to the Android System Battery Stats straight from your homescreen!

After installing the widget, connect your phone to AC power and then remove from AC power to start tracking battery uptime.

Available in the Android Marketplace for $0.99

qrcodescreenshot_config
screenshot_chart

Saturday, November 27, 2010

Android: Hacking the lock screen with LiveWallpapers

Toying with making a LiveWallpaper that can display your Google Calendar info (and other goodies) on the lock screen when the phone is locked, and only displaying your wallpaper when the phone is unlocked.

Screen shot 2010-11-27 at 11.27.08 AM

Wednesday, October 20, 2010

DoublePost for Android 1.1


  • Removed Ads!

  • Fixed lots of bugs: Restoring text when hiding app, receiving phone calls, rotating phone

  • New UI colors. Still looks like crap, but I am working to improve it

Tuesday, October 19, 2010

Smart Phones Anonymous

Starting today, I am going to see how long I can go without a smart phone.  My goal is to last till next Monday.. in the mean time I will only be using my work provided cell phone (an LG Vx550).

Wish me luck...

Sunday, October 03, 2010

Android: Introducing DoublePost for Android

I frequently find myself posting an update to Twitter, realizing my genius and creativity, and then posting the same exact message to Facebook.  (After fumbling around in various Android applications to copy and paste).
screenshot2
Twitter for Facebook lets anyone with a public account sync their twitter status to their Facebook status.  That works great, except it only works for public accounts!  Folks (like me) with private accounts need not apply...

Of course various Twitter applications, and web services offer to simultaneously post to Twitter and Facebook, but I dont feel like changing Twitter clients or giving my Twitter and Facebook credentials to a 3rd party website.

DoublePost for Android lets me control which messages I post to both services, and keeps my account credentials safe in my possession.

Available on the Android market for FREE today (ad supported).

qrcode
Quick application to simultaneously post status updates to Twitter and Facebook.

Do you repeatedly post something to twitter, only to use the same status to update Facebook later?

Why give your account information to a third party? DoublePost uses the built-in account verification of both Twitter and Facebook.

Thursday, September 02, 2010

Android: BatteryLastUnplugged 1.3 (renamed to BatteryUptime)

First, a little bit of an Android Developer PSA: Do not lose the private key used to sign your app during your first publication! This key is needed to continuously sign your application before uploading to Google. Keep it backed up..

I am rather embarrassed that I did indeed lose my private key, and there is no way to recover from this.  You have to rename your application, resign with a new key, and reupload to google =(qrcode

Changelog:

  • New slightlier less ugly widget design

  • Code improvements necessary to introduce stats in the next update.

  • Achievement messages! Will show a toaster dialog when you bet your average and best times.



Tuesday, August 24, 2010

Android: Shush 1.4

Version 1.4

- Start on boot

- Fixed notification sticky

- Turned off debug logging

Version 1.4

- Start on boot

- Fixed notification sticky

- Turned off debug logging

- Additional code cleanup

Sunday, August 15, 2010

Android: Introducing Shush

Shush will reduce your ringer and notification volume when your screen is on (who needs to have the volume be super loud when you are right in front of your phone anyway?) and then return the volume to normal when your screen is off.

screenshot2
screenshot1

Available in the Android Market for free.


qrcode

Friday, August 06, 2010

Android: Introducing Baseball Season Standings 2010

Polished widgets for each of the major league teams that show current standings in their conference. - Standing - Score - Games back


Future updates will include wild card standings, overall conference standing widget, and playoff standings.




qrcode
screenshot

Also available in "Mini" for only $0.99!



qrcode
screenshot1



Monday, August 02, 2010

Android: MLB Standings (Preview)

So folks have been commenting on how blatantly ugly my first Android widget is.  I agree.  Its horrible.

But only because I have been focusing every little ounce of creative energy into this widget (Coming Soon!):

mlbstandings_1.0_preview

Pretty cool for all the baseball fans out there :)

Saturday, July 31, 2010

Android: BatteryLastUnplugged V1.2 Released

There was a really nice bug in the first release that would prevent your best unplug time from being saved and displayed.  Unfortunately I went on a whirlwind vacation to the east coast for a week and was unable to publish V1.2 (that hopefully fixes this bug).

Additionally, if the widget crashes (or stops responding) when you install the update, try the following:

- Uninstall widget, and reinstall widget

- Uninstall widget, restart device, reinstall widget.

BatteryLastUnplugged 1.2 is available in the Android Market today.

Monday, July 19, 2010

Introducing: Battery Last Unplugged (Android)

My first public Android application, so be gentle...

I am always very paranoid about my battery usage on my smart phones.  I am constantly checking the Battery settings screen on my Android phone that shows battery usage, and the time since it was last unplugged.

Screen shot 2010-07-19 at 10.37.24 PMSo over the course of a few days here and there, I threw together a simple Homescreen Widget:

Screen shot 2010-07-19 at 5.15.58 PMThe first line is the current AC status of the device (Discharging/Charging).  The second line is the current time since being unplugged, and the last line is your best run time since being unplugged.

I would like to implement more features, such as recording all of your unplugged times and plotting them.

Available in the market for free:

Thursday, March 25, 2010

What does your Droid look like?

Discovered Helix Launcher recently, it seems to be an excellent free replacement to the stock launcher.  Just as speedy, but lets you add dock-like shortcuts to the bottom of the screen.

CAP201003231322



Now if only RemeberTheMilk didn't have a super ugly widget...

Thursday, March 11, 2010

My Top 5 Android Applications

Here are my top 5 android applications and widgets (two separate lists).  In an effort to spread the word about some lesser-known power-user apps, I will try to exclude everyone's favorites, such as RememberTheMilk and WeatherBug.

Applications


1 Handcent


Handcent is a replacement for the stock "Messaging" application on Android.  It literally has too many feature to list, but some of my favorites:

  • Can customize notification options on a per contact basis, and even set custom vibrate settings

  • Can skin to your hearts content

  • Can reply inline to incoming text messages

  • Can quick-compose a text message from within ANY android application


2 SayMyName


SayMyName is a nice little random utility that will speak the name of the incoming caller when receiving a new phone call.  It is overlaid with the ringtone that is being played, but in my experience that is not much of a problem.  You can have it just say the persons name, or configure what it says, such as "Incoming Call from %first% %last%".

3 Gentle Alarm


GentleAlarm is a sort-of a replacement for the Clock application.  In my opinion the stock Clock application is severely lacking in the alarm feature, coming from using an iPhone as a dedicated alarm clock for almost two years.

Once you get past GentleAlarm's rather HORRIBLE user experience, it is easily the best alarm application I have ever used.

  • dock support

  • sleep-cycle optimized to you wake up during light sleep (optional)

  • music, playlists, ringtones

  • silent alarm for school/work

  • very smooth onset of alarm

  • night display

  • flip to snooze

  • optional flightmode at night


4 KeePassDroid


I use KeePassX on my Macbook Pro to track all of my important account information.  KeePassDroid allows me to carry that information with me everywhere on my phone.  Definably a must for me and my smart phone.

5 twicca


I really don't spend much time using Twitter anymore, but twicca seems to be the best currently available twitter app for Android.  It looks great, and covers all of the basic features perfectly.

Widgets


1 Agenda Widget


The stock "Calendar" widget that comes with Android sucks.  What I needed was an agenda style widget that doesn't look like crap.  "Agenda Widget" fits the bill rather perfectly.


2 Power Control Widget (root required)


A widget that gives you quick access to toggling bluetooth/wifi/3g, comes with a rooted ROM.


3 Battery Time Lite Widget


This widget gives you a little battery icon showing remaining juice, but it also places the battery percentage into your notification bar.