Skip to content

Instantly share code, notes, and snippets.

View funky-monkey's full-sized avatar

Sidney de Koning funky-monkey

View GitHub Profile
@funky-monkey
funky-monkey / print-badge
Created July 12, 2024 15:23 — forked from gelin/print-badge
Python script to print a badge to a thermal printer with TSPL language (by TSC)
#!/usr/bin/env python3
PRINTER = '/dev/usb/lp0' # the printer device
DOTS_MM = 8 # printer dots per mm, 8 == 203 dpi
WIDTH_MM = 100 # sticker width, mm
HEIGHT_MM = 35 # sticker height, mm
GAP_MM = 2 # sticker gap, mm
FONT = "0" # built-in vector font, scalable by X and Y
@funky-monkey
funky-monkey / airprint.md
Created July 12, 2024 15:23 — forked from elia/airprint.md
Enable Airprint for any printer on MacOs (BigSur)
  1. Connect printer, install printer drivers, and enable Printer Sharing.
  2. Open terminal, run: dns-sd -Z _ipp._tcp. You'll see a few lines of repeated text. Look for your printer's name, next to that record you will see a TXT, copy everything after TXT into a notepad.
  3. In that TXT line, you'll see a line like this: "pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/pwg-raster" Change that, to add ,image/urf. So it'll look like: "pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/pwg-raster,image/urf"
  4. Now take that entire TXT line, and add it to this: dns-sd -R "name_to_be advertised" _ipp._tcp.,_universal . 631 URF=none pdl=application/pdf,image/urf YOUR_TXT_STRING
  5. Run that line in the terminal, and Airprint should be enabled.
@funky-monkey
funky-monkey / remove_admin_shizzle.php
Created October 19, 2023 10:04
Menu items weghalen in Wordpress
function hide_wordpress_icon() {
echo "<style>#wp-admin-bar-wp-logo, #wp-admin-bar-comments {
border: 0; clip: rect(0 0 0 0); height: 1px;margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }</style>";
}
add_action('admin_head', 'hide_wordpress_icon');

Fix unclean restart:

sudo fsck -y /dev/sda1 && sudo reboot

Umbrel.local - not accessible - what to do

I see a lot of users having issues connecting to umbrel.local and most of them are Windows users. People… please before getting into running a node, DYOR and learn at least basics about networking, TCP/IP, IPs, LAN, WAN.

Running a node is something serious, is not a toy!

ssh-copy-id -i ~/.ssh/mykey user@host

Test it: ssh -i ~/.ssh/mykey user@host

OR: cat ~/.ssh/raspberry-pi.pub | ssh user@12.34.56.78 "mkdir -p ~/.ssh &amp;&amp; cat &gt;&gt; ~/.ssh/authorized_keys

Download YouTube playlist videos in separate directory indexed by video order in a playlist

youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re

Download all playlists of YouTube channel/user keeping each playlist in separate directory:

youtube-dl -o '%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/user/TheLinuxFoundation/playlists

A very simple and straightforward way that worked for me is as follows:

Stop apache2.

sudo service apache2 stop

Uninstall Apache2 and its dependent packages.

Error

Ran into an issue, where for some reason, on one of my Macs, XCode swift works fine, but on another, I got an error like:

$ xcrun --sdk macosx --find xctest
xcrun: error: unable to find utility “xctest”, not a developer tool or in PATH
Now that all modern browsers support SVG favicons, here's how to turn any emoji into a favicon.svg:
<svg xmlns="http://w3.org/2000/svg" viewBox="0 0 100 100">
<text y=".9em" font-size="90">
Pile of poo
</text>
</svg>
Useful for quick apps when you can't be bothered to design a favicon!

This Gist contains an example code fragment of how to read temperature and humidity data from Inkbird ibs-TH1 bluetooth thermometer in NodeJS with Noble.

Note that you can also read values directly via command line with gatttool:

gatttool -b <MAC> --char-read --handle=0x002d

Example value: