Monday, July 27, 2015

Forwarding HTML e-mails on Android

I was looking at blogging platforms again.  A big feature for me that used to be very hard to find is now supported by all of the major blogging platforms I looked at: the ability to post via e-mail.  Even better, also formerly elusive, is the ability to change the e-mail address used to post the messages, in case the old address got hacked or whatever.  They all had that as well.  However, I'm finding it difficult to post HTML e-mails to the blogs from my Android phone and have them show up properly.

The native clients I'm using are K-9 Mail, Google Inbox, and Gmail.  When I get an HTML e-mail that I want to post to my blog, I forward it.  Currently, I'm using Blogger for this since that workflow seems to reliably get the HTML up on my blog without any massaging on my part.  I tried posting an HTML e-mail to WordPress in this manner, by forwarding it with Inbox, and the post was empty.  I tried it with Gmail and got the same result.  However, when I post using Gmail on a Web browser -- both Chrome for desktop and Chrome for mobile -- the message appear properly on WordPress.

I'm guessing that the native clients are not actually sending the message's assets (images, at least), but only the IMG tags, leaving it up to the recipient's client to load the assets.

My first question is, is this guess correct?  My second question is, why do native clients behave this way?  Is it a question of bandwidth, i.e., the cost of sending the assets themselves versus sending the IMG tags?  My third question is, how can I get around this with a native Android client?  Now that I know I can do this with Gmail on mobile Chrome, no problem, but it would still be nice to be able to do this offline.

Update

To elaborate, when I use Inbox from desktop Chrome, forwarding the message as-is to both Tumblr and WordPress produces an empty message.  Blogger posts the message in full.  Only when I remove the delimiter between the forwarded message and the body of the message do WordPress and Tumblr post the message.  Even then, Tumblr seems to filter out all of the HTML assets; WordPress posts the message fully and intact.

Thursday, April 3, 2014

Google Chrome and your local hosts file; Squid proxy for Mac

I was trying to alter my hosts file in order to block Faceb**k[1][2] and other annoying things that Ghostery told me were constantly loading on websites.  I looked up tips on how to do so and was surprised to see that what works on most browsers does not work on Google Chrome.  Here's an excerpt from How-To Geek:
When [we] tested it, Chrome did not use the hosts file in any operating system but we were able to block Facebook in Chrome by adding www.facebook.com.
Weird.  I did go to my Mac's System Preferences -> Network -> Proxies, selected Auto Proxy Discovery, and that seemed to make Google Chrome observe the /etc/hosts file.

There might have been more at work there, but I didn't want to mess with it further.  Instead, I decided it was time to install my own Squid proxy.  Of course, I wanted to see if someone had already made this less painful.  :-)  And voila:


A Squid wrapper for Mac.  It installs and configures Squid, giving you a nice GUI to configure basic options.  It is designed to be a personal proxy, running on your local box, but you can configure it to accept connects from other computers, a subnet, etc.

Side note, it was unfortunate that the URL filtering on my router wasn't very smart or else I would have used that instead.

Update:

I set Squid up as a transparent proxy, meaning basically that it requires no configuration by the clients, and that all HTTP traffic will go through Squid by default.  The problem is with HTTPS.  Using HTTPS with a transparent proxy appears to work with Google Chrome, which seems to delegate all proxy settings to the system, but it does not work with Firefox.  With Firefox, HTTP did work, but HTTPS did not.  Only when manually setting Firefox to use Squid as an HTTPS proxy did HTTPS proxying work.

Update:

When trying to accomplish the same thing on my Ubuntu box, this is how I got Chrome to respect Squid:

http://askubuntu.com/questions/66554/why-is-google-chrome-ignoring-my-proxy-settings


References

Problems running current version of Android SDK (22.6) on Mac OS 10.6.8

More evidence that my trusty 2006 Mac Pro, while still very capable, is becoming obsolete, seemingly thanks to Apple's rigid upgrade/obsolescence policies.

I was taking an online Android course through O'Reilly School of Technology, and have been doing all of my Android development there for the last several months.  My course ended, and I was anxious to use what I learned for other projects and to give Android Studio a try.  (O'Reilly's Android 1 course used Eclipse.)  Much to my dismay, it appears that Android SDK 22.6 doesn't play well with Mac OS 10.6.8.  I think the first problem I ran into was when I dusted off my local Eclipse and updated to the current version of the SDK.  That didn't work.  I had to manually upgrade it.  I finally got it installed, downloaded my O'Reilly projects and was going to ensure they ran locally.  The emulator never started up[1].  After many tweaks and restarts, installing the Android ADT bundle, etc., I gave up and tried Genymotion.  That didn't work either.  :-)  It seems ominous that a show-stopper such as this has existed as a reported bug[2] for three weeks.

I followed the instructions[3] from Stackoverflow to sneakily download an older version of the Android SDK tools (22.3), and then copy its /tools directory over the /tools directory in the ADT SDK bundle, i.e., ~/Downloads/adt-bundle-mac-x86_64-20140321/sdk/tools .

The good news for me is that I have a couple old Android devices I can use to run my apps on instead of using an emulator, but it's still frustrating to be unable to use the entire set of the current version of the development tools.

Reference


  1. https://stackoverflow.com/questions/22709471/bus-error-when-running-android-emulator - The question in Stackoverflow that describes the problem I was having with the Android emulator
  2. https://code.google.com/p/android/issues/detail?id=67036 - The relevant issue in Google Code for the Android Open Source Project
  3. https://stackoverflow.com/questions/9555337/how-to-downgrade-my-sdk-version#comment19794463_11514698 - The comment in Stackoverflow that allowed me to download an older version of the SDK tools.

Tuesday, February 18, 2014

Using Bundler to set up Ruby and Rubygems to work like Node.js and NPM

I was so excited by reading Development Seed's post about using Jekyll and prose.io to create sites without resorting to content management systems that I jumped into Ruby.  I was slowed when I dug my heels in and refused to "sudo gem install" anything, and tried to figure out how to use some keywords I'd heard -- "rvm", "Bundler" -- to do things the right way and install my project's gems locally, within the project itself.  After only a brief period of frustration, the clouds parted, and I found this:

http://ryan.mcgeary.org/2011/02/09/vendor-everything-still-applies/

So far, so good.  Thanks, Ryan!

- Also, a rbenv plug-in for making Bundler more convenient.

Thursday, January 2, 2014

Keybindings in Openbox

When I log into XFCE on my work desktop remotely using NoMachine's NX client, the "p" button stopped working.  Instead of messing with my XFCE settings, I tried logging into LXDE.  The "p" button worked.

Then I needed to remap the keyboard shortcuts for switching/cycling through windows.  I'm using a Mac Pro at home, and left Command-Tab alone.  Instead, I wanted my keyboard's control + tab keys to cycle through windows.  In XFCE, I would have gone to the window manager settings in the main settings dialog.  However, it looks like I had to manually edit Openbox's keyboard mappings in an XML file.

I ran xev in the X session to find out which key was being pressed.  It said Control_L and Tab were being pressed.  When I edited the /.config/openbox/lxde-rc.xml file from:

   1:  <!-- Keybindings for window switching -->
   2:  <keybind key="A-Tab">
   3:    <action name="NextWindow"/>
   4:  </keybind>
...to:
   1:  <!-- Keybindings for window switching -->
   2:  <keybind key="Control_L-Tab">
   3:    <action name="NextWindow"/>
   4:  </keybind>
...it didn't work.  I didn't care if it was the left or right Control key, so I just changed it to:
   1:  <!-- Keybindings for window switching -->
   2:  <keybind key="C-Tab">
   3:    <action name="NextWindow"/>
   4:  </keybind>
Then I typed openbox --reconfigure to reload the settings without restarting Openbox, and it worked as expected.

References:


http://openbox.org/wiki/Help:Bindings
http://superuser.com/questions/248517/show-keys-pressed-in-linux
http://linux.die.net/man/1/xev

Thursday, December 26, 2013

Android: Accessing shared preferences in Activity

I was getting this error when trying to access shared preferences in my main activity:

http://stackoverflow.com/questions/12201371/android-unable-to-start-activity-componentinfo

Moving getPreferences() to the onCreate() method solved the problem.  I'm guessing it's because I was trying to get the shared preferences before the activity was created.  (Hey, I'm new at this!)