Creating a ZIP file including a CSV summary of contents with Django

So I was building an “apply to work here” application for the company I work for, and I was using Django as my framework. My company has a bunch of entry level/part time jobs we post, so people would usually want to apply for more than one at a time, meaning on the apply page there is a list of jobs, and you check off one or more positions you want to be considered for. You then have to upload one resume and one or more cover letters depending on the job you applied for.

From the Admin side, I wanted managers to be able to login and download a zip file that had all the resumes and cover letters for applicants in their area, and I also wanted to include a CSV file in that zip download with an overview of everyone and the various fields they fill out when submitting their application. I built this as a action for the list view in the admin, but the core functionally (make a CSV from a DB and add it to a zip file) can be used in any situation

Continue reading “Creating a ZIP file including a CSV summary of contents with Django”

Using SQL with Google Sheets to create Views

I’m not a huge fan of Google Apps or whatever they are calling them these days, as I prefer the power of Office. But 365 is not free and I really do appreciate the power of realtime collaboration you get when working on a Google Apps file.

Something I just discovered was that you can use SQL in Sheets. You can query up any table (set of data) you have using SQL. Being a programming, and always wanting to see data in different views, I love this.
Continue reading “Using SQL with Google Sheets to create Views”

Setting up SSL Certificate on Ubuntu with Apache 2.4

sudo su #probably get hate for this,   but I'm lazy
  cd /etc/ssl/mycerts/
nano domainname.crt

Copy the certificate from your provider including the BEGIN and END tags
Continue reading “Setting up SSL Certificate on Ubuntu with Apache 2.4”

Creating a CSR Request for SSL Certificate on Ubuntu

I have to do this every three years, and its always a pain to remember

sudo su
cd /etc/ssl/mycerts/
openssl reg -new -newkey rsa:2048 -nodes -keyout serverdomain.key -out serverdomain.csr

Answer the questions. Most places don't care about the Organizational Unit. Leave the challenge password blank (press Enter).

cat serverdomain.csr

Copy the output (including the BEGIN and END tags) to the form of the supplier.

SQL Comparison operations ( =, <>, !=, <, >, <=, >=) with NULL

I had question about what would be returned from this query

SELECT `name` FROM `customer` WHERE `date` <> '05/05/10'

Here was the table:

John Smith null
Mary Smith 05/05/10
Joe Allen 02/16/10

I had to take a pause at that. I had no idea if John Smith would be returned.

Turns out that NULL is never equal to another value.
It is also never not equal to another value.
NULL is basically like “I have no idea” when it comes to comparisons.

The way to return both John Smith and Joe Allen would be

SELECT `name` FROM `customer` WHERE `date` <> '05/05/10' OR `date` IS NOT NULL


WordPress hyphenating my words

Fuck that.

/* Remove automatic hyphenation */
.site-content article { word-wrap: normal; -webkit-hyphens: none !important; -moz-hyphens: none !important; hyphens: none !important; }
.widget-area .widget { word-wrap: normal; -webkit-hyphens: none; -moz-hyphens: none; hyphens: none; }
.post-navigation .post-title,   .entry-title, .comments-title { -webkit-hyphens: none !important; -moz-hyphens: none !important; hyphens: none !important; }


Script to copy MySQL db from production server to dev machine

I like to use a copy of the production data when I’m testing out new features I’m building on my development version of the site. I just find that having real data leads to less unexpected issues. Here is a script I wrote to download that data from the production machine and copy it to my development machine. It also backups a copy of the database on production and keeps a copy of the db you’re replacing on dev.

#! /bin/bash
d=$(date +%Y%m%d%H%M%S)
ssh "mysqldump -u root -p'1234' database | gzip -c | cat > ~/db_backups/database_$d.sql.gz"
echo "production/database backed up"
scp$d.sql.gz .
ssh "mysqldump -u root -p'1234' database > ~/database_last_overwrite.sql"
echo "dev/database was backed up to ~/database_last_overwrite.sql"
gzip -d database_$d.sql.gz
cat database_$d.sql | ssh "mysql -u root -p'1234' database"
rm database_$d.sql
echo "copied production/database to"

Both servers are running ubuntu. Executing from a macOS machine.

Make a zip of files in PHP

There is this form that people enter a bunch of info and attached 1 to 7 files too. The files get uploaded to a web server directory and the form responses are stored in a mysql table. I wanted to create a script that would let me download all responses including the uploaded files, as having to SSH in to download the files, and then dump the info from mysql to a csv file was annoying. Continue reading “Make a zip of files in PHP”

Terminal Command Shortcuts

Typing long commands out in the terminal can be a pain, like SSHing into a server you use daily.

To make a shortcut, edit your bash_profile

nano ~/.bash_profile

Then add the shortcut by adding this line to the bottom of the file

alias someservername='ssh -p 1234'

Then all you have to do to connect to that server in the future is


You can do this with any command, not just ssh. But if you do it with SSH, you should setup public key authentication to speed that up. I'll write about that sometime cause I always forget how to do that too.

Here are some other ones I have setup on my machines. (I got these of the internet at some point. I don't know where)

alias ll='ls -lh'
alias la='ls -lhA'
alias l='ls'
alias c='clear'
alias x='exit'
alias q='exit'


Using virtualenv

I always forget how to activiate the virtualenv when working with Django

source newenv/bin/activate

To close it when done