Sunday, March 17, 2013

Google Reader replacement

Google recently announced it is shutting down their Google Reader service on June 1st. I'm a long time user of this service, like many people, and I was a little dismayed to hear this news. I've been using Google Reader probably ever since it first came out in 2005. One thing I really like about it is because it is a web-based service, it is available anywhere you can use the web. So I don't have to keep separate programs on each computer I use and my cellphone.

There is a good alternative to replicate this functionality.. Tiny Tiny RSS. This is a web-based RSS reader that can be installed on your own hosting or other server. I actually set it up on an old computer at my house and it runs just fine. It is a very easy setup too, if you have a little bit of technical skill. It requires Apache, PHP and MySQL.

Very basically the steps can be summed up as:

  • Acquire the files from the website
    • You might notice it's on github. I just did a  git clone  in my home directory on my Ubuntu server which made a local copy of the most recent tree. Then I made a tt-rss subdirectory under /var/www/ and copied the whole thing there.
    • If you download the tar.gz instead, make sure you unpack that. You could probably unpack it directly into /var/www/. 
  • Make a database and database user in MySQL. It will also work with PostgreSQL but since I already had MySQL, I used that instead. There are several ways you can do this. I used a local copy of phpMyAdmin.
  • Once you have the database and database user setup with correct permissions, install the schema.
    • Look under the schema directory for a file named like "ttrss_schema_mysql.sql" if you are using MySQL.
    • Copy the whole file and paste it into a SQL window in phpMyAdmin. Then run it.
    • This will create all of the appropriate tables, views, etc that Tiny Tiny RSS uses.
  • Go back to your shell and make a copy of config.php-dist in the root of the app. Name it config.php and then edit it.
    • It's a good idea to go through each option and at least read them. The most major options that you have to worry about are the ones you need to set for the database server. Make sure you set IP, database, username, and password.
    • I believe you should enable multi-user mode to use the built-in user account options. If not, you may need to setup authentication in Apache.
  • At this point you can try to open it in your web browser.
    • I had to chmod several files so they could be read/written to. You might even need to chown all of the files to your Apache user such as www-data.
    • Default password is admin/password. Everyone knows this so you should change it right away. Especially if you set it up somewhere where it is Internet accessible. Even if not, it would be best to change it anyways.
    • Rather than using the admin account in normal usage, it is even better if you make a user account and save the admin account for administration.
  • Figure out how you want it to update your RSS feeds. See UpdatingFeeds on the wiki
    • The recommended way is to run update.php -daemon or update_daemon2.php from the shell or from a shell script. These will continuously run in the background.
    • Run update.php -feeds in your crontab occasionally to update your feeds.
    • There's a command in the config.php you can set so while you are browsing via the web interface, it will try to update your feeds. If you don't visit for a while using this method you could miss some entries.
    • If you don't run one of these methods, nothing will ever show up in your feeds.

So once you set this up, what then? If you already have an active Google Reader account, it is possible to import all of your existing feeds. Even the categories you have each feed in can come across!

  • Log into your Google Reader account.
  • Click on the gear shaped icon near the upper right and choose Reader settings.
  • Click on the Import/Export button.
  • Click on Download your data through Takeout
  • Click on CREATE ARCHIVE button.
    • This can take several minutes to run.
    • Once it is done, click on the Download button to download it.
    • The file I downloaded was around 10MB, yours might vary. More than just subscriptions, it also contains all the items you shared, starred, liked, and more in JSON format. That stuff isn't really useful right now unless you can make a program to do something with it.
    • subscriptions.xml is the important file.
  • Log into your Tiny Tiny RSS site in your browser at this point.
  • In the very top right there's a menu named "Actions...", click that.
  • Then click Preferences.
  • Click on the Feeds tab.
  • Look for a bar that says "OPML" and click on it to expand it.
  • Click on "Choose File" and pick your subscriptions.xml
  • Finally click on "Import my OPML"
