• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Justin Joyce

Practical tips and tutorials about software development.

  • Standing Invitation
  • Featured Posts
  • Latest
  • About

Latest

Calculate Date Difference in Javascript

Posted Jan 19, 2023 — Updated Jan 10, 2024

You have two main options: Let’s go through a quick example of each approach. Using date-fns to get date difference Above, I mentioned luxon, day.js, and date-fns. They’re all great packages, but I personally prefer date-fns due to its easily searchable documentation. date-fns has a ton of other functionality and the docs are very good […]

Filed Under: Dates, Javascript

How to find files on linux / mac

Posted Jan 19, 2023 — Updated Jan 10, 2024

Command line find is a powerful, underutilized tool. In this post, I’ll go through the following use cases: Find files by name I use this all the time. Let’s say I’m in my ~/Downloads directory. That directory has several hundred files in it—and quite a few subdirectories—so it’s a bit hard to comb through in […]

Filed Under: Command Line, Productivity

How to exit Vim

Posted Dec 27, 2022 — Updated Nov 1, 2023

My preferred method is “:x”. It saves the file only if there is a change to be saved, and then exits. You can also use :wq, :q, or :q!—each one behaves slightly differently.

Filed Under: Vim

Grep, grep options, and grep’s faster open-source alternative: ripgrep

Posted Dec 24, 2022 — Updated Feb 7, 2024

Tldr: Grep In large codebases just finding the things you need can be hard. The built-in solution on linux/unix is grep. The basic format is grep {search_term} {file_path}. Here are a few simple examples: Here are a few commonly-used useful flags for grep: Flag Effect -i makes search case-insensitive -r recursively search directories -n show […]

Filed Under: Command Line, Featured, Productivity, Tools

Reading CSVs in Python

Posted Dec 21, 2022 — Updated May 15, 2024

When reading in CSVs in Python, you have two main options: Let’s go through an example of each using a spreadsheet containing some US political funding data I have around from a personal project. Option 1: Python’s csv module: That’s it! Now you have access to the data in a list of dicts. You might […]

Filed Under: Python

Python Context Managers: the “with” Statement

Posted Dec 19, 2022 — Updated Jan 10, 2024

When reading and writing files in python, you’ll often see the use of with: This is called a Python context manager, and it’s essentially an automatic way to clean up after yourself. The code block above is functionally equivalent to this block: Without a context manager, we have to remember to manually .close() the file, […]

Filed Under: Python

Swapping dict keys and values in Python

Posted Dec 18, 2022 — Updated Jan 10, 2024

Sometimes you need to invert the keys and values in a dictionary. Fortunately, Python gives us a concise way to do exactly that with list comprehensions and dict.items(): However, if you have nested dictionaries this method won’t work: This error is caused by attempting to use the entire “address” dict as a key in the […]

Filed Under: Python

Convert between timezones in Javascript

Posted Dec 17, 2022 — Updated Jan 10, 2024

Javascript dates are frequently stored in UTC, or Coordinated Universal Time, specifically so we don’t have to store time-zone-adjusted dates. You’ll often see ISO-formatted date strings ending in Z like this: 2022-12-15T21:07:49.883Z. That Z means “Zulu”, and is just military jargon for “UTC”. Greenwich Mean Time (GMT) is also exactly the same: GMT === UTC […]

Filed Under: Dates, Javascript

Merging Python Dictionaries

Posted Dec 14, 2022 — Updated Jan 10, 2024

Merging dictionaries in Python is a common task, and there are a few ways to do it: The unpacking operator ** Since Python 3.5 (circa 2015), the simplest way to merge dictionaries has been with Python’s unpacking operator ** : It’s worth noting that if the objects being merged share a key, the last one […]

Filed Under: Python

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 4
  • Page 5
  • Page 6

Primary Sidebar

Recent Posts

  • Every Built-In Vim Color Scheme (with screenshots)
  • Reverse a string in Python
  • Meeting Cost Calculator
  • Vim find and replace
  • What makes an effective development team

Categories

  • Arrays (5)
  • Command Line (9)
  • Dates (3)
  • Featured (7)
  • Git (7)
  • Golang (5)
  • Javascript (8)
  • Productivity (8)
  • Projects (4)
  • Python (15)
  • Regex (2)
  • Ruby (3)
  • Shell (2)
  • Thoughts (2)
  • Tips (11)
  • Tools (3)
  • Tutorials (1)
  • Vim (4)

Archives

  • July 2024 (1)
  • February 2024 (1)
  • January 2024 (1)
  • December 2023 (1)
  • November 2023 (1)
  • October 2023 (4)
  • September 2023 (1)
  • August 2023 (2)
  • July 2023 (5)
  • June 2023 (3)
  • May 2023 (6)
  • April 2023 (5)
  • March 2023 (5)
  • February 2023 (10)
  • January 2023 (6)
  • December 2022 (7)

Copyright © 2025 · Contact me at justin [at] {this domain}

  • Privacy Policy