Using awk and SQLite

I have recently had the opportunity to use awk and sqlite on a project that I’m working on.

My first thought was that awk should be able to do that. I found some code that someone else did that parses quote and comma delimited.

I started off installing sqlite on cygwin.

After getting sqlite installed, I felt that I needed some test data in order to work with so I did a search and found this site:

https://www.briandunning.com/sample-data/

I grabbed the free file for testing.

The file is comma delimited file that has these fields:

  • First Name
  • Last Name
  • Company
  • Address
  • City
  • County (where applicable)
  • State/Province (where applicable)
  • ZIP/Postal Code
  • Phone 1
  • Phone 2
  • Email
  • Web

Here I used the SQLite command line to issue the command to create the table.

I attempted to import the csv file but got an error.

I can tell that the records are from a Macintosh system because the file has a carriage return record delimiter.

so I wanted to view a hexdump of the file.  I used cat, tr , head and hexdump.

You can see in the HEX dump below that the file now has hex 09 line feeds.

The problem is how to handle quote comma delimited files. I did a search to see if someone already had a solution for that and found this:

AWK CSV Parser

The code contains a function called parse_csv(). You can look at the usage of the parameters on the link above. The important part is how to call this function.

I’m using AWK to convert the CSV file into a pipe delimited file.

I then imported the data into the database.

I’m seeing the first row has the column titles. I’ll look into how to import without that line later.

C# Create list of string

FuelPHP framework jQuery DateTimePicker

I have recently started learning about the FuelPHP framework. I have been working on understanding how to use the framework as intended by the creators, and I think I’m doing a fair job of that, except possibly with regards to using external jQuery libraries.

I have a simple CRUD application that I built as a proof of concept for using a third party jQuery DateTimePicker library.

This is the jQuery DateTimePicker library that I found and used.

This is not including the public asset folder that contains the actual Javascript and CSS.

Model
fuel/app/classes/model/dtpsample.php

View Template
fuel/app/views/template_dtpsample.php

I want to specifically point out this piece of code. The main thing to notice is Asset::js and the JavaScript code.

Screenshot of the DateTimeStamp picker on the page.

Views
fuel/app/views/dtpsample/_form.php

Controller
fuel/app/classes/controller/dtpsample.php

Add Caption to image in WordPress

Here is a sample post that has text with an image with a caption that is centered below it.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer viverra, orci sit amet mollis cursus, eros mi iaculis neque, non consectetur risus leo at dui. Mauris sit amet scelerisque leo. Donec nunc urna, dictum at massa in, aliquam cursus lectus. Maecenas rhoncus vulputate justo, eget venenatis metus fringilla ac. Suspendisse euismod, tortor quis imperdiet finibus, lectus felis hendrerit erat, ac dignissim

leaf graphicBoy Scouts

tortor tellus nec lectus. Aenean ultrices imperdiet arcu eleifend molestie. Aenean aliquet non urna at rhoncus. Nunc ut aliquet nisl, sit amet pulvinar nisi. Vivamus facilisis urna magna. Interdum et malesuada fames ac ante ipsum primis in faucibus. In et metus sed dolor ornare vehicula vel quis ante. Etiam at malesuada libero, eu scelerisque leo. Mauris tempor sed dui at porttitor. Sed augue odio, luctus at nibh at, aliquam mollis felis. Cras dui urna, aliquet vitae aliquam ut, imperdiet vitae sapien. Maecenas ut congue tellus.

The code that I used came from the https://codex.wordpress.org/Wrapping_Text_Around_Images site.

Here is the code I used: