Archives

Blog index

Blog

  • Rebuilding cagrimmett.com and Moving Old WordPress Posts to Jekyll


    Earlier this week I did a major revamp of cagrimmett.com. It started with redesigning my page templates to include a sidebar, then it morphed into making a long-standing goal of mine reality: Reviving the posts from my old 2008-2012 WordPress blog and getting them into Jekyll.

    The Redesign

    The redesign started as a seed in my mind when I visited http://datavisualizi.ngArchived Link a few months ago. I loved the look of the sidebar with the social links. What I didn’t love about it was the way the menu works and how the sidebar is sticky. I noticed the site is also built on Jekyll, so I briefly considered installing the theme, but I decided against it after about 30 seconds. I wrote most of my current theme myself and don’t want to mess up my TIL and Book Notes templates. So I took an afternoon and rewrote some of my templates to include a sidebar.

    The trickiest part was figuring out what I wanted to do with the sidebar on smaller screen sizes. I decided to push it up to the top on pages, show the social buttons on the Home and About pages, and then hide it altogether on posts.

    The other main issue was what to do with featured images. My templates were built to include featured images on posts before, but this time I decided to make them optional. The home page and archive pages don’t display featured images, but the category pages do.

    Migrating my Microblog to Jekyll

    Last year I started a Microblog, built a custom theme for it, and posted there 116 times over a few months.

    I found it confusing to have multiple places to store content, so I decided to consolidate. I’m keeping cooklikechuck.com separate, but I’m killed cagrimmett.com and moved all the posts here. This was originally on WordPress, so it a small test case for whether or not it would be possible to resurrect my old 2008-2012 blog and migrate the posts to Jekyll.

    There is an official jekyll-import gem that supports WordPress, so I figured that this was going to be a piece of cake. That is, until I tried to install the gem. An hour later and 5 dependencies deep down the debugging rabbit hole, I finally gave up. Cryptic error messages somewhere around the mysql2 dependency finally made me throw in the towel and go to bed.

    I woke up the next morning with a renewed sense of confidence and started searching. I came across this WordPress to Jekyll exporter, which worked phenomenally well. It dumped all of my posts out as .md files with the WordPress metadata translated into YAML front matter.

    I was a little worried about what to do with all of the image links, but then I realized that all uploaded images in WordPress are stored at /wp-content/uploads/year/month/filename.jpg. If I add that /wp-content/uploads/ directory to Jekyll wholesale and replace all instances of cagrimmett.com with www.cagrimmett.com, all images in posts will work! So I pulled the directory down off my server, dusted off my grep skills, and everything worked as intended. Success.

    The only other hiccup was that about half of my posts on the microblog didn’t have titles. That is part of the whole microblog philosophy. Those posts showed up in my main feed with just ID numbers, which looks strange. I solved that by adding hidden: true to the posts to hide them from the Jekyll paginator. Win number 2 for the old grep skills.

    Resurrecting CAGblog

    After my success with copying over my microblog posts, I decided to kick the difficulty up a notch and see if I could move over 500 posts from my old 2008-2012 site, which I affectionately called CAGblog. I was eager to get this stuff back online because 2008 is when I first started blogging, and I wanted my internet cred back. I know some of my stuff from when I was 18 is pretty cringeworthy, but having my old stuff up for posterity really matters to me.

    Here is one of the few screenshots I have of it, from 2008:

    CAGblog

    Before I shut the blog down in 2013 and put up a landing page in its place, I made a backup and promptly forgot where I stored it. After hours of searching old hard drives, I finally found it on dropbox.com. It hadn’t synced to my local machine because I had selective sync turned on. I almost panicked earlier because I thought I had lost all my old stuff. Thank goodness for Dropbox!

    The first step in the revival was to restore my old database to a working WordPress site so that I could install the Jekyll exporter plugin. I only really needed the posts, not a complete working site, so I ignored all my old post templates and stuff. The database was from an early version 3 of WordPress, so I was concerned that it wouldn’t work on my Homestead dev environment and I’d have to go hunt down an old WordPress install somewhere. Thankfully WordPress has a bunch of update routines in place to handle just this kind of thing, so after going through a few “You need to update this database” prompts, I was able to log in to the wp-admin area and access all my old posts.

    Just like on cagrimmett.com, the WordPress to Jekyll exporter worked exactly as intended. Now the fun began: I had a ton of old categories and tags I didn’t want to use, old images I needed to find and get linked up, and old links that needed to be rewritten.

    Categories and Tags

    For categories and tags, I simply edited the yaml metadata on the old posts and changed the keys to oldcategories and oldtags so that Jekyll wouldn’t parse them as normal. Grep win number 3.

    For old images, I used the same method as on my microblog: I moved the wp-content/uploads/ folder to the root of my Jekyll site. That took care of about 50% of the broken images. The rest were scattered around other folders, so I searched for broken images, looked at where they were, and moved over every folder I could find. There are a few casualties, namely images that I didn’t host myself, but the vast majority are back up and running. I was a n00b 10 years ago and just threw stuff in my main directory, so now I have a bunch of old stuff cluttering up my previously pristine main Jekyll folder. Perhaps one day I will move all that to more logical folder structure and write redirects, but for now it is all staying where it is.

    The links aren’t easy to preserve on a static site because I used the default post ID permalinks on my WordPress site. Those are the ones that look like website.com/?p=2347. I used the permalink key in Jekyll to set the permalink to /blog/[oldid].html. (Another win for grep. Man, regex is useful.) Then I followed this post to do some apache magic, fetch the ID from its query string, and redirect it to its new home. Now all of my old post links redirect to their new home on my Jekyll site! I clicked a few old ones from Facebook just to make sure.

    When I moved to Cloudflare, my site search broke. With all of this old content back on my site, I knew I needed to get search working so the posts are findable, so I took a look at it again. The issue was that I had been submitting the form action to the same page. The query string didn’t get preserved with all the redirects/rewrites I’m doing/Cloudfront does, so I edited the submit function to just kick off the JS search function with the query directly instead of submitting/refreshing the page. Go run some searches and dig through my archives!

  • SVG Viewbox


    Today I wrote an article for the Praxis blog outlining four free charting/visualization tools and showing examples of visualizations created with those tools. One outputs SVGs, but they are a fixed size. But since SVGs are just code, I figured I could make it responsive.

    First I tried the old responsive image trick: width: 100%; height: auto; – This resulted in the SVG scaling, but only the top 10% was visible.

    After some Googling, I came across this article: How to Scale SVG on CSS Tricks. Here I learned about the viewbox attribute. The viewBox does many things:

    • It defines the aspect ratio of the image.
    • It defines how all the lengths and coordinates used inside the SVG should be scaled to fit the total space available.
    • It defines the origin of the SVG coordinate system, the point where x=0 and y=0.

    My original SVG was 848px by 500px. So, I set viewbox="0 0 848 500" and width=100% and removed the height attribute.

    This led to a nice scalable SVG:

    2005200620072008200920102011201220132014201520162017East GateNorth GateNortheast GateSouth GateWest GateHighway 191

  • Altcoin Research: What is Sia?


    This month I’m spending some time researching altcoins. I’m posting my notes on Yours.org. First up: Sia. https://www.yours.org/content/altcoin-research–what-is-sia–c72e723a56a0

  • Persistence with Chrome Dev Tools


    TIL that you can save changes you make with Chrome Dev Tools directly to your disk instead of having to copy and paste them out (or forgetting to and accidentally hitting refresh, which I do at least once a day.)

    More info here: https://developers.google.com/web/tools/setup/setup-workflow

  • CSS Confetti


    TIL how to make confetti with CSS. No javascript needed.

    I used this codepen as a base and modified it to my needs. The author, @fionnachan, had an interesting method I hadn’t thought of: Make a div for each piece of confetti, transform and skew each one, and then set a random offset so it looks like each one moves independently when you apply keyframes animation. @for in SCSS makes the random offsets and transforms a breeze.

    The only downside is that it compiles to almost 4000 lines of CSS. I’m going to try a JS version and see how it performs in comparison.

    UPDATE January 7, 2018: I moved to a JS solution based on https://codepen.io/anon/pen/JMOQzE. 50 lines of code + a jQuery dependency that was already getting loaded anyway is much better than 4000 lines of CSS, even if the CSS is novel.

    CSS Confetti

  • WordPress Template Hierarchy


    TIL a ton about the WordPress template hierarchy and the conditionals that select them.

    Relevant resources:

    1. https://developer.wordpress.org/themes/basics/template-hierarchy/
    2. https://codex.wordpress.org/Conditional_Tags
  • Genesis Framework’s Hooks and Filters


    TIL about the Genesis framework’s hooks and filters. I’m disappointed in how poorly they are documented. I spent most of my time digging around in the Genesis base theme’s /lib/ folder deciphering their functions and figuring out what powers what via trial and error.

    Here are a few resources that helped along the way:

    1. https://genesistutorials.com/visual-hook-guide/
    2. https://my.studiopress.com/documentation/hooks/hooks/hook-reference/
    3. https://my.studiopress.com/documentation/filters/genesis-filters/filter-reference/
  • 100 Highlights of 2017

    Derek Magill’s 100 Things That Made My Year post inspired me to write one, too. Here are my 100 highlights of 2017:

    1. Making more trips back home to Ohio.
    2. Finishing up a large analysis and recommendation project for a large customer at eResources.
    3. Writing and publishing 261 original blog posts.
    4. Visiting TK and Michelle in LA.
    5. Visiting Joshua Tree National Park for the first time.
    6. Driving up the Maine coast and visiting Little Cranberry Island, the setting of The Secret Life of Lobsters.
    7. Getting an early morning email from Isaac Morehouse asking for a call, which led to me joining the team at Praxis. I joined as the CTO.
    8. Hiking around Acadia National Park in the rain.
    9. Spending a weekend with my best friend, Sean Nelson, at his new place in Chicago.
    10. Helping a suicidal friend.
    11. Surprising my journalist friend Liz Essley WhyteArchived Link with a custom portfolio website.
    12. Visiting with Marieke and Brent Desmond in the spring, learning about their engagement in the summer, and then attending their wedding in the fall.
    13. Building TK Coleman a new website.
    14. Rereading The Story of Your Life and Others by Ted Chiang.
    15. Going to one of my favorite restaurants, Ssam Bar, and having duck ssam for lunch.
    16. Going fly fishing with Amanda on the Delaware River and having dinner at Uncle Brother on our anniversary weekend.
    17. A week of reading and travel between jobs.
    18. Working with Sara Morrison, Brian Nuckols, and Derek Magill for a whirlwind three days in Atlanta to switch out marketing automation platforms.
    19. Standing by my parents’ fireplace this winter.
    20. Visiting the Machovina Carlsons, keeping an old friendship alive, and learning about how a loom works.
    21. Emailing Mr. Strohm, a teacher, former boss, and mentor, about books.
    22. Carrying firewood with my Dad.
    23. Making pizza from scratch with family.
    24. Working on my patience, empathy, and humility.
    25. Improving my javascript skills.
    26. Discovering some sci-fi classics for the first time from James Hogan and Philip K. Dick.
    27. More dates with Amanda.
    28. Losing some weight at the beginning of the year and successfully keeping most it off all year.
    29. Meeting so many awesome young people at Praxis Weekend 2017.
    30. Building the Praxis curriculum portal.
    31. Rewriting 90% of the Praxis bootcamp curriculum in my first 6 months.
    32. Having Thanksgiving with some new friends: Bjorn and Pamela.
    33. Preserving a lot of food that we grew or picked ourselves. Using your own ingredients adds a lot of character to the dish.
    34. Fun summer and autumn hikes and picnics with Amanda.
    35. Learning the ins and outs of both Hubspot and Salesforce from Sara Morrison.
    36. Learning sales and marketing skills from Isaac Morehouse, Derek Magill, and Brian Nuckols.
    37. Late night conversations with TK Coleman about technology and philosophy.
    38. Taking primary responsibility for the Praxis bootcamp curriculum.
    39. My Dad taking a new job at the Superintendent of Buildings and Grounds at the school district we both went to. He has my old email address from when I worked on the tech team there!
    40. Buying an iPad Pro and working with it outdoors multiple days a week.
    41. Meeting many of my Praxis coworkers in person for the first time in Atlanta.
    42. Successfully completing the Whole 30 in February and staying primarily low carb after that.
    43. Making conscious decisions about what high carb or high sugar items are worth consuming vs what isn’t worth the sluggishness that follows. This Christmas, in particular.
    44. Learning how to coach from TK Coleman.
    45. Spending more time considering other people’s perspectives.
    46. Watching Amanda’s professional growth at Convene.
    47. Learning from brilliant people at the NYC D3.js meetups
    48. Making an effort to discover new local places to eat and work. Amanda and I explored many small towns in the Hudson Valley on our Saturday work/play treks.
    49. Visiting my aunt, uncle, cousins, and grandfather in north Georgia and exploring the Chattahoochee National Forest.
    50. Making trips to celebrate family and friends’ birthdays in Chicago and Ohio.
    51. Writing Christmas cards for the first time.
    52. Making a conscious effort to give more praise.
    53. Making a conscious effort to own all of my mistakes, misjudgments, and miscalculations.
    54. Learning to draw. More importantly, breaking the misconception that I couldn’t ever learn to draw.
    55. Writing weekly posts about how I’m using my CSA vegetables led me to get creative about using uncommon vegetables. I heard more positive feedback about that series than all other Cook Like Chuck posts combined.
    56. Noticing small details like how detailed and interesting sardine packaging is.
    57. Upping my cocktail game with barrel aging.
    58. Visiting the farm where our CSA vegetables came from and getting to know the farmer.
    59. Getting more adventurous with my ingredients.
    60. Taking more time to document my work, cooking, and learning.
    61. Shooting some short videos of my Grandma and aunt talking about traditional family foods.
    62. Getting off the beaten path for coffee and food in cities we visit for the first time.
    63. Set up the automatic texting system with Salesforce, Zapier, and Zendesk to text people when they apply and when their application status changes.
    64. Automating things at Praxis like deliverable notifications, check-ins, Bonjoro tasks, and curriculum tracking.
    65. Ignoring 99% of the news in favor of books and podcasts.
    66. Made the Praxis network map.
    67. Made the Praxis Talent and Opportunities portals.
    68. Listening to my favorite wind chimes on the back porch at my parents’ house.
    69. Chatting with Grandma in her Sun Room.
    70. Talking through situations with coworkers where we had strong disagreement and quickly resolving them by explaining our reasoning. Everyone I work with is very reasonable, and I couldn’t be happier about that.
    71. Amanda and I coaching her brother through the career change and job finding process.
    72. Figuring out how to thaw a frozen windshield washer fluid line during a road trip.
    73. More deliberately taking advantage of inspiration when it strikes, but also not waiting for inspiration to make progress on work.
    74. Cryptocurrency taking off in a massive way.
    75. Coming together as a team to handle curveballs and setbacks, and subsequently growing from that.
    76. Taking a stand against ad tracking by discontinuing use of Google Analytics, Disqus, and email open tracking. I also block trackers in my email clients and browsers.
    77. Taking more time to notice the beauty of the Hudson River and the Palisades.
    78. Watching the snow.
    79. Learning to ask myself, “Is this a drop everything problem?” And setting appropriate priority from there.
    80. Shifting my mindset from fulfilling contractual agreements to providing as much value as possible.
    81. Starting the shift from being at the beginning of my career and jumping in on everything I can to saying no and prioritizing.
    82. Making a dedicated effort to question my own assumptions and take note of when I fall prey to fallacies and illusions.
    83. Hiring my first trainer to align incentives and get my physical fitness in order.
    84. Realizing that instead of driving people toward a certain decision, it is best to lay out the costs and benefits as you see them, have a discussion about them, and have the person reach their own conclusion. Personal buy-in is key.
    85. Deciding to go all-in on personal responsibility and rejecting political solutions and shifting responsibilities to others.
    86. Starting breathing routines.
    87. Using Exist.io to pull in and correlate my activity data and track my mood, and checking in with myself midday to ask, “what can I do to make today better?”
    88. Realizing that how you approach problems mentally is more important than the mechanics solving them.
    89. Learning about Claude Shannon.
    90. Realizing that there is a strong connection between your physiological state and your mental state and making physiological changes accordingly.
    91. Visiting Uncle Bernie before he passed away unexpectedly.
    92. Stretching more.
    93. Giving lots of gifts to friends and family.
    94. Upgrading my camera from a 40D to a full frame 6D Mark II.
    95. Finding a fantastic used 24-70mm f/2.8 L series lens.
    96. Selling a bunch of stuff we weren’t using on eBay.
    97. Meeting a friend to eat our way around Flushing, Queens. Fantastic dumplings and an incredible tea tasting.
    98. Touring FDR’s homestead, the Vanderbilt mansion, and Staatsburg.
    99. Walking across the Walkway Over the Hudson in Poughkeepsie.
    100. Going to see the Hudson Valley Shakespeare Festival for the 6th year in a row.

  • CSS Grid


    TIL about CSS Grid and actually used it in a project to lay out blog posts. I put in a fall back to flexbox for older browsers.

    CSS grid blog

  • Basic Elements of Communication


    I listened to most of “A Mind at Play: How Claude Shannon Invented the Information Age” on a road trip today. I learned that all forms of communication share the same basic elements, no matter the sender or medium.

    Claude Shannon, the father of information theory, published “A Mathematical Theory of Communication” in 1948, which laid out these basic elements:

    1. A source produces the message.
    2. A transmitter translates the message into a signal that can be sent through a particular medium.
    3. A medium, over which the signal is sent.
    4. Noise interfering with the signal across the medium.
    5. A receiver, which receives the signal and translates it back into a format that the destination can understand.
    6. A destination, for which the message is intended.

    Here is a diagram I drew of these elements:

    Mathematical Theory of Communication

    All forms of communication share these same basic elements, including:

    • Email
    • Tweets
    • Text messages
    • DNA
    • Radio
    • Telephone conversations
    • Traffic signals
    • Television
    • Telegraph
    • Physical letters
    • Carrier Pigeons
    • Smoke signals
  • Guidelines for Putting Your Projects on Display


    We emphasize the importance of working out loud throughout our curriculum. Each of our participants make portfolio sections on their websites where they collect projects they’ve built. How you package and present your projects matter as much as the projects themselves! Here are some general guidelines for what makes a good project write up. https://discoverpraxis.com/guidelines-putting-projects-display/Archived Link

  • My WordPress Development, Testing, and Deployment Workflows


    Environments

    • I like having three distinct environments: – Local Development – All development happens locally, never on the server. – Staging – Staging is for pre-deployment testing and for team content tweaking before deployment. – Production – Nothing untested gets sent to production. It is always the working copy.

    Development & Testing

    Version Control and Deployment

    • I use Git for version control and deployment.
    • If I am working on the project solo, my local git repo is the main repo.
    • If I am working with other developers, the Github repo is the main repo and I start my day by doing a git pull.

    Here is my testing and deploying workflow:

    Testing and deploying

    1. git push staging master – Sends the code up to the staging server on WPengine. If I have database changes to migrate, I do so immediately afterward. For pages/posts I use the general WordPress exporter. For theme settings, both main theme frameworks I use (Genesis and Total) both have theme settings import/export features. For widgets, I use the Widget Settings Importer/Exporter plugin.
    2. After verifying that everything works as intended with Step 1 and getting a second set of eyes on the team to verify, I run git push production master. This pushes my already tested code to the production environment. No code touches production without having been tested on staging first. If database changes need to be moved over, I’ll either use WPEngine’s Deploy Site tool for big changes, or export them from Staging and import them on Production for smaller changes or times when the database on Production is significantly out of sync with staging.

    Backing up my work

    At the end of my work day, I back up my work:

    back up

    This is a two-part process:

    1. git push github master pushes my day’s commits up to Github.
    2. gulp dumpDatabase dumps my database from Homestead and saves it to my hard drive, which gets replicated within 30 minutes to Backblaze.
  • Remember to Ask for Help


    Yesterday I worked on building the new Praxis website for 12 hours straight, from 12-12, after spending the morning on coaching calls with Praxis participants. I was getting a lot of good work done, then I hit a wall with coding out this timeline:

    timeline

    I tried a bunch of different solutions for about three hours. Nothing worked. I got frustrated and almost convinced myself that this just couldn’t be done. It was about midnight at this point. I knew how to make the month boxes offset from each other on the left and right and make the whole thing responsive OR make the month boxes overlapping like this and the whole thing static/non-responsive. But not both.

    Then, thankfully, I took a step back for a brief moment. The designer we contracted to design this is well-known and a great web developer in his own right. I was pretty sure that he wouldn’t design something that he couldn’t actually build himself. So I emailed him and asked for guidance.

    Within a few hours he got back to me with a rough solution. He immediately pointed out two things that alluded me:

    1. Making 3 discrete sizes makes much more sense than making everything completely fluid
    2. The floats work well with content in them, but are completely broken without content in them. I tried to mock this up with very little content in it, which produced strange results. With content in place it functions as expected.

    With an hour and a half, I took the rough solution he outlined and turned it into a fully functioning polished version of the design.

    This was a great reminder for me:

    I don’t know all the answers, even if I think I do.

    When I start to get frustrated, I need to take a step back.

    Sometimes I need to ask for help.

  • Turn Your Defeat Into a Growth Story


    How do you address being fired when asked in an interview? Turn it into a growth story. https://discoverpraxis.com/turn-defeat-growth-story/Archived Link

  • Responsive Breakpoints in Sass


    Up until last week, Sass breakpoints were a bit of a mystery to me. I finally figured out how they work.

    First, they are programmatically generated. Define the breakpoints as a map. I use the list here.

    $breakpoints: ( 	xs: 512px, 	sm: 768px, 	md: 896px, 	lg: 1152px, 	xl: 1280px );

    Next, use a mixin and expressions to build the media queries. I use min-width. I leave it as an exercise for the reader if you wish to reverse this to use max-width instead.

    @mixin breakpoint( $breakpoint ) {     @if map-has-key( $breakpoints, $breakpoint ) {         @media ( min-width: #{ map-get( $breakpoints, $breakpoint ) } ) {             @content;         }     } @else if type_of( $breakpoint ) == number and unit( $breakpoint ) == px or unit( $breakpoint ) == em or unit( $breakpoint ) == rem {         @media (min-width: $breakpoint ) {             @content;         }     } @else {         @warn "No value could be retrieved from `#{$breakpoint}`. "                + "It is either not defined in the `$breakpoints` map, or it is an invalid number of px, em, or rem.";     } }

    To use, define your breakpoint styles using @import. Here is an example defining H1 font sizes at three different breakpoints:

    h1 { 		text-transform: capitalize; 		@include breakpoint(xs) { 				font-size: 2.2em; 		} 		@include breakpoint(sm) { 				font-size: 2.7em; 		} 		@include breakpoint(xl) { 				font-size: 3em; 		} }

  • 10 Steps to Becoming a Manager


    I saw this question on Reddit: I recently graduated with a degree in business management, but I’m having a hard time finding a management job. I’m not getting any interviews because I have no experience. What can I do? Here is my answer: https://discoverpraxis.com/10-steps-becoming-manager/Archived Link

  • A Crystemas Goman

    Yesterday I threw down a challenge to the Praxis community: 12 Days of Christmas Blogging. Blog every day from the 13th until Christmas. Flex that shipping muscle in the face of holiday obligations and time constraints. Stay on that grind when it is easy to let it slip.

    I’m playing with fire here because I have to ship, too. Like all good challenges, the blade has to cut both ways in order for it to be any fun.

    Here is yesterday’s post: How can I come up with more ideas?Archived Link

    This reminds me of my favorite Christmas story: Sir Gawain and the Green Knight.

    Sir Gawain

    The story opens with at King Arthur’s court where he and his men are exchanging gifts and getting ready to feast. A gigantic green figure atop a green horse rides into the court with an axe and a piece of holly. He challenges the court to “a Crystemas Goman” – someone can strike him with his axe and he will return the stroke in a year and a day. Sir Gawain rises to the challenge and promptly lops off the knight’s head with his own axe. Not missing a beat, the knight picks his head up off of the floor, reminds Sir Gawain that they have date at the Green Chapel in a year and a day, then rides off as abruptly as he arrived.

    I won’t ruin the rest for you. Give it a read this Christmas! The story teems with vivid, meaningful descriptions, double meanings, alliteration, imagery, and symmetry. It is a wonderful read.

    To mark the occasion of my own Crystemas Goman, here is a translation I did of my favorite passage. I used Casey Finch’s Complete Works of the Pearl Poet for the text and the Oxford English Dictionary for reference of word meanings.

    'Nay, frayst I no fyȝt, in fayth I þe telle;				279 Hit arn aboute on þis bench bot berdlez chylder. If I were hasped in armes on a heȝe stede, Here is no mon me to mach, for myȝtez so wayke. Forþy I craue in þis court a Crystemas gomen, For hit is Ȝol and Nwe Ȝer, and here ar ȝep mony: If any so hardy in þis hous holdez hymseluen, Be so bolde in his blod, brayn in hys hede, Þat dar stifly strike a strok for an oþer, I schal gif hym of my gyft þys giserne ryche, Þis ax, þat is heué innogh, to hondele as hym lykes, And I schal bide þe fyrst bur as bare as I sitte.			290 
    “Nay, on my word, I seek no fight;					279 There are about these benches but beardless children. If I were fastened in armor on a noble steed, There is no man here to match me, for their strength is weak. And so I ask in this court for a Christmas game, For it is Yule and the New Year, and here are many agile fellows. If any in this hall holds himself hardy enough, Be so bold in his blood, mad in his mind, That dare swiftly strike one stroke for another, And I shall give him as my gift this well-wrought guisarme, This axe, that is plenty heavy, to handle as he likes, And I shall endure the first blow as bare as I sit.			290 

    Details

    • Frayst: (verb) Ask, seek, try, or test. From Fraisten. (a) To seek or search for (something), esp., to seek adventure or combat, go in quest of; (b) to seek or indulge in (worldly things). – I chose “seek” here because each definition had this in common and because “to seek” is an attempt to find something, which captures the uncertainty of the Green Knight barging in to Arthur’s court, even if he were seeking a fight, because he must be uncertain he will find one. Unfortunately, this translation does not preserve the alliteration in the line (frayst, fyȝt, fayth) but I think using the sequence (to seek, fight, on my word) better preserves the meaning, albeit at the sacrifice of some beauty.
    • fyȝt: (verb) to fight, contend. From Fighten: to contend with weapons, engage in armed conflict (en masse or singly), do battle. Or, (noun) hostile engagement, fight, spiritual or moral struggle. – I think “fight” works best here because just a few lines earlier in the poem uses a different word (batayl) which can mean battle or contend, so if the poet wanted to repeat that, he could have. He instead used “fyȝt” (likely to alliterate). Also, “fight” is more personal than “battle.” Since the Green Knight came alone looking for trouble, he would be looking for a fight, not a battle (which implies large groups fighting.) Also, “contend” today means to struggle with something or engage in a competition, which could have been the case for the Green Knight, but I think “fight” fits better with the other words in the line.
    • Finch’s translation throws in “have I come” at the end of this line which does not appear in the ME. While that phrase seems to be implied in the ME, it is not stated, so it does not make a lot of sense to add it in to the translation. Finch seems to add a lot of unnecessary words in this translation.
    • fayth: (noun) belief, religion, word of honor. From Feith. A formal pledge, assurance, or promise. Also, ‘a confidence’ in someone, so it’s both an outward motion and an inward stance. – I chose “on my word” here to reflect the tradition of and emphasis on oral oaths that knights had and to take into account the phrase “I þe telle” at the end of the line. “On my word” conveys the idea of a spoken pledge, which takes into account both “fayth” and “telle.” To give one’s word is a verbal pledge that someone must take in faith.
    • telle: (verb) from Tellen. tell, speak, say, describe, express, utter, report – See explanation for “fayth” above.
    • Hit: it, there, etc. – Paired with “arn” it is appropriate to translate this as “there are” since the line is about all of the men (plural) on the benches.
    • Aboute: (adv) about, around, towards every side, in all directions, in every part of something, everywhere, throughout – About gives the idea that they are on and all around instead of just around the benches. Also, “about” is a concise way to both alliterate with “are” and to portray the idea that the only people the Green Knight sees on and all around the benches around the table are “berdlez chylder.”
    • Bot: but, only quite, except; Alternate definition: a parasite affecting the skin. – I chose “but” here as it seems the most likely translation for “bot” and it alliterates with “benches” and “beardless.” I found it interesting, though, that “bot” is also a skin parasite. It is possible, if this parasite was common, the Pearl poet could have a little laugh at the idea of beardless youth/puny men being parasites upon Arthur’s benches. I think it is unlikely that this is the first meaning of the line, but it is interesting nevertheless. “But” better fits the idea that the only men around Arthur’s bench are “berdlez chylder” and the Green Knight is poking fun at them.
    • Berdlez: (adj) Without a beard, beardless, not having reached manhood, underage. – “Beardless” is both alliterative and a concise way to call out Arthur’s men as being puny and not worthy to fight a real man like the Green Knight. Calling a man beardless is a pretty good jab at him. It implies – “You must not be a man because you can’t grow a beard.” This leads to the next word.
    • Chylder: (noun) youth, child, a youth of noble birth, esp. an aspirant to knighthood – The Green Knight does not actually mean there are children sitting around Arthur’s table. He is poking fun at the strength and size of the men. They are all likely around the Green Knight’s physical age, but he is saying he is stronger than they are and they are not worthy to be called men. Using “children” here is more of a jab in modern language at the men around the table than calling them “youth.” Calling a losing football team “youths” will get you yelled at. Calling them “children” will probably get you beat up. When the Green Knight says these first two lines, he is basically saying he is not seeking a fight because there are only little boys here, not men worthy enough to fight him.
    • Hasped: (verb) from Haspen: To fasten (a door) shut; to fasten (a helmet), buckle or lace; to wrap (oneself) in a garment; enclose (in armor, clothing); to embrace (someone’s neck), clasp. – Taken together with “in armes” I translated this as “fastened in armor” because being wrapped or enclosed in armor does not make much sense. A warrior or knight fastens his armor in preparation for a fight to make sure it does not fall off.
    • Armes: arms, armor. Taken together with “hasped in arms” would then mean to be fastened or buckled in one’s armor. (See previous explanation.)
    • Heȝe: (adj) high, lofty, noble, excellent, tall, great. – “noble” – See explanation for “stede” below.
    • Stede: A splendid, noble, spirited horse; a riding horse, a steed; (b) a war horse, charger; – I preserved what this word becomes in modern language, “steed.” Paired with the previous word, I translated this to “noble steed.” The Green Knight is a big, powerful knight and thus should be paired with a large, noble steed on which to pursue glory. The word “noble” encompasses high, tall, and lofty in itself, so I think it appropriate.
    • Note: This line is somewhat factious because the Green Knight just charged into the room on his massive steed in his armor. The “were I” is a conditional and a roundabout way to say that he can beat anyone in the room. Since he is in armor on his steed, he is saying that no one in the room is as powerful as he is. Also, a note on Finch’s translation: “on a heȝe stede” does not really match up to “warlike on steed.” Heȝe refers to the steed, not the Green Knight. Finch takes a lot of liberty with this line.
    • Mach: (verb) from macchen: To be an adequate opponent for, equal; be equal to, to match. Or: To marry; to become familiar with; to be paired with, work for, serve. Or: To fight, oppose, attack; also, to attack and overcome. – I chose “to match” here, but with the different definitions it could go multiple ways. Referring back to a hypothetical fight, “to match” works well here because it can mean an opponent that the Green Knight is paired with or that there is literally no one in the court to match the Green Knight’s skill and strength. The word play is interesting here, though: the “work for,” or “serve” can mean that there is no one in the court that the Green Knight would even let work for or serve him. Basically, the idea I tried to capture is that there is no one in this court, by the Green Knight’s opinion, as great as he is.
    • Myȝtez: from myȝt: might, can, may, will. Or: physical energy, vitality, vigor; exhausted, unconscious; very vigorous; physical strength. – I chose “strength” here because, paired with “so wayke,” “may” does not make sense and the idea of “feeble physical energy” is not very appealing. The idea that no one can match the Green Knight because their strength is so weak makes a lot more sense and fits in with the storyline. Also, see part of the explanation for “wayke.” The potential word play here is interesting, though, if “exhausted” or “unconscious” is taken to be the translation of myȝtez, because we get the line to mean something like: “There is no man here to match me, for they will be exhausted because they are so weak.” It adds a little different meaning. I think “strength” here fits better, though, because the Green Knight is continuing his jabs at them by calling their strength weak.
    • Wayke: (adj) Weak, feeble. Of combative strength: ineffectual; deficient in bodily or muscular strength – I picked “weak” as it has the connotation of the rest of the possible definitions. “Deficient bodily or muscular strength simply means “weak” in modern usage. (This also strengthens the case for using myȝtez to mean “strength.”) Calling someone’s strength weak in modern language has a little more of a sting to it than calling their strength feeble or ineffectual. See part of the explanation above.
    • Note: Finch’s translation of this previous line is intriguing, especially since he takes the last part to mean: “though mighty and sure.” The mighty part works well, but nowhere did I find wayke to mean “sure” – Finch in the back does not even translate it that way. In the back, it is translated similarly to above.
    • Forþy: (conj) For that, on that account, therefore, consequently, accordingly, and so. – I chose to translate forþy as “and so.” This one was somewhat difficult for me because I think the meaning of “therefore” might have changed from ME to modern english. When I think of “therefore,” I think of something logically following from the previous statements. This does not: I am not here for a fight, therefore I am here for a game. “And so” captures the idea that the Green Knight is not here for a fight, “and so” he will reveal what he is actually here for. This is one spot where I really like Finch’s translation. Finch translates it as “No! I come to this court…” This captures the idea that the Green knight is reaffirming that he is not there for a fight and he reveals what he, therefore, is there for. (Ha, couldn’t resist.)
    • Craue: (verb) From craven: to ask or beg for. Or: To long for, desire. Or: (noun) neck; throat; crop of a bird or fowl, craw. – Given the context, I think the neck/crop of a bird meaning is right out. In this case, I think it is either to ask, beg, or desire. I translated it as “ask” because it fits in with coming to the court to “seek” something… ask and seek go hand in hand. There is potential word play here and it can go multiple directions. For example, if craue is taken as “beg,” we get a very different situation with the Green Knight. Instead of the GK being in charge of the given situation, he is at the mercy of Arthur if he is begging. Also, if we take craue as “desire” we get another meaning (explained in gomen below.)
    • Crystemas: Christmas
    • Gomen: game, festivity, revelry; a pastime, amusement; or joy, happiness. – I chose “game”here for the mystery associated with “Christmas game” that gets the reader wondering what this game is. There is wordplay going on, however. Should we take gomen to mean festivity or revelry, we get a different meaning because Christmas festivities and revelries are exactly what is going on at the court. Of course, when we read ahead, we understand that he is looking for more than revelries, but a game which he will spell out. If we take gomen to mean joy, we get yet another meaning, especially if we choose craue to be desire and gomen to mean joy. In this case, the Green Knight would have came to the court desiring Christmas joy, which could be a number of things. Again, if we read ahead and find out what he is really looking for, the “Christmas joy” must be a very strange notion of joy. I think game fits best.
    • Ȝol: Yule, the Christmas season generally, Yuletide or Christmastime; specif. the festival season from Christmas Eve to Epiphany
    • Nwe Ȝer: New Year
    • Ȝep: Physically agile, skilled at a physical activity, adroit; nimble, active, quick; vigorous, lively; also, youthful in appearance or manner Or: Mentally agile, sharp-witted, astute, clever; also, as noun: clever fellows; full of stratagems, wily; also, full of sleights, crafty, cunning – I chose “agile” here to preserve the poet’s open-ended meaning. Agile can refer to either mentally or physically agile – we will only know when the Green Knight reveals the game. (When he does, we realize it is a sense of both.) For either mental or physical, agile covers the other possible ways of translating this word. There is also a word play going on here with relating the mental or physical agility of the men to the season. A new year is seen to be lively, vigorous, and agile. Also, strangely, the poet says in this line that there are agile or lively men in this court, right after he pokes fun at them for being “berdlez chylder.” I haven’t quite figured out what to make of this except that he is possibly tempting them into his “game” with this statement.
    • Mony: many, many a one; Or money; Or moon. – I was unsure about this word because I could not find a clear definition of it. There are a number of words in the MED that looked like they could work, but none of them made sense in the context (like money or moon.) I just settled on many because that is what the reference in the back of Finch used and it works well with the the idea that there are many agile fellows in Arthur’s hall. I suppose the translation could be something like “and here is cunning money” but I am not sure that fits in the poem.
    • Hardy: (adj) Physically tough, hardy, enduring, brave, bold; of actions, faith: requiring resolution or courage, firm, fierce; Or: Audacious, presumptuous, rash, foolhardy – I translated this as “hardy” – the same as in ME, because it preserves the open-ended meaning of the word. The word play here is interesting… it could mean bold, tough, brave, or firm on one hand, or presumptious and rash on the other hand. Of course, these seemly different meanings go hand in hand–pride is a double-edged sword.
    • Hous: (noun) house, building, hall, etc. Or a covering for the back and flanks of a horse, horsecloth; also, a saddle cloth; a protective covering, case, sheath; – I translated this as “hall” since these scene takes place in Arthur’s hall. Also, I wanted to preserve alliteration here: (hall holds himself hardy.) Another possible meaning emerges if we takes this as either a protective covering or a saddle cloth: the Green Knight could be poking fun at the men that act bold when protected from blows by armor or when they sit high on a horse, but would get defeated easily.
    • Holdez: holds, claims, thinks, views. – I chose “holds” for holdez in order to preserve the alliteration in this line. Changing from holds to claims, thinks, or views has a slight change in meaning, but nothing of depth. Since these have close to the same meaning in the context of the line, I chose the one that alliterates the best to preserve the alliteration from the ME.
    • Hymseluen: himself
    • Bolde: bold, valiant, daring. Of persons: brave, courageous, daring, fearless. Or: overconfident, forward, rash; brazen, presumptuous, shameless, impudent; – I chose “bold” here because bold has multiple meanings in modern language, just as it does in ME. Again, there is good word play here with the line between boldness and overconfidence.
    • Blod: blood, emotion, anger, passion, (sexual) desire; courage, mettle, spirit; temperament, nature; Or: A living being, a creature, a person. – I chose “blood” here for two reasons: alliteration with bold and one of its modern meanings: temperament or disposition. We can choose any of these words and get the line to mean something slightly different, but having a bold temperament pretty much covers most of these. The poet could be pulling in a critique of knights under the rug if he had in mind that bolde in blod could mean bold or shameless in sexual desire.
    • Note: It is important to keep in mind that tweaking any of the words in a line could give the line a different meaning every time. Since each of these words in ME has multiple meanings, the meaning of each line (not to mention how each line interacts with each other line) starts to cover a wide range very quickly.
    • Brayn: (adj) mad, reckless, insane. (noun) brain (body part) – This has two different meanings depending on if we use it as an adjective or a noun. If a noun, then we get the end of the line to be: “brain in his head”-which is a fact, but not very insightful. We all have brains in our heads. If we take it as an adjective, however, we get “mad in his head,” which points to insanity. I chose to treat it as an adjective and translate it as “mad in his mind” in order to preserve the alliteration of the line (though as Ms instead of Hs) and so that it adequately reflects the beginning of the line. (boldness and insanity can be different sides of the same coin.)
    • Hede: head, the seat of the mind; the mind; heart and mind; headstrong rashness; impetuously, rashly, unadvisedly. – I chose “mind” here in order to create some alliteration and to help convey the idea of insanity. Given the other possible meanings of “hede,” I think this is justified. (headstrong rashness; impetuously, rashly, unadvisedly)
    • Dar: (verb) dare, to have the courage to, to be able to, or shrink, cower, bow down, submit. – I chose “dare” here to portray the idea that someone might be mad enough to have the courage (read: dare) to take the Green Knight up on his offer. The interesting possible word play here is that instead of dare, one might be mad enough to “bow down,” “shrink,” or “submit” to the Green Knight’s game. This could be pointing back to the beginning of the Green Knight’s monologue where he makes fun of the men for being weak. He could be suggesting that if they give in to his game they are weak in yet another way and can be easily manipulated.
    • Note: What is intriguing here is that the one who is “mad in his mind” and “dares” to take the Green Knight up (or is manipulated by him) initially is only King Arthur…
    • Stifly: Staunchly, steadfastly; unwaveringly; without ceasing, persistently; also, refractorily, stubbornly; boldly, swiftly, valiantly, courageously; also, proudly; also, loyally. – I chose “swiftly” here for alliterative purposes and to portray the motion of swinging a large axe through words. Also, it gives the connotation of someone stepping up without hesitation to exchange one blow for another (because stifly has more than one meaning in this situation and I tried to preserve that.)
    • Strok: (noun) A stroke, a blow delivered with a weapon; a slash, cut; a thrust or stab – I chose “stroke” here because a stroke is just one swing, which preserves the rules of the Green Knight’s game–one stroke for another.
    • Anoþer: another, a second. – Though there is not much here, I think choosing “another” over “a second” needs an explanation. One strike for another gives conveys the idea of that “another” being a reciprocal strike rather than a second strike from the hand that struck first. Though “a second” would have added to the alliteration, I don’t think the meaning was clear enough to warrant using it.
    • Schal: (verb) shall, will, must. – I chose “shall” here because the meaning of shall in modern language expresses a strong assertion. The Green Knight is giving his word (back again to the importance of oaths) and will not break it. This is a theme in the rest of the poem.
    • Giserne: A long-shafted battle ax or halberd with a knife-like point rising from the blade – or the gizzard of a fowl; the liver of a fowl or a hare; the entrails of a fowl. – I chose guisarme here because that is the modern word for the weapon the Green Knight had and gives the reader a definite idea of what it is. If giserne did, in fact, also mean the entrails of a fowl, then this line has comical undertones–the Green Knight giving one of Arthur’s men gizzards as a gift. It is almost certain the GK meant his axe, but the potential double meaning is comical.
    • Ryche: (adj) rich, splendid, ornate, fine, noble, costly, precious, well-wrought, well-made. – I chose “well-wrought” here because it assumes and subsumes the other adjectives I found for ryche.
    • Heué: heavy, serious, grievous. – I chose “heavy” here as I wanted to put the emphasis on the axe’s weight (see explanation for innogh below.) The poet had word play going on here, though, because the two other definitions for heué give the line different meanings. A serious or a grievous axe have darker, more chilling undertones than a heavy one. This possibly forebodes what might happen later in the poem.
    • Innogh: (adj or adv) enough, plentiful, generous, abundant, great, very. – I chose “plenty” here because not only is the Green Knight expressing the weight of the axe, but he is making another statement here as well. Earlier he said it is “noble” or “well-wrought.” The weight of it could be a sign of its authenticity. “Plenty” is the Green Knight’s way of assuring the men that it is indeed well-wrought and its weight alone might be sufficient to display that.
    • Hondele: (noun) A handle of a container, implement, etc.; a grip or hilt of a sword.
    • Lykes: likes, pleases, wishes, chooses, approves
    • Schal: (verb) shall, will, must. – Again, I chose “shall” here because the meaning of shall in modern language expresses a strong assertion. The Green Knight is sure he will endure the blow and he is making a promise to his hosts that this is the case.
    • Bide: (verb) remain, wait, stay, endure; from Biden: to experience or undergo (sth.); to suffer or bear (hardship, etc.); to enjoy – I chose “endure” here to express the idea that not only will the Green Knight take the blow, but he will patiently take it, he will not be harmed by it, and he will wait a while year before he retaliates (as we find out a few lines later.) To change “endure” to suffer or bear would be to irretrievably lose some of this meaning.
    • Bur: (noun) from burre: onslaught, blow, force, or strike. – I chose “blow” for alliterative purposes.
    • Bare: (adj) bare, naked, without armor, unprotected, or open. Also, unadorned, unornamented; simple, plain, crude, laid waste, destitute, or poor. – I chose to keep this as “bare” because it portrays the idea that the Green Knight is not going to have extra protection, pull any tricks, or try to defend himself. Bare can mean without armor and unprotected, but also open, which helps the idea that he will not protect himself. He will be under the axe just as Arthur’s men see him.
  • How can I come up with more ideas?


    The old saying, “You are what you eat”, applies to the creative process. If you want to be creative and come up with ideas, the best thing you can do is engage the creative ideas that are already out there. Not because you want to copy or emulate them, but because creative ideas catalyze other creative ideas. https://discoverpraxis.com/more-ideas/Archived Link

  • My BTC, BCH, and Ripple Strategies


    The past few days have been quite a ride in the crypto world! This rollercoaster is reminiscent of late 2013, except now there is much more skin in the game. My latest piece on Yours.org covers my history with BTC, BCH, and Ripple, and my investment and use strategies for the currencies. Read this piece over at https://www.yours.org/content/my-btc–bch–and-ripple-strategies-cb2b3d401e30.

  • Does the Environmental Case Against Bitcoin Have Merit?


    I’m not sure that we have a bitcoin-caused environmental energy crisis on our hands. This piece on Yours.org points out some of the issues with the articles going arount about bitcoin and the environment. Read this piece over at https://www.yours.org/content/does-the-environmental-case-against-bitcoin-have-merit–656fd7d75c0f.

  • Selling Photos on Yours.org


    This afternoon I decided to try Yours.org, a site where you can write articles, decide what to charge for them, and get paid in bitcoin cash. I had an idea: If you pay and then a section is revealed to you, that doesn’t have to be just for articles. It can be used for anything digital!

    A few ideas:

    • Podcasts
    • Photo filter packs for Lightroom
    • Digital art
    • eBooks
    • Word and Powerpoint templates
    • Photoshop and Illustrator files
    • Music
    • Videos
    • WordPress themes

    So, I decided to test it out. I packaged up four sets of national parks photos, put a thumbnail grid in the preview, and put a download link in the paid section:

    I’m testing three different price points: $15, $10, and $5.

    I also wrote a piece on how to use Yours.org for selling digital products. I priced it at $2.

    In just a few hours I made over $40 in bitcoin cash! It is super exciting seeing the notifications come in while you are reading other articles. I think that the notifications are tied to transaction verifications because they come in waves. That must be when blocks get processed and transactions verified.

    Yours.org articles

  • Bulk Clearing Expiration Dates in Restrict Content Pro


    At Praxis we use Restrict Content Pro as the membership system for our curriculum portal. We decided that all grads get access for life, not just during the program. So, I needed a way to clear over 200 member expiration dates. The only bulk method available through the WordPress interface is to set the expiration dates to another date in the future, which would just kick my problem further down the road. So I needed to dust off my SQL knowledge and directly edit the database.

    Step 1: Back up the database.

    Don’t be a fool. Back up your database and test the queries on a local development version first. Never run queries for the first time on production. The backup is also a failsafe that you can restore if something goes wrong despite your testing.

    Step 2: Find the data.

    I saw that all data related to Restrict Content Pro usually had rcp somewhere in the table, column, or key. So I started with the rcp tables. They had nothing to do with expiration dates, so I checked the wp_usermeta table since RCP extends the WordPress users with more functionality. Bingo. There was a column called meta_key with rcp_expiration in it with corresponding date values.

    Step 3: Make sure you are editing the correct data by running a SELECT statement first.

    Sure, you could run your UPDATE statement first, but I like to make sure I am editing the correct data by running a SELECT statement first and then using the same WHERE clause for my UPDATE statement.

    After a few stupid syntax errors, here is the SELECT statement that got exactly what I wanted. This shows the user ID so I can spot check, restricts searching to the rcp_expiration meta key, and looks for values that are not none.

    SELECT user_id, meta_key, meta_value FROM wp_usermeta WHERE meta_key = 'rcp_expiration' AND meta_value != 'none';

    This returned 176 results. When I changed it to show only meta values that were none, I got 31 values. 31+176=207, which is the total number of users. Looking good.

    Step 4: Craft your UPDATE statement.

    Now that we know we selected the correct data with our previous statement, it is time to craft our UPDATE statement.

    Here I’m updating the wp_usermeta table and setting the meta_value to none where the meta_key is rcp_expiration and the corresponding meta_value is not none.

    UPDATE wp_usermeta SET meta_value = 'none' WHERE meta_key = 'rcp_expiration' AND meta_value != 'none';

    I tested this on my local machine and it updated 176 rows. Just like we wanted.

    Step 5: Run the same query on production.

    Now that we’ve tested the query in our development environment and verified that we got the results we wanted, we can run the query on the production database. If you use phpmyadmin and want to triple check that you aren’t messing anything up, you can click the “Simulate Query” button first. (I did.)

    Step 6: Verify things worked.

    Log in to WordPress and check the RCP membership area. Verify that all expiration dates are now set to none. Also verify that your users can still log in. You should have a few user test logins specifically for this purpose. You can also check your site logs throughout the day to make sure people are still logging in. You can’t count on them always letting you know when something doesn’t work. More often than not they will just stop using it. It is up to you to verify everything works as it should!

  • Adding Months to a Calculated Date in Salesforce


    Adding dates is tricky. Months have different numbers of days, so you can’t rely on just adding 30 days to get an extra month. You also can’t just add a certain number of months because formulas in Salesforce don’t auto increment the year. The solution is modular arithmetic and conditionals.

    The goal here was to make a set of fields to send out emails on the first day of each month for 6 months, given a specific month to start with.

    What I’m doing here is:

    • Year: Figuring out the month number, adding one less than the number of months over all, dividing it by 12, and rounding down to add either a 0 or 1 to the year. You have to subtract one from the month because 12/12 = 1 and you don’t want December adding an extra year.
    • Month: If the resulting month is December, return 12. Otherwise return the month number modulo 12. (12 mod 12 is 0, hence the conditional).
    • Day: Always returning 01, the first day of the month.
    DATE(   YEAR( date ) + FLOOR( ( MONTH ( date ) + number_of_months - 1 ) / 12 ),   IF( MONTH ( date ) + number_of_months = 12, 12, MOD( MONTH ( date ) + number_of_months, 12 )),   01 ) 

    How to use this: the date variable should be the date field you are starting with. You should replace number_of_months with the number of months you want to add to the original date. If the date is 07/01/2017 I want this to go out on 08/01/2017, I’d set number_of_months to 1. If 09/01/2017, I’d set it to 2, etc.

    Note: This only works for the first of each month. If you need it to work on any day of the month, use this more complicated solution to account for months having different lengths.

  • Automating MySQL Backups with Gulp


    As I mentioned a few days ago, I’m using Gulp on a new WordPress project. I like to back up my work every night, and since a lot of WordPress config and customization happens in the WordPress editor and widgets, that means backing up the mysql database as well as the code.

    Why not use this newfound tool? Let’s do it.

    I did some searching and found Gulp WordPress Backup, but it was overkill for what I wanted. But I saw that it used an npm package named mysqldump, for the export, so I grabbed that and started setting up a new task in gulpfile.js:

    // add mysqldump as a dependency var mysqlDump = require('mysqldump');  // dumpDatabase gulp.task('dumpDatabase', () => { return new Promise((resolve, reject) => { mysqlDump({ host: 'localhost', user: 'user', password: 'pass', database: 'wp_database', dest: 'backup.sql' }, (err) => { if (err !== null) return reject(err); }); }) .catch((err) => { console.log(err); }); });

    Next step: Defining the filename. I just wanted to use today’s date because I intend on running this at the end of each work day. Since gulp is all javascript, this is easy:

    var today = new Date(), dd = today.getDate(), mm = today.getMonth()+1 //January is 0! yyyy = today.getFullYear(); if(dd<10) { dd = '0'+dd } if(mm<10) { mm = '0'+mm } today = mm + '-' + dd + '-' + yyyy;

    Add this to the gulp task and you are good to go!

    gulp.task('dumpDatabase', () => { var today = new Date(), dd = today.getDate(), mm = today.getMonth()+1 //January is 0! yyyy = today.getFullYear(); if(dd<10) { dd = '0'+dd } if(mm<10) { mm = '0'+mm } today = mm + '-' + dd + '-' + yyyy;      return new Promise((resolve, reject) => {         mysqlDump({             host: 'localhost',             user: 'user',             password: 'pass',             database: 'wp_database',             dest: 'SQLBackups/' + today + '.sql' // Outputs to the folder named SQLBackups and uses today's date as the filename.         }, (err) => {             if (err !== null) return reject(err);         });     })     .catch((err) => {         console.log(err);     });  });

    Make sure you add mysqldump to your project’s package.json, or at least run npm install mysqldump before using!

  • Fixing s3_website Java 9 Error with jEnv


    When I updated to macOS High Sierra, a bunch of necessary stuff broke: Jekyll, Homebrew, Node.js, and a bunch of gems. s3_website, the tool I use to deploy my Jekyll site to S3, was one of the gems that just completely disappeared. When I went to reinstall it, I got an error that I didn’t have Java installed. Against my better judgment, I went to the URL listed and installed it. Then I ran s3_website push.

    After about 30 seconds, I got an error saying that s3_website doesn’t work with Java 9, which was the most recent version at the link. And also the version you get with brew cask install java. Well, shit.

    Exception in thread "main" java.lang.ExceptionInInitializerError 	at org.jruby.Ruby.newInstance(Ruby.java:266) 	at s3.website.Ruby$.rubyRuntime$lzycompute(Ruby.scala:4) 	at s3.website.Ruby$.rubyRuntime(Ruby.scala:4) 	at s3.website.model.Config$$anonfun$15.apply(Config.scala:229) 	at s3.website.model.Config$$anonfun$15.apply(Config.scala:227) 	at scala.util.Try$.apply(Try.scala:192) 	at s3.website.model.Config$.erbEval(Config.scala:227) 	at s3.website.model.Site$$anonfun$2.apply(Site.scala:28) 	at s3.website.model.Site$$anonfun$2.apply(Site.scala:27) 	at scala.util.Success.flatMap(Try.scala:231) 	at s3.website.model.Site$.parseConfig(Site.scala:27) 	at s3.website.model.Site$.loadSite(Site.scala:100) 	at s3.website.Push$.push(Push.scala:62) 	at s3.website.Push$.main(Push.scala:40) 	at s3.website.Push.main(Push.scala) Caused by: java.lang.RuntimeException: unsupported Java version: 9 	at org.jruby.RubyInstanceConfig.initGlobalJavaVersion(RubyInstanceConfig.java:1878) 	at org.jruby.RubyInstanceConfig.(RubyInstanceConfig.java:1585) 	... 15 more

    After lots of searching, I came across a kind soul on Github suggesting that we use jEnv to define which java environment to use in the directory.

    When I first installed jenv, I couldn’t add versions to the tool. I kept getting this error:

    ln: /usr/local/opt/jenv/versions/oracle64-9.0.1: No such file or directory

    The fix is described here: https://github.com/gcuisinier/jenv/wiki/Trouble-Shooting. Once I added version 8 as well, I switched to version 8 locally with this:

    jenv local oracle64-1.8.0.151

    Then I opened a fresh Terminal window and ran s3_website again and everything pushed up to s3 without an issue.