Skip to content

Instantly share code, notes, and snippets.

View ammgws's full-sized avatar
🐨

Jason Nader ammgws

🐨
View GitHub Profile
@ammgws
ammgws / missing_ufw_samba.md
Last active January 26, 2025 19:59
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 / 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 / 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 / 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 / fish_dev_scan_PO_files.py
Last active October 16, 2021 04:49
Find unused functions etc used in fish shell's PO files
import re
from pathlib import Path
p = Path("/tmp/fish-shell/po/")
for pofile in list(p.glob('*.po')):
print(f"=============================\n{pofile}\n=============================")
with open(pofile) as f:
po_data = f.readlines()
del_these = set()
import re
from pathlib import Path
from langdetect import detect
p = Path("/tmp/f/fish-shell/po/")
pattern = re.compile('^msgstr\s*"(.{10,})"')
for pofile in list(p.glob('*.po')):
language = []
with open(pofile) as f:
po_data = f.readlines()

OK sudo strace -- swaymsg --socket $SWAYSOCK -t get_inputs 2> swaymsg_getinputs_withswaysock.log

 44 socket(AF_UNIX, SOCK_STREAM, 0)         = 3
 45 connect(3, {sa_family=AF_UNIX, sun_path="/run/user/1000/sway-ipc.1000.1324.sock"}, 110) = 0
 46 setsockopt(3, SOL_SOCKET, SO_RCVTIMEO_OLD, "\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
 47 write(3, "i3-ipc\0\0\0\0d\0\0\0", 14)   = 14
 48 write(3, "", 0)                         = 0
 49 recvfrom(3, "i3-ipc\31\26\0\0d\0\0\0", 14, 0, NULL, NULL) = 14
 50 recvfrom(3, "[ { \"identifier\": \"0:0:Eee_PC_WM"..., 5657, 0, NULL, NULL) = 5657
# output size of `swaymsg -t get_outputs`,
# run every 5 minutes
#
# time bytes diff
March 1 16:55 12994 0
March 1 16:56 12994 0
March 1 16:56 12994 0
March 1 16:56 12994 0
March 1 16:56 12994 0
March 1 17:22 12994 0
Node: /dev/dri/card0
β”œβ”€β”€β”€Driver: amdgpu (AMD GPU) version 3.36.0 (20150101)
β”‚ β”œβ”€β”€β”€DRM_CLIENT_CAP_STEREO_3D supported
β”‚ β”œβ”€β”€β”€DRM_CLIENT_CAP_UNIVERSAL_PLANES supported
β”‚ β”œβ”€β”€β”€DRM_CLIENT_CAP_ATOMIC supported
β”‚ β”œβ”€β”€β”€DRM_CLIENT_CAP_ASPECT_RATIO supported
β”‚ β”œβ”€β”€β”€DRM_CLIENT_CAP_WRITEBACK_CONNECTORS supported
β”‚ β”œβ”€β”€β”€DRM_CAP_DUMB_BUFFER = 1
β”‚ β”œβ”€β”€β”€DRM_CAP_VBLANK_HIGH_CRTC = 1
β”‚ β”œβ”€β”€β”€DRM_CAP_DUMB_PREFERRED_DEPTH = 24
Node: /dev/dri/card0
β”œβ”€β”€β”€Driver: amdgpu (AMD GPU) version 3.36.0 (20150101)
β”‚ β”œβ”€β”€β”€DRM_CLIENT_CAP_STEREO_3D supported
β”‚ β”œβ”€β”€β”€DRM_CLIENT_CAP_UNIVERSAL_PLANES supported
β”‚ β”œβ”€β”€β”€DRM_CLIENT_CAP_ATOMIC supported
β”‚ β”œβ”€β”€β”€DRM_CLIENT_CAP_ASPECT_RATIO supported
β”‚ β”œβ”€β”€β”€DRM_CLIENT_CAP_WRITEBACK_CONNECTORS supported
β”‚ β”œβ”€β”€β”€DRM_CAP_DUMB_BUFFER = 1
β”‚ β”œβ”€β”€β”€DRM_CAP_VBLANK_HIGH_CRTC = 1
β”‚ β”œβ”€β”€β”€DRM_CAP_DUMB_PREFERRED_DEPTH = 24