Skip to content

Instantly share code, notes, and snippets.

View xyproto's full-sized avatar
😊

Alexander F. Rødseth xyproto

😊
View GitHub Profile
@adtac
adtac / Dockerfile
Last active April 13, 2024 22:33
#!/usr/bin/env docker run
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
# syntax = docker/dockerfile:1.4.0
FROM node:20
WORKDIR /root
RUN npm install sqlite3
@earthboundkid
earthboundkid / -Go iterator experiment.md
Last active July 25, 2023 17:28
Go iterator experiment

Go iterator proposal experiment

The second problem in Project Euler is

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

Nine years ago, I wrote a blog post that showed how to solve this in Python using iterators and in Go using channels. The Go code started simple, but ended up a bit complicated because it also had stop channels to allow early exit. See euler.py for the Python code, and channel.go for the Go code using channels.

Go issue #61405 proposes to add a new function-based iterator protocol to Go. To test it, I rewrote the Go code using push function iterators. See functional.go. The code is notably simpler and shorter than the channel based code.

@mcpower
mcpower / aoc-tips.md
Last active March 27, 2024 03:28
Tips for getting on the Advent of Code leaderboard

Hi, I'm mcpower. I've done Advent of Code seriously for two years now in Python, placing 9th in 2018 and 12th in 2017. This year, I'm taking a break from aiming for the leaderboard - while it's fun and all, it is a bit stressful at times (the good kind of stress, though!). As such, I'd like to share a few tips for anyone wanting to aim for the leaderboard.

This is everything that worked for me. Your mileage may vary, though - don't take this as gospel, see what works for you.

Go fast

Go fast.

# Install these packages (use your favorite AUR tool here)
yay -S minikube kubectl docker-machine-driver-kvm2 libvirt qemu-headless ebtables
# Get libvirt going
sudo systemctl enable libvirtd.service
sudo usermod -a -G libvirt $(whoami)
# This fix thanks to http://blog.programmableproduction.com/2018/03/08/Archlinux-Setup-Minikube-using-KVM/
sudo virsh net-autostart default
@HarryUPf
HarryUPf / README.md
Last active September 28, 2023 01:37
Raspberry Pi SunVox Headless Synth (in 10 easy steps)

Raspberry Pi SunVox Headless Synth Setup (in 10-easy-steps)

INSTRUCTIONS

STEP_01

STEP_02

  • write the extracted .img to sdcard with Etcher

STEP_03

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@enricofoltran
enricofoltran / main.go
Last active April 1, 2024 00:17
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@nilsdeppe
nilsdeppe / emacs.el
Last active June 7, 2020 16:31
My Emacs init file
;;; initfile --- Summary:
;;; Commentary:
;; Emacs 25.1 and newer tested
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Configuration/Customization:
;; Defines global variables that are later used to customize and set
;; up packages.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@tanaikech
tanaikech / submit.md
Last active April 17, 2024 11:55
Downloading Shared Files on Google Drive Using Curl

Downloading Shared Files on Google Drive Using Curl

When the shared files on Google Drive is downloaded, it is necessary to change the download method by the file size. The boundary of file size when the method is changed is about 40MB.

File size < 40MB

CURL

filename="### filename ###"
fileid="### file ID ###"
curl -L -o ${filename} "https://drive.google.com/uc?export=download&amp;id=${fileid}"
@drmalex07
drmalex07 / README-python-service-on-systemd-activated-socket.md
Last active January 13, 2024 12:53
An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation

README

The example below creates a TCP server listening on a stream (i.e. SOCK_STREAM) socket. A similar approach can be followed to create a UDP server on a datagram (i.e. SOCK_DGRAM) socket. See man systemd.socket for details.

An example server

Create an simple echo server at /opt/foo/serve.py.