DEV Community

mafflerbach
mafflerbach

Posted on

1

Ingredient list as QR code

As a good housewife I have a personal cookbook with all the favourite meals of my family.
Usually we are doing our weekly grocery shopping, for the whole week, on Saturday . On this day I also create a meal plan for the upcoming week and think about what i have to buy.

I'm using an App to manage my shopping list and I have to add the items by hand. But this App has a feature to import lists from the clipboard. And if I want to cook something new, I have to copy and pasting this in to my note App, reformatting as list, finally after this, I can use the import feature.
It is quite tedious and sometime painful do everything on my phone.

After thinking about how to optimize this work flow, I come up with following script:

#!/bin/bash

tickCount=0
ingredient=""
# read the recipe file 
while IFS= read -r line
do

    # checking for ticks as hint for the ingredient list start
    if [ "$line" == "\`\`\`" ] && [ "$tickCount" == "0" ]
    then 
        tickCount=1
        continue
    fi

    # checking for ticks as hint for the ingredient list end
    if [ "$line" == "\`\`\`" ] && [ "$tickCount" == "1" ]
    then 
        tickCount=0
        continue
    fi

    # as long as i am between ticks append the current line to the variable
    if [ "$tickCount" == "1" ]
    then
        lf=$'\n'
        ingredient="$ingredient$lf$line"
    fi

done < "$1"

# show the list
echo "$ingredient"
# print out the ingredient list as qr code in to the terminal
qrencode -t UTF8 $"$ingredient" -s 1 -o -

Enter fullscreen mode Exit fullscreen mode

Now, I have to digitalize all my cooking recipes in to markdown format, cause for the moment they are only handwritten in a book.

But the copy/pasting part of new recipes, are easier on a pc instead of a mobile phone. And if I am going further, I can write a scraper script which converting the html into markdown for me.

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs