Using Python to Edit PDF Files

I had a need to edit a batch of PDF files to remove some sensitive information such as account numbers and replace them with asterisks (*). When looking at some of the programs that are available to edit PDF’s they seemed to be mostly paid programs that didn’t have good batch options.

Writing a program in Python seemed like an interesting option and I did a quick survey of some of the existing packages. PyPDF2 looked to be a good library and had some examples on the web on how to do something similar, especially this particular gist: Redact phrases of text from a PDF.

Testing PostgreSQL Databases With Go

While setting up a Go project for database access using the PostgreSQL database I was looking for an efficient way to quickly unit test different database access functions without a lot of extra setup or time for each test. Also to make the tests more useful it helps if the actual Postgres drivers and database is used.

For this purpose I found an interesting Go package called txdb that’s described as a Single transaction based sql.Driver for Go. It allows to run a series of SQL commands in a test that get automatically rolled back after the test is complete. This allows the next test to start with pristine database conditions to keep the test independent. In practice I found this very useful and it helped me more quickly develop a correct database schema and database access code.

Search Integration with Hugo Static Site

While migrating from a Wordpress site to a static site in Hugo, I needed to implement some kind of search to replace the search available in the dynamic Wordpress site. There were several articles written about how to do this using the lunr.js search framework but I couldn’t get some of them to work very well so decided to write this post in case anyone else is having similar trouble.

The main idea is to generate a searchable index based on the current state of the site and then that index is used by lunr.js at runtime in the browser to execute the search.

Migrating a Blog From Wordpress to Hugo

I recently decided to migrate this blog from Wordpress to a site using the Hugo static site generator. The main goal was to simplify the hosting and learn more about the technology of static site generation. I chose Hugo mainly because it is fast and simple to use and install.

Process

The process to migrate the blog was somewhat involved because I wanted to make some improvements to the layout and hosting in addition to getting it into a new host. I also wanted to make it compatible with the old permalinks which turned out to be a bit of a challenge.

Testing Versioned API’s in ASP.Net Web API

I recently wrote about a framework for Versioning ASP.Net Web API. Continuing on the theme of versioning API’s, I researched how to test the different versions of a Web API, both for unit tests and SpecFlow acceptance tests.

Overview

As a quick review, the SDammann.WebApi.Versioning package was used for versioning the API and provides methods for selecting the controller that is active for a particular version of the API. At the code level the controller is selected by the name space of the particular version of the controller, e.g. Appname.Controllers.Version1. As mentioned in the last post, care must be taken to avoid unnecessary duplication in the controllers. Likewise the same duplication concerns apply for testing and relevant techniques will be reviewed in this post.

Versioning ASP.Net Web API

One of the important things to consider when building an API is a strategy for versioning the API to manage changes. There are several reasons this is important:

  • To support users (developers) of the API that are using an existing version so as not to force breaking changes on them.
  • To prevent breaking existing versions of the client applications that are using an existing version of the API.

Previous versions of the API will normally be maintained for either a period to allow developers and client applications to upgrade or indefinitely.

Using SpecFlow to Test the ASP.Net Web API

I previously wrote about the use of SpecFlow in an ASP.Net MVC application with the SimpleBrowser library. I’ve recently been building a project to utilize the ASP.Net Web API to study the best practices of building a “RESTful” API for an application to save research notes and links about multiple projects.

Approach

Since the Web API is intended to be utilized by a number of types of client applications that support the HTTP protocol (smart phones, tablets, desktop applications, as well as browsers), it is convenient to use a library that is well-suited to use the HTTP verbs used by the Web API. In this case I used the HTTPClient class for interacting with the Web API.

Hanselminutes Podcast: On Empathy with Leon Gersing the Ruby Buddha

Scott Hanselman recently published a really great podcast on his always-good Hanselminutes show, “On Empathy with Leon Gersing the Ruby Buddha”.  They discuss how important it is to maintain empathy when dealing with others on the Internet as well as in real life, and the importance of keeping a direct connection to your end customers and colleagues in your community. It is a good listen for anyone in the software industry.

Using SimpleBrowser with SpecFlow for BDD with ASP.NET MVC

The SpecFlow project provides a useful way to integrate BDD (Behavior Driven Development) testing into .NET projects using the Gherkin language. The main idea is that the project specs or user stories are written in user language and then are linked to actual tests that are automatically executed as the project is developed. There are several possible ways to implement this with ASP.NET MVC to automate the testing with the browser.

JQuery UI Autocomplete and MVC3 Remote Validation Conflict–Update

I previously posted about a fix to a problem when the JQuery UI Autocomplete doesn’t play well with the ASP.Net MVC3 Remote validation. Part of the solution included a way to ensure that the remote validation isn’t fired for each key click or change of focus in the text box.

The method for doing this is to change the settings of the validation to not fire onkeyup or onfocusout, but to get there the validator settings must be obtained from the form in question.  The following snippet was given to grab the settings (do not use this method):