Skip to content

Instantly share code, notes, and snippets.

@ammgws
ammgws / pango_pxtest.c
Last active October 16, 2021 04:50
Pango pixel width output test
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <cairo.h>
#include <pango/pangocairo.h>
int main (int argc, char **argv)
{
@ammgws
ammgws / gist:57cf8d4d4442abf9d7d16282fb7028a8
Created September 6, 2019 13:59
Using dbus-rs (v0.6) to get value of new DBus property from the signal message
```
extern crate dbus;
use dbus::{BusType, Connection, SignalArgs};
use dbus::stdintf::org_freedesktop_dbus::PropertiesPropertiesChanged;
fn main() {
let c = Connection::get_private(BusType::Session).unwrap();
let matched_signal = PropertiesPropertiesChanged::match_str(Some(&"localhost.statusbar.DBus".into()), Some(&"/localhost/statusbar/DBus/SoundDevice".into()));
c.add_match(&matched_signal).unwrap();
loop {
@ammgws
ammgws / cli.go
Created March 20, 2019 15:40 — forked from cema-sp/cli.go
Part of TCR driver utility
package cli
import (
"bufio"
"encoding/json"
"fmt"
"os"
"quantum/hart/tcr/hart"
"quantum/hart/tcr/messages"
"strings"
@ammgws
ammgws / missing_ufw_samba.md
Last active May 28, 2025 11:00
Missing ufw samba application profile in /etc/ufw/applications.d

Am using a samba share on Ubuntu 16.04 server, and wanted to enable Samba traffic in ufw using sudo ufw allow from 192.168.8.0/24 to any app Samba comment 'allow samba from local' which returned the error "ERROR: Could not find a profile matching 'Samba'".

Cause: I was using the minimal amount of tooling required to use Samba (cifs-tools) on my server, which doesn't include the Samba application file.

Fix: install the samba package... or manually create the file:

sudoedit /etc/ufw/applications.d/samba

[Samba]
title=LanManager-like file and printer server for Unix
@ammgws
ammgws / python3.6_ubuntu16.04_install_notes.md
Last active April 24, 2019 11:58
Install Python 3.6 on Ubuntu 16.04

Using pyenv seems to be the easiest way apart from a random PPA or finding/downloading/compilign the source myself.

Build dependencies:

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev

Install Pyenv (as the user who will use it, not root):

curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
@ammgws
ammgws / proxmox_CT_distupgrade_fix.md
Last active October 23, 2024 00:17
Fix for Proxmox container failing to start after dist-upgrade
  • Upgraded from Ubuntu 16.04 LTS to 18.04 (pre-release) using dist-upgade
  • Upon restart CT would not start
  • Error displayed in Web GUI: command 'systemctl start pve-container@101' failed: exit code 1
  • SSHd in and manually ran CT with pct start 101:
>root@server:~# pct start 101
Job for [email protected] failed because the control process exited with error code.
See "systemctl status [email protected]" and "journalctl -xe" for details.
command 'systemctl start pve-container@101' failed: exit code 1
@ammgws
ammgws / unifi_ubuntu_lxc_install.md
Last active January 23, 2019 11:15
Steps to install Unifi 5.6.29 in a Ubuntu 16.04 unpriveleged LXC
@ammgws
ammgws / letsencrypt-acme-guide.md
Last active July 23, 2023 17:19
Using acme.sh script to renew LetsEncrypt certs using non-standard SSL port

1. Install acme.sh shell script

git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install

Optionally, set the home dir and/or account info (if already have one).
If was previously using LetsEncrypt's certbot, can probably get account info from /etc/letsencrypt/accounts/acme-v01.api.letsencrypt.org/directory/*/regr.json.

@ammgws
ammgws / setup_fulldisk_encryption_rpi.md
Last active December 9, 2023 08:46
Notes on how to setup full disk encryption on an already setup Raspbian system

Setup full disk encryption using LVM on LUKS (single drive) with remote SSH for an already setup/running Raspbian stretch system. Using this guide there is no need to connect a screen or keyboard to the rpi at any stage since we will setup remote SSH at the same time (at present no other guides available tell you that this is possible).

1. Backup SD card

To be safe, backup SD card (using another computer is easiest in my case): sudo dd bs=4M if=/dev/<rpi_sdcard> | gzip > rpibackup.img.gz or use my fish shell function.

2. Install LUKS dependencies and reboot

@ammgws
ammgws / edgerouter_lite_openvpn.md
Last active September 2, 2024 19:06
Notes on setting up OpenVPN on Edgerouter Lite

My notes on how I setup OpenVPN server on Edgerouter Lite. Based mostly on this guide from openVPN wiki. This guide assumes easyrsa3 is being used, otherwise substitute whatever the easyrsa2 versions are for the commands below.

This guide will use 3 different machines.

A Public Key Infrastructure (PKI) will be created on each machine:

    1. Server - openVPN server (Edgerouter in this case).
    1. Client(s) - the device(s) you will be connecting from.
    1. CA Server - used to generate and sign certificates for server and clients to use.