Open-source News

Make a cup of coffee with Git

opensource.com - Fri, 04/01/2022 - 15:00
Make a cup of coffee with Git Moshe Zadka Fri, 04/01/2022 - 03:00 Up Register or Login to like.

Git can do everything—except make your coffee. But what if it could?

Like most people, I already have a dedicated coffee brewing device listening to HTCPCP requests. All that is left is to hook Git up to it.

The first step is to write the client code, using httpx:

More on Git What is Git? Git cheat sheet Markdown cheat sheet New Git articles >>> import httpx
>>> result = httpx.request("BREW", "http://localhost:1111/")
>>> result.text
'start'

Ah, nothing nicer than a coffee pot starting to brew. You need to do a few more steps to make this available to git.

A proper way to do it would be to put this in a package and use pipx to manage it. For now, install httpx into your user environment:

$ pip install --user httpx

Then put this code in a script:

#!/usr/bin/env python
# This script should be in ~/.bin/git-coffee
# Remember to chmod +x ~/.bin/git-coffee
import httpx
result = httpx.request("BREW", "http://10.0.1.22:1111/")
result.raise_for_status()
print(result.text)

Make sure that ~/.bin is in your path:

$ (echo $PATH | grep -q ~/.bin) || echo "Make sure to add ~/.bin to your path!"

Finally, enjoy as your git command allows you to enjoy your morning coffee:

$ git coffee
startThe finer things in life

Python, Git, and coffee are a good combination for any open source programmer or user. I leave the exercise of implementing a coffee brewing terminal to you (maybe you have a spare Raspberry Pi looking for a purpose?) If you don't have a coffee machine configured for HTTP requests, then at the very least, you've learned how easy it is to use Python and the httpx module to make HTTP call requests. So go get yourself a coffee. You've earned it!

I created my own Git command to brew my morning coffee.

Image by:

Pixabay. CC0.

Git What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Zorin OS Lite 16.1 – A Ultimate Linux Desktop with Windows Feel

Tecmint - Fri, 04/01/2022 - 13:10
The post Zorin OS Lite 16.1 – A Ultimate Linux Desktop with Windows Feel first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Since Linux is founded in 1991, Linux is transformed into a mature operating system, a ready-to-use operating system even for people that have never touched a computer before. Linux at the beginning only had

The post Zorin OS Lite 16.1 – A Ultimate Linux Desktop with Windows Feel first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

FreeType 2.12 Released With Support For OT-SVG Fonts

Phoronix - Fri, 04/01/2022 - 12:00
FreeType as the widely-used, open-source library for font rendering is out with FreeType 2.12 as its first big feature release since last summer...

Steam Deck, Ryzen Servers, Apple M1 On Linux & Milan-X Excited Linux Users In Q1

Phoronix - Fri, 04/01/2022 - 07:40
Here is a look back at the most-read stories on Phoronix during Q1'22 with our daily content around Linux hardware, open-source news, and lots of benchmarking...

Chrome 101 Beta Introduces Priority Hints, FedCM API, CSS HWB Function

Phoronix - Fri, 04/01/2022 - 03:00
Following this week's release of Chrome 100, Google has now published the Chrome 101 web browser beta...

Ubuntu 22.04 LTS Beta Released With Many Improvements

Phoronix - Fri, 04/01/2022 - 01:58
In working toward the official Ubuntu 22.04 LTS "Jammy Jellyfish" release on 21 April, today Canonical and the Ubuntu community have announced the beta release...

Pages