Skip to content

Instantly share code, notes, and snippets.

View quaintdev's full-sized avatar
🏠
Working from home

quaintdev

🏠
Working from home
View GitHub Profile
@quaintdev
quaintdev / assignment.md
Created January 11, 2023 14:14
Sample Go programming assignment involving structs and composition:

Create a program that models a shopping cart for a e-commerce website. The program should include the following structs:

  • Item struct, with fields for the item's name, price, and quantity.
  • Cart struct, with a field for a slice of Item structs and methods for adding an item to the cart, removing an item from the cart, and calculating the total cost of the items in the cart.

Your program should allow a user to create a new cart, add items to the cart, remove items from the cart, and display the total cost of the items in the cart.

Here is a skeleton of the code

@quaintdev
quaintdev / batterymon.go
Created August 30, 2021 17:01
A battery low and full notifier for sway along with systemd service config
package main
import (
"github.com/distatus/battery"
"github.com/gen2brain/beeep"
"log"
"time"
)
// check battery every 'interval' seconds
const interval int = 60