It should import all of your existing feeds and already have them in all of your original categories.

Now there is a good Android app made by the original author of Tiny Tiny RSS with a 7 day limitation. Despite it being open source, he would like you to pay $2 to unlock it for unlimited use. This application requires access to an instance of Tiny Tiny RSS such as one you just setup or a public one to operate. Someone else has forked the source as TTRSS-Reader which is similar but has a few nicer features and isn't limited to a 7 day trial like the other one. I recommend it.

To use either one, make sure you enable the external API in the options of your instance. Look in Preferences again for that.

Saturday, March 2, 2013

PHP work and APIs

I've been learning PHP for a while. I think I have a long way to go but I have completed a few projects in PHP and have a fair amount more that I'm working on. My most recent portfolio website is written in PHP. It queries a MySQL database for the contents of a page and then it dynamically builds the page. That includes dynamically building the navigation links on the said, breadcrumbs and so on. The PDFs that I host also are shown on their own generated page. It's really neat.

Something else I've been working on recently is a utility for the local Amateur Radio club I belong to. It's a membership roster that can be managed online. Each member is stored in a database and I will have a page to edit details and another page to add a new member. I haven't completed the edit page just yet. It loads the member's details and even generates a form with the correct input elements for the data type. Checkbox for bool, textbox for varchar, date (HTML5) for date. The date picker in HTML5 is really neat. I have it show the ID field but greyed out because that is not user generated. I'll have to add some sort of authentication to this before I turn it loose. I also want to add some tracking for who the officers are, and maybe even some tracking of who is in what committee because they do those too. Another thing that I will add is the ability to download a PDF copy from the roster page and also to send out some sort of version to the email list, like what normally happens. It'd be great if I could integrate this into Drupal, at least for authentication, but I don't know that is going to happen. I did write a PHP script that can be used to look up someone's information by their callsign. Originally this information came from the FCC but I am using the API and querying their database for it.

Something else club related that I would love to write is a callsign logging program for the club to use on field day. Especially if I can put it on a Raspberry Pi with a WiFi router in a box, then each station could have a laptop connected over wifi that would show the page and let each individual station make entries. Field day also is a competition so you get points for so many contacts in various situations. That could be handled by the computer and it could give real-time results. Maybe with a 1200-baud packet radio link those results could be sent somewhere with an Internet connection and shown live on the club's website, or posted to Facebook.

For work I wrote a PHP script to be run at the command line in Windows and using TCPDF it would scan through a list of patients in the EMR software we support and print out 1 PDF per patient with all of the internal emails related to that patient. It looked really nice. I'm excited for the customer to see the result because I think they are going to be pleased.

I have a few more personal projects that I'd like to work on. One is a tracking program someone can use to keep track of their headaches and maybe more usefully.. taking medications. I'm 10% done with that. Another one is a gas log for my car and my wife's car. Yet another one is for groceries. All of these I'm working on something that shows up fine on a cellphone browser. My wife could be at the store and looking at the list on her phone. There are utilities that should integrate letting me do barcode scanning with the camera. Eventually, a couple years down the road probably, I will have something that can suggest sales and help us save money by buying at certain times.

Another idea I had the other day is I would like to write a PHP class that can take a string input consisting of the contents of a Tiddlywiki file. Then using the class methods I can easily extract information from the Tiddlywiki. Once that is done, I may inject that information into a MySQL database. I just have to figure out how to use the DOM methods in PHP to look for the div containers that Tiddlywiki uses and then pull various information from it including the contents.

There are a couple of APIs I need to learn for work:
Google Analytics
I'll be using these to build a nice application for someone with a lot of reporting and control.
I hope what I learn can be applied to other places. I'd love to write something that uses the API to help me keep track of wish-lists and maybe even make purchases. (Maybe not, if I have something stuck in a loop that orders 1000 copies of a CD I want, that wouldn't work out well for me)
I'd also like to connect to Facebook and Twitter over their APIs.