Marc Blase

Converting Windows line endings to UNIX

Especially in the case of writing shell scripts. It’s imperative to move from CRLF (Win) to LF (*nix) so they will run.

Try this:

$ dos2unix FILE_NAME.EXT

if that doesn’t work, then try this.

$ sed -i 's/\r$//' FILE_NAME.EXT

Also, make sure you’ve set the permission bits so they can execute.

$ chmod 770 FILE_NAME.EXT
Published on September 3, 2024

Issue with register_post_type with custom capability type(s)

I have a plugin for a site that creates multiple custom post types (CPT). Each with their own custom capability specified via the capability_type attribute of the register_post_type() function. I copy-and-pasted the code block for each register_post_type() from the first one, which includes the capability_type as an array, ie. array('type' , 'types'). Some of the subsequent CPT didn’t need multiple capability types so I was receiving the warning ‘Notice: Undefined offset: 1 in post.php’ due to a single item in the array. The fix was to remove the array wrapping the single value, et voila, no more warning.

Published on January 17, 2024

Disable New User Notification Emails in WordPress

I use this when doing bulk imports of users in dev environments.

add_filter( 'wp_new_user_notification_email', '__return_false', 10, 3 );

Add that to functions.php and you’re set. Users will not be notified.

Published on September 29, 2023

Delete post revisions in WordPress with wp-cli

Easily remove revisions using wp-cli. First, get a list of revisions with:

$ wp post list --post_type='revision' --format=ids

This command will provide a list of revisions by post ID.

To remove those revisions, use to following command:

$ wp post delete $(wp post list --post_type='revision' --format=ids) --force

This command will provide feedback to stdout as Success: Deleted post XXX. Where XXX is the post ID of the deleted post. The --force flag may not be necessary, but was in my case since the command failed with the warning: Warning: Posts of type 'revision' do not support being sent to trash.

Published on August 11, 2023

Me on a bike (Winter/Spring 2023)

CES Northstar Enduro – Truckee, CA

SET Redemption Enduro – Eureka Springs, AR

SET O’Rock Enduro – Ouachita National Forest, OK

SET Dino Enduro – Dinosaur State Park, Glen Rose, TX

SET Return of the Zombie Goat Enduro – Flat Rock Ranch, Comfort, TX

Published on January 24, 2023

Me on a bike (Fall 2022)

TTP TEXAS ENDURO CUP – Spider Mountain, Burnet, TX

TTP TEXAS ENDURO CUP – Reveille Peak Ranch, Burnet, TX

results

Published on October 31, 2022

More Yard Birds

More birds that have hatched and/or fledged in my yard.

Great Horned Owls

Published on March 21, 2022

Change WordPress user ID

This is usually needed in order to secure the default admin user which has a user_id of 1.

Run these two mysql queries via your favorite interface.

UPDATE wp_users SET ID = 666 WHERE ID = 1;

then…

UPDATE wp_usermeta SET user_id = 666 WHERE user_id = 1;

Please note: you can use any number you want for the user_id as long as it doesn’t correspond to that of an existing user. I just chose the most metal user_id for this example. 🤘.

Published on February 24, 2022

Me on a bike (2022 Season)

Return of the Zombie Goat Enduro – Flat Rock Ranch, Comfort, TX

Dino Enduro – Dinosaur State Park, Glen Rose, TX

results

Published on January 23, 2022

2021 Top Listens

  1. Wilco
    319
  2. Sturgill Simpson
    279
  3. Paul Simon
    278
  4. Wally Clark
    249
  5. Steely Dan
    225
  6. Sault
    221
  7. Jazz Spastiks
    220
  8. My Morning Jacket
    220
  9. Band of Horses
    210
  10. our Old Droog
    197
  11. Benny the Butcher
    196
  12. Yo La Tengo
    184
  13. Michael Bublé
    173
  14. Enzo Carella
    172
  15. Ultramarine
    165
  16. Burrito Brown
    164
  17. MF DOOM
    162
  18. Larry June
    153
  19. Westside Gunn
    148
  20. Miles Davis
    146
  21. The Magnetic Fields
    144
  22. Delvon Lamarr Organ Trio
    142
  23. Always Proper
    139
  24. Berner
    139
  25. White Denim
    139
  26. The Shins
    133
  27. Emma-Jean Thackray
    127
  28. Richard “Groove” Holmes
    127
  29. Modest Mouse
    126
  30. David Bowie
    125
  31. PUP
    123
  32. Richard Swift
    120
  33. Lucky Brown
    115
  34. Moses Boyd
    115
  35. emune
    113
  36. Kurt Vile
    112
  37. Mocky
    107
  38. Adrian Younge
    105
  39. Conway the Machine
    105
  40. Nick Drake
    104
  41. Built to Spill
    103
  42. Wun Two
    102
  43. Bruno Pernadas
    100
  44. Fleet Foxes
    99
  45. Hot Snakes
    99
  46. Rhye
    98
  47. Theon Cross
    97
  48. Bright Eyes
    96
  49. Ted Hawkins
    95
  50. The Deli
    95
Published on January 3, 2022