Skip to content

Instantly share code, notes, and snippets.

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

M blinkinglight

🏠
Working from home
View GitHub Profile
@blinkinglight
blinkinglight / cmd-to-websocket.go
Created July 26, 2024 07:45 — forked from rochacon/cmd-to-websocket.go
Stream a command stderr and stdout throught websockets
package main
import (
"bufio"
"fmt"
"github.com/gorilla/websocket"
"io"
"log"
"net/http"
"os/exec"
@blinkinglight
blinkinglight / yubikey4-ssh-macos.md
Created July 22, 2023 06:28 — forked from ixdy/yubikey4-ssh-macos.md
Setting up ssh public key authentication on macOS using a YubiKey 4

Setting up ssh public key authentication on macOS using a YubiKey 4

I largely followed Florin's blog post, but have a few notes to add regarding issues I encountered:

Basic setup notes

  1. I used a YubiKey 4, while the blog describes using a YubiKey NEO. I'm sure a YubiKey 5 would also work. I'm also running macOS 10.13.6.
  2. I installed GPGTools as recommended. However, as I'll note later, it seems that gpg-agent only automatically starts when gpg is used; for ssh, you'll need to ensure it's running.
  3. Before generating your keys, decide what key size you want to use. If you run the list command inside gpg --edit-card, look for the Key attributes line to see what is currently selected. On my YubiKey 4, it defaulted to 2048 bits for all keys:
Key attributes ...: rsa2048 rsa2048 rsa2048
@blinkinglight
blinkinglight / Caddyfile.tmpl
Created March 10, 2023 18:09 — forked from optiz0r/Caddyfile.tmpl
Caddy with Nomad + Consul
{{- range services -}}
{{- if .Name | contains "sidecar" | not -}}
{{- $groupedServices := (service .Name | byMeta "caddy_enable") -}}
{{- $enabledServices := (index $groupedServices "true" ) -}}
{{- range $enabledServices -}}
{{- $vhost := index .ServiceMeta "caddy_vhost" -}}
{{- scratch.MapSetX "vhosts" $vhost . -}}
{{- end -}}
{{- end -}}
{{- end -}}
@blinkinglight
blinkinglight / webdavserv.go
Created March 5, 2023 16:21 — forked from staaldraad/webdavserv.go
A small webdav server in go
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
"golang.org/x/net/webdav"
@blinkinglight
blinkinglight / job.nomad.hcl
Created January 24, 2023 06:50 — forked from Gurpartap/job.nomad.hcl
nomad + consul template comma separated services from tags
job web {
datacenters = ["dc1"]
type = "service"
priority = 70
group app {
count = 1
task env {
driver = "exec"
@blinkinglight
blinkinglight / factorio_headless_guide.md
Created September 6, 2022 10:04 — forked from othyn/factorio_headless_guide.md
How to setup a Factorio Headless Server

[LINUX] Factorio Headless Server Guide

So, with credit to the Factorio wiki and cbednarski's helpful gist, I managed to eventually setup a Factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records.

The specific distro/version I'm using for this guide being Ubuntu Server 16.04.1 LTS. Although, that shouldn't matter, as long as your distro supports systemd (just for this guide, not a Factorio headless requirement, although most distros use it as standard now). The version of Factorio I shall be using is 0.14.20, although should work for any version of Factorio 0.14.12 and higher.

Just a note to newcomers: If there are any issues with the installation steps, people in the comments are doing a good job

This document describes the work-in-progress C API for writing custom chips for the Wokwi simulator.

Using the API

First, make sure to include wokwi-api.h. Every external method you declare should be wrapped with the EXPORT macro (e.g. void EXPORT(my_method_name) (uint32_t arg) { ... }). The chip should declare a chip_init method. This method will be called for every new instance of the chip. If the chip has some internal state, chip_init should allocate memory for the internal state and return a pointer to this memory. This pointer will be passed in the first argument for any listener that you declare (e.g. chip_pin_change). For chip without any internal state, simply return NULL.

Here's an example of a minimal chip file:

<?php
/**
* Lietuviškų vardų linksniai.
*
* @author Maug Lee <mauglee@gmail.com>
* @copyright Copyleft (ↄ) 2011, Maug Lee
* @version 0.3
* @package Vardai
*/
@blinkinglight
blinkinglight / start_docker_registry.bash
Created October 30, 2020 07:51 — forked from u1i/start_docker_registry.bash
Start docker registry with letsencrypt certificates and Basic Auth
#!/usr/bin/env bash
# install docker
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
# install docker-compose
# https://docs.docker.com/compose/install/
# install letsencrypt
# https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software