Theme finished (mostly)

So I have finally gotten to a point where I am happy with the way the website looks. All in all, I spent somewhere between 20 and 30 hours building and tweaking the theme over the past week or so. My primary goal from the start was to have a clean, simple theme that scaled well across different screen resolutions. With this in mind, and with the help of the Bones framework, I have made a theme that I think looks beautiful at any screen resolution. For small displays, it collapses the navigation menu into a hidden area that expands and contracts with a menu button. For slightly larger resolutions, the navigation menu is constantly visible, with a similar style for the main post area as the mobile view. For larger screens with a horizontal resolution above 1100 pixels, the posts on the main page become condensed into small, card-like containers that can be expanded by pressing a “Read More” link. Further, each individual post page has a similar background to the main page, appearing as if the post is a piece of paper over a gray cloth background.

The most difficult part of this whole process lies in the JavaScript code. It was difficult to get it to do exactly what I wanted it to do without bugs, and so took plenty of tweaking to get just right. I’m hoping with the way I implemented JavaScript that the website still works perfectly fine without it, but I need to test that further. Almost all of the visual parts of the theme are built with CSS and HTML, with only some extra features being handled by JavaScript. Further, I haven’t tested on older browsers, specifically IE 7-9. I’m hoping to do that shortly, but I’m not entirely worried about those browsers due to the kinds of users I think visit the site. As it’s a fairly technical blog, the viewers are likely running more modern browsers. Either way, I will test it at some point.

I’ve been trying to think of a good name for the theme. So far, I haven’t really decided on one, but the color scheme reminds me of watermelons. I may just end up naming it something relating to watermelons as a result.

Read More

Redesigning the Site with Bones

I have decided to explore building my own theme for the site. Previously, I had one built on top of PaperPunch, and more recently used the default Twenty-Thirteen theme. Both of these themes are clean, but I have decided to build my own.

I was reading a post on /r/web_design about starter themes for WordPress. Through this thread, I found out about Bones, an HTML5, mobile-centric theme base. Themes are built by modifying LESS files and compiling them into the relevant CSS. The process for building the CSS is fairly straight forward.

So far, I have built a good bit of the base of the theme, but it’s not quite where I want it yet. There’s a good chance that the design will change greatly over the coming weeks. Depending on the success of this, I may consider using Bones to redesign my girlfriend’s blog and my Guild Wars 2 site.

Read More

Analyzing Twitter Feed Data for Subjectivity and Polarity

Recently, I became aware of the TextBlob library. This library is built on top of the Natural Language Toolkit. This library allows you to analyze text for “part-of-speech tagging, noun phrase extraction, sentiment analysis, classification, translation, and more” (per the documentation page). The features that really interested me were the ability to analyze text for both its subjectivity as well as its polarity (how positive or negative the text is). For example, a statement such as “The Earth is round” is a neutral statement (neither positive or negative) and is entirely objective. On the other hand, a statement such as “I love you” or “I hate you” is neither objective or neutral (one is very positive, one is very negative). The library allows you to analyze these statements to provide numerical basis for how neutral and objective these statements are.

I came up with the idea to utilize this library to analyze individual’s Twitter feeds. This provides a method to know, on average, how objective or subjective and how positive or negative an individual is when posting statuses on Twitter. So, I wrote a python script using Tweepy to analyze a user’s individual subjectivity and neutrality. The source code itself can be found on my github here.

The script is pretty simple. You pass in a consumer key and secret (given by registering for an API key on the Twitter dev pages,) as well as a user name to analyze, a maximum tweet count to look at, and whether or not to include retweets. The script will look through all of the tweets of the selected user (up to 800, which is limited by Twitter’s own API) and will show the average polarity and subjectivity. It also shows the most positive and negative tweets, as well as the most subjective and objective tweets. A tweet with a subjectivity value of 0.0 is considered to be very objective, while a tweet with a subjectivity of 1.0 is considered to be very subjective. Similarly, the polarity ranges from -1.0, very negative, to 1.0, very positive. I have included an example of the output from analyzing @macklemore‘s tweets.

Average Polarity of Tweets: 0.151289301423
Average Subjectivity of Tweets: 0.347877407229
Most Negative Tweet: I picked the wrong night to drink 2 energy drinks.... Can't sleep. Can't wait. LETS GO!!!!!!! #seahawks
Most Positive Tweet: Leonardo blocking out the haters. He can't see you. My best friend. #pals #animals&me #fox #vintageGǪ
Most Objective Tweet: Seahawks plane headed to NYC.....TURN UP!!!!!!! #superbowl #seahawks
Most Subjective Tweet: SEATTLE... I'm pumped to announce that for our Key Arena show on the 11th we're bringing out Sir Mix-AGǪ

As you can see, Macklemore is slightly positive in all of the tweets he has made. Further, his tweets lean towards being objective, rather than subjective. You can read his most positive and negative, and most objective and subjective tweets for fun, if you’d like. If the results seem potentially inaccurate, it’s because they use the built-in language data for analyses. TextBlob can be trained with custom input to improve results. In this instance, the most negative tweet returned by the script doesn’t actually seem all that negative. Further training could alleviate this.

This script could be expanded to further use cases, such as analyzing the average polarity and subjectivity directed towards a user, or the average subjectivity and polarity of a hashtag. It’s fairly simple at the moment, but the results themselves are interesting nonetheless. Please, feel free to analyze your own Twitter feeds and discover something about how you tweet!

Read More

A Word on Drawing with WPF

One of the more interesting applications of WPFs powerful graphics capabilities, at least to me, is it’s use in creating a powerful image manipulation and general purpose drawing application.  I have been working on an application like this myself.  One of the first features I wanted to implement was a basic version of the paintbrush tool like that found in Photoshop.  Microsoft has an example project that supports multi-touch painting on their website.  One problem with this example, however, is that it is terribly, terribly slow.  Eventually, the app slows to a crawl as the complexity of drawings on the screen increase.  This was a huge problem when you’re trying to make a high performance application.  So, I set about trying to see what I could do to fix it. 

The answer itself lies in using a StreamGeometry instead of a PathGeometry.  The PathGeometry actually contains a StreamGeometry inside, but it also has other bits that make it’s performance sub-par compared to a StreamGeometry.  The problem with using a StreamGeometry is that it can’t render while you have it’s DrawingContext open.  What this means is that you either can choose to wait until mouse / touch up to close the stroke and render the entire thing at once, or you can break the strokes down into much smaller pieces by creating a new one on mouse / touch move.  I decided to go with the second option because I didn’t particularly like not knowing what I was drawing until I lifted my finger / mouse button. 

At this point, I had a performant drawing application that suffered from no visual slowdowns no matter how much was drawn on the screen, but there was another issue.  This issue is that there were gaps between the individual strokes and they looked awful.  I didn’t right away know what was causing them, so I decided to try a few different things.  My first course of action was to try adding multiple points to a list and draw all of the points in the list at once, rather than going by two points at a time.  So I tested by storing five points at a time and drawing them.  Now my strokes were longer, but the gap still existed between different strokes.  This lead me to the conclusion that I needed to overlap the strokes a bit in order to remove the gap, as using a start point and end point wasn’t really working too well. 

What I ended up doing was adding a variable to keep track of a midpoint.  On mouse down, set the start point and mid point to the current mouse location.  On mouse move, set the start point to the mid point, the mid point to the end point, and the end point to the new mouse location.  Draw the line segment at that point.

This produces a smooth line and removes visible gaps.  There is still some issue when using a semi-transparent color, but it’s not a big enough issue that I would worry about it.

I hope this is helpful.

As an aside, this is my first time writing a post from my TF300T (Asus Transformer Pad), so I apologize if I missed any grammar or spelling issues.  I’ll hopefully remember to proofread this later.  If necessary, I can provide some code examples to assist anyone who may be interested.

Until next time,

Also, since I can, I might as well include random images with my tablet-typed blog posts:

Read More

Android’s MapView with Interactive Overlays

A member of reddit asked a question on /r/androiddev. I figured I would help him out by writing a blog post on the issue.

Android’s MapView allows developers to get use Google Maps rather easily as a View in their project. More documentation can be found on MapView here and here. You will need an API key in order to use MapView. Click here to get one.

I currently utilize MapView in my GPS Fog of War application (that I haven’t worked on in forever). In GPSFoW, I have an Overlay item that you can click on to see current latitude and longitude information. I am going to briefly go over how to implement MapView and get Overlays working in your own Android app.

The first necessary item you will need is a class that extends MapActivity. In GPSFow, I also implement LocationListener, so my view can get GPS information directly. I won’t cover that in this post.

So, make a new class with this header (call it whatever you want).


    public class Map extends MapActivity

Great! So now we have a Map class that is all set to handle a MapView with overlays. There’s one problem, however. We don’t have an Overlay yet! So before we get any further, let’s make an Overlay class.

import android.content.Context;
public class MapOverlay extends ItemizedOverlay
    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>(); // this holds the overlays that are added to this overlay.
    private Context mContext; // this holds the context of this overlay, which is the MapView
    public MapOverlay(Drawable arg0, Context context)
         mContext = context;

    // adds an overlay to our internal list of OverlayItems
    public void addOverlay(OverlayItem item) {
    protected OverlayItem createItem(int i) {
        return mOverlays.get(i);

    public int size() {
        return mOverlays.size();
    // removes a specified overlay from our internal OverlayItems
    public void removeOverlay(OverlayItem item) {
    private ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

    protected boolean onTap(int index){
            OverlayItem item = mOverlays.get(index);
            AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
            return true;
        catch (Exception ex)
            Context context = mContext;
            CharSequence text = ex.toString() + " ID = MapOverlay onTap"
            int duration = Toast.LENGTH_LONG;
            Toast toast = Toast.makeText(context,text,duration);
            return false;

So, that’s the gist of the MapOverlay class. It’s a good chunk of code, and I’ll try to explain what everything does. The constructor takes a Drawable that represents the Overlay and and context so Android knows where to place the Overlay. ItemizedOverlays allow touch events to occur on them, and so are a perfect object to use in an overlay that needs to handle touch events. populate() ends up being very important, as the application crashed whenever I didn’t have this piece of code in.

Internally, the class holds onto a bunch of OverlayItems internally. While I’ve never really had more than one at a given time, it’s feasible to place multiple OverlayItems into the single Overlay class. They will share the same Drawable as whatever was passed to that particular instance of MapOverlay. For the sake of having multiple different Drawables, I would suggest having multiple MapOverlays instead of multiple OverlayItems inside a single MapOverlay class. The add and remove functions just allow me to specifically remove an overlay item in my Map class.

The real meat and potatoes here is the Overriden onTap function. This is where you can put code to interact with the Overlay when you touch it on the map. In GPSFoW, I set the OverlayItems to have the latitude and longitude as the title and something really basic as the body and show that in the onTap through an AlertDialog. This is where you will put whatever you want to occur when the user touches the Overlay.

Okay, so now to actually implement the thing. Let’s go back to our Map class. We need to add the MapOverlay to it and then add some things to interact with to the map!

public class Map extends MapActivity
    // some things we need throughout the class
    MapView mapView; // the actual MapView where all the cool things happen!
    List<Overlay> mapOverlays; // the overlays contained on the MapView
    Drawable drawable1; // the drawable of the MapOverlay (since you have multiple MapOverlays, we want more than one of these).
    Drawable drawable2;
    MapOverlay mapOverlay; // the first MapOverlay
    MapOverlay mapOverlay2; // the second MapOverlay

    public void onCreate(Bundle savedInstanceState) 

         setContentView(; // I have defined a "map" layout in my resources. I'll go over this later
         mapView = (MapView) findViewById(; // in your .xml for your resources, you need to define a MapView item. I'll go over this later
         mapView.setBuiltInZoomControls(true); // I'm guessing you want zoom controls
         mapOverlays = mapView.getOverlays(); // Get the overlays from the mapView
         drawable1 = this.getResources().getDrawable(R.drawable.androidmarker); // These are images that I have in my project. Change these as necessary
         drawable2 = this.getResources().getDrawable(R.drawable.busmarker);
         mapOverlay = new MapOverlay(drawable1, this); // initialize and add the overlays to mapView
         mapOverlay2 = new MapOverlay(drawable2, this);

Now, I have a bunch of other code in GPSFoW related to actually obtaining and processing location data from the GPS and Coarse Network Location. I haven’t included that here, as it makes the process more involved. Let me know if you want help with this too.

On to the resources I said I would get to later.

I have a map.xml in my layout folder:

<FrameLayout xmlns:android="" android:id="@+id/map" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">

    < android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="FILL YOUR KEY IN HERE"/>

    release key: android:apiKey="This is where I keep my release key, for easy access (different than the debug key, keep that in mind)"/>

I really hope this was helpful. If you need any additional help or are confused, please let me know and I’ll do my best to assist you. For anyone reading this, if you see mistakes, please let me know. I hate spreading false / inaccurate information or otherwise dangerous (unsafe) code. Thanks guys!

Read More

WordPress Mobile Application

I just installed a mobile application that lets me post to my blog from my phone.  Now I can post things on the go, which is most of the time.

School and work take up a ton of time so no work has been done on GPSFoW for about two months.  It’s still on my mind and I will finish it eventually.  I really need to write the site code too, maybe I’ll use Dart.  It looks like a decent language. 

Until next time.

Read More

Oh look, a blog post!

I know I haven’t been posting here all that often, but life has been busy as usual.  Work combined with a general lack of sleep makes my motivation towards working on the project diminished at best.  I forced myself to get some work done today, and I have done a decent bit.  First, I’d like to talk about an awesome tool I found that will help other developers

So, what is this tool?

The tool is called BugSense.  I signed up a while ago, but completely forgot about it until I saw a post on Reddit.  It’s a free service that lets developer add a single line of code to their main activity to keep track of user’s application crashes.  The download is a small .jar that is included in the application build path.  So far, I have used it to fix three crashes in the past thirty minutes.  The link to learn more is:

Back to the app

I have written a good chunk of code today that isn’t yet implemented anywhere, but should make it possible to get a bunch of things done all at once.  The code is all related to storing data on the external storage, checking whether or not the user has access to their external storage, loading and saving files, and generating images.  Essentially, all of the code is a baseline that will allow me to generate the fog.  I still have a good bit of code to write with relation to the database storage stuff.  I also fixed the bugs I talked about earlier.

My lovely girlfriend was kind enough to make a new icon for me that I have integrated into the application itself.  It looks much better than the placeholder icon I had before.  Thanks babe!

After rereading the Google Maps API Terms of Service, I found that I need to write a privacy policy that informs users just what kind of data I will be collecting from them.  None of the information will be personally identifiable.  I will probably work on this next, just so I can get it out of the way.

I also found out that mobile applications on the Android market are exempt from some of the not-so-nice ToS.  Reading them made me happy.

Immediate Plans

I’m probably going to refactor some of the code so it’s more suited for OOP development.  Afterwards, I will relax and watch some Samurai 7.

Until next time.

Read More

Progress Updates on GPS FoW

I realize I haven’t posted any status updates in quite some time, so I’m going to fill everyone in on what I’ve been up to.



The past few weeks have been rather busy for me.  This has directly affected the amount of time I have spent working on the application.  Two weeks ago, my girlfriend came to visit for the week.  I felt it would be improper to work on the application while she was visiting.  The following week, I traveled to Nag’s Head with my friend and his family.  I worked slightly on the website and set it up while I was at the beach, but only fixed a few bugs in the current code and didn’t add anything new.  My girlfriend then visited for a few more days.  I’m now completely free of delays and will be getting back to work.

Website / Server

I’ve been having some issues getting some database code to work the way I want it to.  I’m not sure exactly what the problem is, but I think it involves either permissions issues on my database user account, or issues with the way I’m trying to connect to the database from my script.  This is a rather large issue, as I need to have the database code in place before I release an alpha, or the places people have traveled won’t be able to fit into my master design plan and they’ll have to restart.  I don’t want that, because there’s a chance people will go on a trip to a distant location while testing the alpha.

Design Ideas

I’ve been debating on whether or not I want to use Google’s Maps API or something different.  I had my eyes on using OpenStreetMaps; however, the developers of OSM recommend that I host the map tiles myself.  If I were to do this, it would take a large amount of space on the server (I think about 250 GB or so).  It also means that in the event that this application ever catches on, the server would get blasted with map tile requests.  This would slow down the server for everyone actually using the website portion of it.  I could opt to use Amazon’s S3 or something, but then that’s more money out of my pocket that I don’t want to spend until the application pays for it.

I’m also trying to figure out exactly what the best method of doing the fog part of the application is.  I’m debating on storing various zoom levels as image files on the user’s SD card versus some other method of generation.  It’s something I’ll have to play around with and hopefully not tie the choice and the rest of the application together wholly, or I’ll have to rewrite lots of code in the future (possibly).


I have figured out what I’m going to name the application, but I’m withholding it for the time being until I actually have a release out.  My girlfriend is going to help with the graphical assets that I need.  I have all of the necessary things in place to put the application on the market when the time comes.  One thing I’ll have to look at in the near future is localization.  I would like to have the application available in as many languages as possible, but I’ll have to see how hard that will be.

That’s really it for now.  I’m going to work on the fog part of the application and then work on implementing the speed and elevation code.  The elevation part will be more time consuming as I need to find a database to use that contains the various elevation values of different locations.  This may or may not ever be implemented, depending on how adversely it affects the performance of the application and the user’s battery life and data consumption.  I’m going to try my best to make the application use as little resources as possible.

Read More

New Website!

This will be the new location of my blog. I will be using this website in the future to host applications I write and to talk about any development endeavors I make. It gives people a place to go when they need to find out information about anything they might use that I had something to do with. All of the posts before this one are old, but have been updated slightly to reflect some changes I’ve made with the new site.

Read More

Android GPS game and possible site move

Android App

I have been working on an app/game for Android that involves the GPS.  The idea is that it will uncover areas as you explore them, similar to a fog of war effect found in most RTS games.  I haven’t gotten the fog of war part down yet, but I now have a little android guy who follows you around based on your GPS location.  Thus far, it hasn’t crashed from enabling/disabling GPS, so that’s good.  I’ve had a very small amount done on the app for a while, but was prompted to get back to work when I saw this post on reddit.  I made another thread on reddit about the app and got much more feedback than I had anticipated.  The only problem is that some other people are now possibly working on the app, so if I do want any marketing advantage, I have to be quick about it.  I won’t go into detail about what exactly I plan to implement, but I am hoping the features will give it an edge.  Here are some screenshots:

The picture with the blur effect going on it just so I could hide my location from unsavory characters who might happen upon this blog.  I really hope no one gets confused and thinks it’s the fog of war effect.  The picture that is all red is red due to a filter I have for nighttime phone usage so I don’t hurt my eyes in the dark.  It happened to be late when I took that screenshot.

Site move

A kind individual at reddit liked the idea of this app, so he offered some hosting on a server he pays for but doesn’t really use.  Along with that, I bought my own domain for the year.  I couldn’t think of what to call it, so it’s just There’s not any site there yet, but hopefully will be in the coming days/weeks.  It will be the main site for anything I develop, on Android or otherwise.  I’ll probably set up a subdomain called at some point.  I will also probably set up a wordpress blog there too and just import these posts.

Read More

An interesting tidbit about C# 3.0’s Bitmap.GetHIcon()

The Problem At my place of employment, I have been tasked with cleaning up code and fixing bugs on some software that we are trying to pass around as a beta.  The application involves a large amount of GDI+ through C#’s System.Drawing namespace.  One of the things we were doing with this was to change the cursor whenever the user was placing an image on the form.  This worked pretty well, unless the user were to rapidly place images, at which point a generic error (thanks for the helpful description, Microsoft) would occur in GDI+ in native code where debugging couldn’t reach.  I also noticed via task manager that every time an image was placed, the application used three more GDI objects, and  didn’t get rid of the old ones.  This prompted me to look around on the internet for the cause. The Solution I found the MSDN page for GetHBitmap() . Under the “Remarks” section, the documentation explicitly states that you have to explicitly call GDIDeleteObject in order to dispose of the resources.  Now, both GetHBitmap() and GetHIcon() return IntPtr objects.  I figured I would give the DeleteIcon function a try to see if it solved the problem of generic GDI+ errors as well as the increasing number of GDI+ objects.  It worked well and both problems were fixed.  I’m not sure if this has been addressed in newer versions of .Net or not, but it’s something to keep in mind.  Microsoft should probably update their documentation. The usage is similar to the following:

[DllImport ("user32.dll", EntryPoint = "DeleteIcon"]

public static extern bool DeleteIcon(IntPtr iconHandle);

//then the cursor code

IntPtr iconHandle = bitmap.GetHIcon();

this.Cursor = new Cursor(iconHandle);

//use the cursor

//reset the cursor and delete the pointer.

this.Cursor = defaultCursor;


Hope that helps someone out there.

Read More

An Introduction

I’m going to preface this whole thing with a little introduction of myself. My name is Joe.  It’s a nice, easy to remember, generic name.  I’m a Computer Science major enrolled at The Pennsylvania State University.  At the time of this post, I recently finished Freshman year.  This blog will hopefully, in the best circumstances, be my sounding board for new projects that I work on.  I have no professional experience with writing, with my only true experience coming from writing courses in both college and high school.  I have failed in the past to maintain an active blog and actually get people reading it, which I’m hoping I can change with this one through both longevity and content.  I might also actually try to get people to read it, though I really don’t like the idea of spamming, so perhaps not.

A brief history:

At 19 now, I have been programming since I was twelve or thirteen.  I guess I technically started with VB.NET but quickly moved on to C# as I found VB to be rather boring and quickly discovered it wasn’t all that powerful for game creation, which was my sole interest at the time.  I found out about XNA and was one of the first members of the now defunct XNA Creators forums.  I had very very little programming experience, so all of my posts where those of a young kid asking really blatantly simple obvious questions.  Everyone was really truly helpful though, and I learned a good bit.  From there, I didn’t do much with programming until I was 15, at which point someone on ZuneBoards needed help with programming.  I gladly assisted and this led to a regained interest in C#/XNA and programming in general.  I ended up making three Zune games and an unreleased XBL Community game.  In high school, I studied QBASIC for a year and JAVA programming for two.  I never liked either of them as much as I like C#.  QBASIC was really rather fun though, and extremely simple.  I was involved, though minimally, in the hacking of the Zune / Zune HD.  I suppose I’m technically on the OpenZDK dev team, but I really owe those guys a ton of work as I haven’t done that much.  In college, I have studied two really really simple semesters of C++.  They have given me a general knowledge of the language, but there is still much for me to learn.  Due to a moderately impressive resume and some knowledge of coding, I recently acquired a job on campus writing software, and I thoroughly enjoy it.  This brief history of mine also include multitudes of little programming projects that would probably take hours to write about, so I won’t go into that.

Present Goals:

I really have been wanting to get into Android application and game development.  I’ve done some little bits of coding on Android, but nothing spectacular.  My current creation right now is a dual android app/ C# server (that runs on windows) that allows you to control media players remotely from your phone.  With the proper port forwarding, it will work anywhere in the world.  It needs a good bit of work and a ton of polish, but I may eventually finish that and release it so others who find it useful can use it.  I think I’m going to use it with my media server next year.  After reading some of the entries here I have become inspired to get back into game programming.  This also prompted me to start this blog here.  I have taken a rather lengthy hiatus from Game Development, not actually creating a full game (aside from two school projects that were not even half-baked) since I release Runaway! for the SD Zunes back in 2007 with updates going on until 2008.  Actually, I might port that over to Android at some point and expand the features list.  For what the game was, I’m happy with it.  I have since lost the source code, however.  If I remember correctly, the entire game only had about 1500-2000 lines of code that I wrote.  And most of it was contained within a single class, though I had several small classes for minor things like player entities and powerups.  My favorite part of the game was the Parallax Scrolling I implemented on the background.  Anyway, back to my present goals (can you see my lack of writing discipline yet?), I’m probably going to use this blog to host any Android apps and games I make (aside from placing them in the market), and will hopefully use this to document my progress on any projects I start.

I know there’s a good chance no one will ever read any of this, but at the very least, it’s here for my purposes.  I have a can of Monster beside me and I’m ready to get coding for a long duration tonight.  Until next time, adios.

Read More