Skip to content

Instantly share code, notes, and snippets.

View jimmydo's full-sized avatar

Jimmy Do jimmydo

View GitHub Profile
@jimmydo
jimmydo / fedora-server-multicast-dns.md
Created January 16, 2023 03:54
Enable multicast DNS on Fedora Server

Set MulticastDNS to yes and apply the change:

sudo vi /etc/systemd/resolved.conf
sudo systemctl restart systemd-resolved

Enable mDNS on the network interface and apply the change:

@jimmydo
jimmydo / grow-a-file-system-in-a-volume-group.md
Created January 15, 2023 22:59
Grow a file system in a volume group

I noticed that my main file system was only 15G:

$ df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
...
/dev/mapper/fedora-root xfs        15G  1.7G   14G  11% /
...
@jimmydo
jimmydo / ssh-key-passphrases-in-macos-keychain.md
Last active November 17, 2022 05:00
Store SSH key passphrase in the macOS keychain

Configuring ssh to use the macOS keychain allows using a passphrase-protected SSH key without having to repeatedly enter the passphrase.

To store passphrases in the keychain, add this to ~/.ssh/config:

UseKeychain yes

You'll now only be asked to enter a passphrase the first time you use an SSH key.

@jimmydo
jimmydo / ubuntu-server-multicast-dns.md
Last active November 1, 2024 12:37
Enable multicast DNS on Ubuntu Server

Enabling multicast DNS (mDNS) on a server allows other hosts on the local network to address the server as <hostname>.local.

mDNS is disabled by default in Ubuntu Server:

$ resolvectl mdns
Global: no
Link 2 (eno1): no
@jimmydo
jimmydo / mocknow.py
Created July 29, 2011 05:02
Python context manager for mocking out datetime.now() in unit tests.
import contextlib
import datetime
@contextlib.contextmanager
def mock_now(dt_value):
"""Context manager for mocking out datetime.now() in unit tests.
Example:
with mock_now(datetime.datetime(2011, 2, 3, 10, 11)):
@jimmydo
jimmydo / buttons.css
Created July 24, 2011 22:37
Reset styling of button-like elements
a,
button,
input[type="button"],
input[type="submit"] {
background-color: #ccc;
line-height: normal; /* since Firefox forces <button> and <input> elements to always have a line height of 'normal', we do the same for all button-like elements for consistency */
padding: 6px 12px;
}
a {
import re
# Some mobile browsers which look like desktop browsers.
RE_MOBILE = re.compile(r"(iphone|ipod|blackberry|android.+mobile|palm|windows\s+ce)", re.I)
RE_DESKTOP = re.compile(r"(windows|linux|os\s+[x9]|solaris|bsd)", re.I)
RE_BOT = re.compile(r"(spider|crawl|slurp|bot)")
def is_desktop(user_agent):
"""
@jimmydo
jimmydo / collapsespacestag.py
Created February 24, 2011 19:29
collapsespaces is a Django template tag that collapses whitespace characters between tags into one space.
"""collapsespaces is a Django template tag that collapses whitespace characters between tags into one space.
It is based on Django's 'spaceless' template tag (spaceless is different in that it completely removes whitespace between tags).
Why is this important?
Given "<span>5</span> <span>bottles</span>", collapsespaces will preserve the space between the two span elements--spaceless will not.
In a web browser:
"<span>5</span> <span>bottles</span>" renders as "5 bottles"
"<span>5</span><span>bottles</span>" renders as "5bottles"
"""
@jimmydo
jimmydo / jquery.textchange.js
Created December 18, 2010 00:22 — forked from mkelly12/jquery.textchange.js
Make val() trigger change event
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {