SideApps

A collection of my applications
Facebook
Stay away - Facebook

CatSpam: An Innovative Approach to Spam

I often come up with programming ideas as I’m trying to fall asleep and, more often than not, this forces me out of bed to start some silly work. About a year ago I had an idea: Would it be possible to create a script to text friends, family and/or strangers with some form of spam. For some reason I landed on the innocuous topic of feline facts and got right to work.

My first idea was to use the email system that has been in place for some time now to send the text messages. However, this requires me to know what network the phone is on and that’s a problem I wasn’t interested in dealing with. Then I remembered Google Voice… For the uninitiated, anyone with a Google account can now get an additional phone number, free of charge. You can configure Google Voice to forward your calls to whichever phones you chose while keeping your primary phone number concealed.

Python, being one of my favorite languages was the clear choice for this task. It turns out that Google has no public API for their Google Voice service. Thankfully, some pro programmers have created Google Voice libraries for a handful of languages, including Python. I used pygooglevoice which ended up being a pleasure to work with. The program prompts the user for their Google login (which is securely handed off to Google for verification) and then asks the user for the phone number they would like to send spam to. Also configurable is a time interval in which the texts will be sent. The cat facts are read from a file located in the same directory and, in theory, could be replaced with any text file in the same format.

Enough about the program – here it is:

If you’re interested in the actual catfacts.txt file you can check it out here: catfacts.txt

Add Markers to Google Map from CSV

I was recently asked to create an HTML page that would access a CSV file containing a list of latitude/longitude values and generate a map with markers for each location. This project was a proof-of-concept challenge for me so I’ve really just made a barebones implementation. That said, it should be very easy to expand using only Google’s API documentation for reference. Google Maps were the clear choice as they’ve become a bit of a de facto standard. Enough – let’s dig into the code!

This block of Javascript converts a local CSV file to a multidimensional array that can be easily accessed and manipulated within memory:

This initialization function is all it takes to generate a Google Map and add all of our markers:

Using these two functions, all it takes to generate the actual map is a single line of code:

You can see this code in action right here: http://sideapps.com/smart911/

If you’re interested in the CSV file it can be downloaded here: http://sideapps.com/smart911/zip-lat-long.csv

I must admit, I am a bit prejudiced toward web applications… However, I found Google’s API and the small amount of Javascript I had to learn very pleasant. I anticipated a much longer process and was very happy to be able to complete the task so logically and directly. Hopefully this helps someone out!

 

FlowReader: A Revolutionary Way of Speed-Reading

Boston-based tech company, Spritz, has recently introduced a new speed-reading method. This technology utilizes a previously existing presentation method, known as RSVP (Rapid Serial Visual Presentation). A single letter is highlighted to focus attention to a natural center of the word. The brain processes the rest of the word through your peripheral vision. By keeping the highlighted word in the same place, Spritz is able to eliminate minute eye movements that make up a large part of our natural reading process.

My friend Julia Hlavacik and I were discussing this new technology when we realized we might be onto something interesting. Not only does this kind of program have potential for everyday uses such as e-readers, mobile web pages, and all forms of articles; it also circumvents a lot of the problems faced by dyslexic readers.

Dyslexic readers generally have trouble scanning lines of text, finding the next line of text, staying focused on a word in a line, reading on certain colors of paper/background along with some impairment of spatial awareness. This isn’t an exhaustive list, but all of these issues are either alleviated or circumvented through RSVP. Although normal readers may not experience these problems to the same acute degree as most dyslexic readers, this speed-reading program can still significantly boost the average person’s reading. This is particularly useful on small, digital screens where text can be difficult to adjust.

The video below demonstrates a brief proof-of-concept. The text you see is being presented at 250 WPM; the reading speed of an average adult. To many of you, this text will likely appear somewhat sluggish – most readers can easily adapt to 500 WPM or more. I chose to use an open source API called OpenSpritz as the Spritz API has limited customization options and forces users to create an account and sign in. Two examples of customization that would be impossible with Spritz’s API are the color theme and the ability to adjust the WPM on the fly to account for longer words or punctuation.

How to Attach an Image to an Email Using PHP

I recently wrote a small data acquisition system using PHP. I’m not a fan of web-based development and know very little but I had some financial incentive for this project and took it upon myself to learn along the way. By far the biggest headache I ran into was dealing with PHP’s mail() function. There’s obviously a reason so many third party libraries exist that tackle this issue but, being stubborn, I wanted to do it from scratch.

My goal was to generate and send an email consisting of an HTML body with an image attached. Embedding the image within the HTML turned out to be fairly trivial (in comparison) but an attachment was preferred. After MUCH ado I came up with the following function which does just that.

NOTE: This function doesn’t go to any extremes to validate itself and doesn’t make it past very many junk filters. This was fine for my use case as the email will be going to a single administrator who can easily whitelist the domain. However, if this is a concern I would highly recommend using one of the third party libraries as considerable configuration is required both in the PHP and on the delivering server itself.

Remotely Control iPhone via SSH and VNC

This is an issue I spent far too much time time on. I stumbled upon a great new game, Threes, and had become consumed with the internal workings – how the game chooses what card to produce, where to place it, etc. In order to get some real data to work with I needed to complete a multitude of games, all while keeping track of which cards were produced and where. This is the type of menial task I have no patience for and I quickly began to seek a method to do this automatically.

I had a jailbroken phone – something you will need to do have if you are interested in any of the methods I am about to describe. This method is 99.9% effective and, if something goes wrong, you can completely fix it by restoring through iTunes. Unlocking your phone is dangerous – it has the possibility of leading to a “bricked” iPhone. Jailbreaking is not unlocking. If you’re interested in jailbreaking check out evasi0n - the latest version of their tool is working on iOS 7.0.6.

With that out of the way, here’s what you’ll need and why:

  • OpenSSH: SSH is ubiquitous method of remotely accessing another system through the command line. This is how we’ll interact with the iPhone and send it the commands we want.
  • SimulateTouch: This package allows you to (you guessed it) send touch events to your iPhone using command line tools.
  • Optional - Veency: This is a VNC server that runs on the iPhone. VNC is another tool that allows you to remotely access devices. However, unlike SSH, it allows you to see the screen of the remote device and send things like touch and keyboard events. But I thought we were using SimulateTouch to send touch events? Yes, that’s right. Though Veency can be used this way as well I’ve found it to be far less reliable than the SimulateTouch library. Sometimes the commands I send are just lost in the ether.
  • Optional - Activator: This allows you to set up a handful (read: a ton) of custom gestures and actions that can do anything from launch applications to disable WiFi to restart your iPhone. It also, conveniently, has a command line interface which can be used to activate any of its abilities via SSH – no gestures needed.

That’s it for the software! Everything I just listed can be downloaded, for free, through Cydia. Cydia is installed automatically when you jailbreak and is the de facto way of installing 3rd party software.

So, now that we have all these tools – how do we use them?! I’m a big python buff so all of my examples are going to be in python. You can use any language you like, but you’ll have to interpret the mysterious code I provide you.

Before I start with examples, here’s the biggest pitfall of our setup:

We don’t have a way to view the current screen in applications that run at 30 FPS or more. Veency simply can’t keep up and provides a distorted display. I’ll explain how I’ve been getting around this in my examples below.

Connecting via SSH:

I’m using Spur as my SSH interface. You can use whatever you want. We use the username ‘root’ because we want full access to the iPhone filesystem. The default SSH_PASSWORD is ‘alpine’ (and has been forever) – I recommend you change this as it is somewhat of a security issue.

Connecting via VNC:

Here I’m using the vncDoTool. Again, use what you want. You can set up the VNC_PASSWORD in the Veency settings.

Sending Touch Events:

The SimulateTouch library makes this dead simple. My example above shows how to make a swipe in any direction. You provide the X,Y coordinates of the start position and the end position. The last two commands are the duration of the swipe and the orientation of the device (1 = portrait).

Taking a ScreenShot:

My first example instructs Activator to take a screenshot. My second example uses VNC to hold down the power button, press the home button, and release the power button – all in quick succession. As you probably know, this is the built in way to take screenshots in iOS. These screenshots will be stored in your camera roll.

Accessing the ScreenShot:

This is a little more complicated. What we’re doing is listing the files in our screenshot directory by their creation time (yours may not be 108APPLE but it will be in the same DCIM directory). We grab the first of these files and assume (correctly) that it’s the screenshot we just took. We then open this file with SSH – this effectively stores the image in memory. Then we use python to open a file for writing – this is where we’ll store the screenshot. We use shutil to copy the screenshot from memory to the file location we opened. Finally, we close out both of our file streams.

In the second to last command I delete the screenshot file. Unfortunately, Apple has made their screenshot system ridiculously complicated. If you navigate to your Camera Roll you’ll find your image is still there. Click on it and a blank screen will be loaded. We’ve deleted the image file it’s trying to load but haven’t gotten rid of the image reference or the associated thumbnail that was created. I haven’t found a way around this.

The final command stores our image into the program memory so I can use it elsewhere without having to read the file from disk each time.

Well, this concludes this fairly verbose tutorial. If you have any questions I’ll do my best to answer them in the comments. I’ll leave you with close to 1000 lines of Python code for you to peruse. This is the code I came up with for automating the gameplay of the addictive and beautiful new game Threes.

 

Programmatically Add Default UITextField

I haven’t posted anything in a while, but I’ve been programming much more often and figured I’d share some answers to questions that had me stuck for a while. Now, if you’ve ever tried to add a UITextField purely through code you’ve probably noticed that what you get is a blank area that you can double-tap and add text to. When you add it using Interface Builder you get this pretty rectangle with rounded edges – what gives?

Well, I have no idea what gives. But what I do know is how to use a whole bunch of extra code to fix it. Here’s some nicely commented code that shows what I’m talking about:

That method will return a nicely formatted UITextField. It may not look precisely like the one you get from IB, but I challenge you to get it closer. If you don’t want any placeholder text just send nil or edit the method to take no instance variables.

Windows 8 Lightscribe Disc Image

I couldn’t find any decent Lightscribe templates for a Windows 8 disk so I whipped one up myself using a mashup of others’ work. Enjoy!


The creator of the Windows 7 image this is based off has a Deviant Art account.

I was unable to find the creator of the Windows 8 logo I used in the image. Creator, if you stumble upon my website feel free to shoot me an email for recognition.

Download Windows 8 LightScribe Template
Downloaded 2800 time(s)

The Inception Button on Cydia

I received an email earlier today asking if I could get the Inception Button onto Cydia seeing as Apple has the preposterous idea that such an application provides “limited functionality” (rather than limitless functionality). I figured, why not, I’d give it a go.

After some time on IRC channels with the creator of Theos and several other helpful and knowledgeable folks I’ve managed to bring the barebones version of the Inception Button to Cydia! I’d like to thank Allen of Planet-iPhones for hosting the application. Anyone who is jailbroken should be able to install the Inception Button via the default community sources.





Automatically Delete iTunes Duplicate Songs with iDupeNuke

UPDATE: I’m finding more and more bugs as I use this. I wouldn’t recommend using it in its current state.

The various methods by which I accumulate my music often leave me with duplicate songs in my iTunes library. Having been fed up with the task of manually removing these files I decided to create a utility to do it for me. The project took me quite a bit further into the night than I anticipated however I was able to come out with an end product I’m happy to call a 0.1 Beta.

The utility is written in Java so it should, in theory, be compatible on both Windows and OS X. That being said, the only testing I’ve done has been on a Windows 7 machine and it was quite minimal. With the latest version of Java installed you can instruct iDupeNuke to remove duplicate songs in iTunes with the following code

java -jar iDupeNuke.jar

The program should proceed to analyze and neutralize any duplicate songs in your iTunes library.

I welcome suggestions, bug reports, and generic comments as I plan to expand this project and implement some sort of GUI. I hate Swing – if anyone has a recommended alternative I’m all ears.

Download iDupeNuke
Downloaded 399 time(s)

WakeMate Reviews

Visit WakeMate Reviews

With the release of the WakeMate I decided to pull together a site to provide prospective customers with current information and reviews on the intriguing device. In addition to providing information, the site encourages people who already own a WakeMate to submit their own thoughts, comments, suggestions, and reviews.

Please feel free to post your thoughts or suggestions on the new site either in the comments here or via the WakeMate Review site itself.