Skip to content

Instantly share code, notes, and snippets.

@djfdyuruiry
djfdyuruiry / README.md
Last active April 28, 2024 08:34
WSL 2 - Enabling systemd

Enable systemd in WSL 2

NOTE: If you have Windows 11 there is now an official way to do this in WSL 2, use it if possible - see MS post here (WINDOWS 11 ONLY)

This guide will enable systemd to run as normal under WSL 2. This will enable services like microk8s, docker and many more to just work during a WSL session. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2.

  • To enable systemd under WSL we require a tool called systemd-genie

  • Copy the contents of install-sg.sh to a new file /tmp/install-sg.sh:

## Description
Sometimes you need to parse CEF with logstash but it is wrapped in some other format, such as JSON or syslog. In this case, you can't use the CEF codec in the input, so you're doomed to do it yourself since there is not currently a CEF codec for filter blocks. Try this logstash recipe, it works well. Just rmeember a comma will break it- so feel free to replace "," with a more rare character like "|" or something...
## Context
At this point, the message has been processed so its a full CEF message starting in cef_message. Syslog "headers" were already removed in a previous step.
## Stripped from production
@mosquito
mosquito / README.md
Last active May 4, 2024 12:42
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/docker-compose@.service. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
PartOf=docker.service
After=docker.service
@xcsrz
xcsrz / center_text_on_image.py
Created March 8, 2017 00:17
Center text on an image with Python and OpenCV. Had to come up with it myself as no one was spelling this out anywhere (or google couldn't find it)
#!/usr/bin/env python
import numpy as np
import cv2
from time import sleep
# create blank image - y, x
img = np.zeros((600, 1000, 3), np.uint8)
# setup text
@jyap808
jyap808 / gist:8700714
Last active November 25, 2022 22:42
Rsync - via SSH with no password, utilizing SSH ForceCommand in the authorized_keys file to limit the commands that can be run with that SSH key

To make rsync both secure and automated (i.e : non-interactive), you can use SSH as the transport and set up a key pair. This is what will be discussed in this post, along with a few improvements.

Basic rsync + ssh

Let’s first ensure that rsync works correctly over ssh :

spaghetti% rsync -avz -e ssh --delete Documents prodigy:/tmp

Password: