Categories
Coding

Couples who code together

My talented wife has been learning to code. Specifically, she’s been learning front-end web development, starting with HTML and CSS.

One of her projects as part of a coding bootcamp she joined is to build a basic site with the HTML and CSS she’s learned. She experimented with a CSS-powered dropdown menu on her project site, and hit a snag with it, so I took a look at it last night.

Merging a pull request on GitHub

In the process of working out a solution, we found something new we can do as a coding couple … submit and merge pull requests (no pun intended there 😜).

Categories
Applications Coding Tutorials

The missing piece in my Python scripts

My quest to automate parts of my workflows usually involves writing Python scripts to streamline some of my tasks as a Happiness Engineer.

One output has confused me for far longer than it should have, and I was shown the light today (in the form of a pretty simple solution).

My dilemma

Many of my scripts generate template documents. These include meeting agendas, hangout notes, and team reports. These documents include a couple components that I’ve largely automated using Python, such as –

  • Calculating dates and times in reports (sometimes including timezone conversions);
  • Taking inputs I provide in response to command line prompts, running calculations, and adding those to fields in my reports; and so on.

Many of my documents have a static list of team members that I ping much like Twitter mentions when I publish them as posts on internal blogs (we use internal blogs quite a lot, as you can imagine). Those lists each need to be updated manually every time there’s a change in the team composition, in each of the documents the list appears in.

Although the team composition doesn’t change frequently, I often find myself re-using a script for a team report, or hangout agenda, for example, in another group I work with. This means another set of documents where I need to manually create a list of people, and maintain that.

An example could be something like this:

Pinging: @john-doe, @maryjacobs, @davesmith, @janestuart, @tomwright, @steverobinson

The solution

Currently, the first part of generating this sort of list of people is creating a .csv file that looks something like this:

first_name,last_name,username
John,Doe,john-doe
Mary,Smith-Robinson,maryjacobs
Dave,Smith,davesmith
Jane,Stuart,janestuart
Tom,Wright,tomwright
Steve,Robinson,steverobinson

I was planning on using Python Classes to do this, but quickly realised that I don’t understand Classes nearly well enough to using this feature for this aspect of my documents.

I realised that there’s actually a simpler solution using .csv files and the csv module available in Python instead, after watching Corey Schafer‘s tutorial on this, here:

As an aside, Schafer’s tutorials are wonderful!

I was able to borrow from Schafer’s solutions to write a script that produced a list that looks something like this:

Pinging: ['@john-doe', '@maryjacobs', '@davesmith', '@janestuart', '@tomwright', '@steverobinson']

My script looked like this:

import csv

with open('people.csv', 'r') as csv_file:
    csv_reader = csv.DictReader(csv_file)

    members = []

    for line in csv_reader:
        wpuser = f"@{line['wp_user']}"
        members.append(wpuser)

print(f'Pinging: {members}')

I couldn’t work out how to just generate a list of usernames separated by spaces. I ran into a similar issue with other scripts where I similarly loop over a list of items to produce some sort of list-generated output.

In other words, I couldn’t figure out how to output the list of usernames without the []' characters you see in my initial output.

So, I asked for help on reddit where JohnnyJordaan pointed me to this StackOverflow post that includes a couple solutions to a similar question. I had searched for a solution to my challenge, but didn’t come across this answer (or anything like it).

Clearly, I need to work on my Googling skills when it comes to finding solutions to my coding challenges.

Anyway, the solution that JohnnyJordaan suggested is pretty simple. Instead of using something like print(f'Pinging: {members}'), I could rather join the items in the list with a statement like this:

print(f'Pinging: {", ".join(members)}')

As I suspected, the solution is pretty simple. It just eluded me, completely. So thank you to JohnnyJordaan for the pointer!

I also like the * that came up in one of the StackOverflow solutions, but it doesn’t work with the f strings that I tend to use. Still, there are other ways to use them. Trey Hunner has an interesting post about these operators here (if you’re interested).

Categories
Photography Travel and places

Pretty sunset yesterday

Sunset in central Israel
A pretty sunset in central Israel

