Google Ngram Viewer

Screenshot from Google Ngram Viewer site

A friend of mine recently linked to an article that made reference to the
Google Ngram Viewer. From the website:

When you enter phrases into the Google Books Ngram Viewer, it displays a graph
showing how those phrases have occurred in a corpus of books (e.g., “British
English”, “English Fiction”, “French”) over the selected years.

This looks like a useful research tool.

OneTab

Image from OneTab site

Yesterday http://waxy.org/links/ posted a link to
OneTab. OneTab is a Chrome extension that lets you
“convert all of your tabs into a list. When you need to access the tabs again,
you can either restore them individually or all at once.”

The problem this solves for me is

  1. I want certain sites to be accessible.
  2. I don’t want something as permanent as a set of bookmarks.
  3. I don’t want 20 tabs taking up memory on my system.

I’ve been playing around with it and it keeps a record of different tab
sessions. You can combine sessions and drag and drop items between them. You
can also drag open tabs into the OneTab window to add it to a session.

It’s a nice little extension.

DokuWiki

At work, we just switched to a new Wiki application for our team documentation:
DokuWiki. So far it has been a pretty big hit. (For a wiki, anyway.)

It has several advantages over our old Wiki app:

  1. It is super easy to install. Drop it on disk, hit the install page,
    configure a few items, and you’re up and running. It’s PHP, so no container
    or application server is necessary.
  2. It is easy to administer. So far, the development team that I’m on has been
    able to administer the DokuWiki wiki ourselves. This makes our operations
    team happy since the old wiki required a bit of care and feeding to upgrade
    and to administer users. With DokuWiki, user admin is really easy.
  3. The syntax is simple and readable as text. I’m a big Markdown fan
    myself so I installed a Markdown plugin to allow me to create some pages in
    the format, but the rest of my team is using the vanilla DokuWiki syntax,
    and they seem to like it.
  4. It supports namespaces. The namespace support is not quite as intuitive as
    I’d like, but it’s simple enough for us to have figured it out. I don’t
    expect us to mave many namespaces, but it’s nice to be able to create a new
    space if another team in our department wants their own corner of the wiki.

DokuWiki screenshot

Scraping Data from a Website using JSoup (Lightly Seasoned with SQLite)

Here’s some Java code I wrote to scrape links from a site for insertion into a
SQLite database. I use JSoup to do the scraping. It uses JQuery selectors
to select content to scrape. I think I prefer XPath, but it’s good to
have another tool in the toolbox. I use a Google Chrome extension called
Scraper to help me form the JQuery selectors. In this example, I’m using
the SQLite FTS4 Fulltext Search extension to make the values easily
searchable in the DB.

package com.sample;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/**
 *
 * @author Oscar Grouch
 */
public class SampleScraper {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) 
    {
        /* Pull the all posts page */
        Document doc = null;
        try 
        {
            doc = Jsoup.connect("http://localhost/all.html").get();
        } 
        catch (IOException ex) 
        {
            Logger.getLogger(Scraper.class.getName()).log(Level.SEVERE, null, ex);
        }

        /* Get a list of all of the links on the all posts page */
        Elements links = doc.select("h2 > a");
        if (links != null)
        {
            /* Initialize DB driver. */
            try 
            {
                /* load the sqlite-JDBC driver using the current class loader */
                Class.forName("org.sqlite.JDBC");
            } 
            catch (ClassNotFoundException ex) 
            {
                System.err.println("Class not found: org.sqlite.JDBC: " + ex.getMessage());
            }

            Connection connection;
            try
            {
                /* create a database connection */
                connection = DriverManager.getConnection("jdbc:sqlite:C:/Temp/sample.db");
                Statement statement = connection.createStatement();
                statement.setQueryTimeout(30);  // set timeout to 30 sec.
                statement.executeUpdate("drop table if exists content");
                statement.executeUpdate("CREATE VIRTUAL TABLE content " + 
                                        "USING fts4(title, url, post)");
            }
            catch(SQLException e)
            {
                // if the error message is "out of memory", 
                // it probably means no database file is found
                System.err.println(e.getMessage());
                return;
            }


            /* Loop through the links */
            for (Element link : links)
            {
                /* Print out the link text */
                System.out.println("Processing " + link.text() + "...");

                Document currentDoc = null;
                try 
                {
                    /* Pull the current link page */
                    currentDoc = Jsoup.connect(link.attr("abs:href")).get();
                } 
                catch (IOException ex) 
                {
                    Logger.getLogger(Scraper.class.getName()).log(Level.SEVERE, null, ex);
                }

                /* Get the post Text */
                Element post = currentDoc.select("div.post").get(0);
                String postText = post.text();

                /* Print the post text */
                System.out.println("Post Text: " + postText);

                try
                {
                    PreparedStatement preparedStatement 
                      = connection.prepareStatement("insert into content values(?, ?, ? )");
                    preparedStatement.setString(1, link.text());
                    preparedStatement.setString(2, link.attr("abs:href"));
                    preparedStatement.setString(3, postText);
                    boolean isResultSet = preparedStatement.execute();
                    if (isResultSet)
                    {
                        System.out.println("A ResultSet was returned.");
                    }
                    else
                    {
                        System.out.println("No ResultSet was returned.");
                    }
                }
                catch(SQLException e)
                {
                    // if the error message is "out of memory", 
                    // it probably means no database file is found
                    System.err.println(e.getMessage());
                }

            }
        }
    }
}

Mirror your Android Device’s Screen on your PC

I was going to be on a conference call where I needed to show my Android Phone’s
screen. I was already sharing my PC’s screen. The last time I did this by
pointing a webcam at the phone, but the screen was pretty hard for call
participants to see. (Especially with my sausage fingers in the way!)

I found a nice solution to the problem. I used androidscreencast to mirror
my phone’s screen so that folks on the conference call could see it on my share
PC screen.

androidscreencast screenshot

I came across another Android screencasting app called Android Screenshots and
Screen Capture
, but I haven’t tried it. You may want to check it out.

Back Up Your Data

Not long after we got married, my wife came to me and asked, “Are our wedding
photos backed up?”

“Yes”, I replied.
“Just so you know. At some point, I’m going to want to look at those photos
again. If they are not available for any reason, we are going to have a
problem, so you do whatever you have to do to make sure I still have my
pictures. Put them in the safe deposit box. Network them to the clouds.
Something. Just make sure I have my pictures.”

I make sure she has her pictures by backing them up.

I prefer to backup my files in multiple ways and in multiple places for maximum
convenience and maximum reliability. Then again, I’m super nerdy. 8^)

If the only place your toddler’s pictures live is on your laptop, then those
suckers are one Mountain Dew away from existing only in your memories.

Maybe I’ll go into detail about backup options later on, but here are some of
my recommendations.

DropBox

https://dropbox.com

This program creates a folder on your computer that is synchronized to servers
on the internet. The amount of data you can store is small, but it is great
for backing up documents. You can synchronize with your phone too.

Western Digital My Passport Essential SE

http://amazon.com/Passport-Portable-External-Drive-Storage/dp/B007FQNKRC

This is a portable hard drive that you can plug into your computer. It comes
with software that you can use to backup your entire computer.

CrashPlan

http://crashplan.com

You can use this program to backup to a hard drive (like the Western Digital My
Passport Essential SE ) for free, or you can pay as little as $2.00 /month to
backup your PC to servers on the internet. (I’d recommend the $4.00 / month
plan since it lets you back up the whole computer.)

Extra Protection for your Online Accounts

A friend of mine fell prey to a scammer and her email account got hacked.
They gained access to several of her online accounts and did a lot of damage.
Once someone gets access to your email account, they can click “Reset Password”
on any other site you use to gain control of it too. Consider setting up your
email and Facebook accounts to send a code to your phone whenever someone tries
to login from a new computer or device. This is called
“Two-Factor Authentication” or Two-Step Verification”. It requires something
you know (your password) and something you have (your phone) before you are
granted access on an unrecognized device. Here are links to pages where you
can setup two-factor-authentication for a few popular services:

Gmail: https://support.google.com/accounts/bin/answer.py?hl=en&answer=180744

Yahoo Mail: https://edit.yahoo.com/commchannel/sec_chal_manage

Facebook: https://www.facebook.com/settings?tab=security&section=approvals&view

Dropbox (Click “Security” after sign-in): https://www.dropbox.com/account#security

Git Stuff

One of my co-workers was looking to begin managing source code for his personal
projects using Git. Here are the links I sent to him
to help get him started:

Tutorials & Reference

GUI Tools