I thought I’d capture our sunset yesterday evening, as a panorama. It was pretty!

Categories
Writing

Summoning demons in Word

Ah, yes, MS Word, my old nemesis … 😂

Source: Meredith Ireland

Categories
Blogs and blogging Business and work Creative expression

Build a membership site with recurring payments

We launched a new Recurring Payments feature for self-hosted WordPress.org sites (powered by Jetpack) or WordPress.com sites today. It’s an awesome new way for anyone with a paid WordPress.com plan to earn money through their sites.

Our new Recurring Payments feature for WordPress.com and Jetpack-powered sites lets you do just that: it’s a monetization tool for content creators who want to collect repeat contributions from their supporters, and it’s available with any paid plan on WordPress.com.

Let your followers support you with periodic, scheduled payments. Charge for your weekly newsletter, accept monthly donations, sell yearly access to exclusive content — and do it all with an automated payment system.

A New Way to Earn Money on WordPress.com — The WordPress.com Blog

The model is similar to Patreon in that you can give your fans a way to support you with recurring payments. This is a great way to build an income through your site.

Here are a few things you can do with this new feature (borrowing from our announcement post):

  • Accept ongoing payments from visitors directly on your site.
  • Bill supporters automatically, on a set schedule. Subscribers can cancel anytime from their WordPress.com account.
  • Offer ongoing subscriptions, site memberships, monthly donations, and more, growing your fan base with exclusive content.
  • Integrate your site with Stripe to process payments and collect funds.

One reason I really like the Recurring Payments feature is that it gives anyone with a paid plan (whether it’s a WordPress.com Personal plan, or a higher plan) a way to create a membership site that can help them grow a following, and a new income stream.

Ad revenue is a popular way of earning money through your site (we offer a WordAds ad platform, for example), but ad revenue really depends on substantial numbers of visitors to turn into meaningful income.

On the other hand, receiving recurring payments from a smaller group of passionate supporters just seems to be more sustainable, and meaningful.

It’s hard to be creative when you’re worried about money. Running ads on your site helps, but for many creators, ad revenue isn’t enough. Top publishers and creators sustain their businesses by building reliable income streams through ongoing contributions.

This new feature empowers creators, bloggers, knowledge workers, <insert your title here> to share something of value with your audience, and build a sustainable business in the process.

Find out more here: Recurring Payments — Support — WordPress.com.

Featured image by Nicholas Green
Categories
People Photography Travel and places

Capturing your bucket shot

I enjoyed Peter McKinnon’s short film about his journey to achieving one of his goals, titled “Bucket Shot” –

His aim was to capture the popular Lake Moraine, with snow-covered mountains, while the lake was still liquid. It’s a beautiful scene, and well worth watching the film.

Featured image: Laurent Gass PHOTOGRAPHIE, licensed CC BY NC ND 2.0.

Categories
Blogs and blogging Design

My new Twenty Twenty look

I decided to switch my site over to the new Twenty Twenty theme that will be released with WordPress 5.3 next week. I downloaded a pre-release version from the GitHub repo, and uploaded it directly.

A fresh coat of Twenty Twenty

I like the default themes that ship with WordPress, and the themes that our team is building. Even though the new generation of themes aren’t perfect*, they’re built for the block editor. I keep forgetting how much flexibility that brings to WordPress.

Preview of the Twenty Twenty theme.

So far, I like this new theme. I think the content container is a bit narrow on a larger screen, so I may tweak that a bit. The mobile view is pretty great, though.

Main image by Anna Kolosyuk

For example, I’d love to see custom fonts return to the Customizer, although with Full Site Editing on the way, we won’t be using the Customizer for much longer.

Categories
Design Events and Life People

… you can create blocks like it’s 1999

I’m watching Matt Mullenweg’s “State of the Word 2019” from the recent WordCamp US, and almost snorted my tea when he had this to say about the new colour gradients feature for blocks in Gutenberg v6.8:

You can create blocks like it’s 1999 …

Matt Mullenweg, speaking at WCUS 2019

😂

You can find Matt’s keynote here:

Luke Chesser