Skip to content

Instantly share code, notes, and snippets.

View v6ak's full-sized avatar

Vít Šesták v6ak

View GitHub Profile
@v6ak
v6ak / revoked_host_keys
Last active March 27, 2023 11:59
Global revocation of the compromised Github SSH key; You need both files.
# github.com compromised SSH key; see https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
@v6ak
v6ak / Main.java
Last active November 23, 2022 14:49
Dynamic typing vs. type inference
public class Main{
private static Object getValue() {
// We return String, but the type is just more generic Object
return "hello world";
}
public static void main(String...args) {
// javac sees that getValue() returns Object, so the type of x is also Object
var x = getValue();
@v6ak
v6ak / Object\Main.java
Last active November 23, 2022 14:39
Proof that var in Java infers compile-time; backslashes in filenames are a workaround for Gist subdirectory limitations
public class Main{
public static void main(String...args) {
final Object x = "hello world";
System.out.println(x);
}
}
@v6ak
v6ak / assignments_list-conservative.py
Created May 18, 2021 08:51
Conservative adjustment of assignments_list.py
def assignments_list(self, persistent=None):
'''List assignments for devices which are (or may be) attached to the
vm.
Devices may be attached persistently (so they are included in
:file:`qubes.xml`) or not. Device can also be in :file:`qubes.xml`,
but be temporarily detached.
:param bool persistent: only include devices which are or are not
attached persistently.
#!/bin/env python3
from qubesadmin import Qubes
q = Qubes()
d = q.domains['sys-net']
devices = d.devices['pci']
print(list(devices.assignments(persistent=True)))
Linux version 4.14.68-xen-stubdom (user@build-fedora4) (gcc version 6.4.1 20170727 (Red Hat 6.4.1-1) (GCC)) #1 Tue Oct 2 03:34:17 UTC 2018
Command line: debug console=hvc0
x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
Released 0 page(s)
e820: BIOS-provided physical RAM map:
Xen: [mem 0x0000000000000000-0x000000000009ffff] usable
Linux version 4.14.68-xen-stubdom (user@build-fedora4) (gcc version 6.4.1 20170727 (Red Hat 6.4.1-1) (GCC)) #1 Tue Oct 2 03:34:17 UTC 2018
Command line: debug console=hvc0
x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
Released 0 page(s)
e820: BIOS-provided physical RAM map:
Xen: [mem 0x0000000000000000-0x000000000009ffff] usable
This file has been truncated, but you can view the full file.
$ sudo journalctl | grep iwlwifi
(some non-interesting sudo-related logs skipped)
Mar 19 03:28:20 localhost kernel: iwlwifi 0000:00:06.0: Direct firmware load for iwlwifi-cc-a0-52.ucode failed with error -2
Mar 19 03:28:20 localhost kernel: iwlwifi 0000:00:06.0: Direct firmware load for iwlwifi-cc-a0-51.ucode failed with error -2
Mar 19 03:28:20 localhost kernel: iwlwifi 0000:00:06.0: Direct firmware load for iwlwifi-cc-a0-50.ucode failed with error -2
Mar 19 03:28:20 localhost kernel: iwlwifi 0000:00:06.0: Direct firmware load for iwlwifi-cc-a0-49.ucode failed with error -2
Mar 19 03:28:20 localhost kernel: iwlwifi 0000:00:06.0: Direct firmware load for iwlwifi-cc-a0-48.ucode failed with error -2
Mar 19 03:28:20 localhost kernel: iwlwifi 0000:00:06.0: Direct firmware load for iwlwifi-cc-a0-47.ucode failed with error -2
Mar 19 03:28:20 localhost kernel: iwlwifi 0000:00:06.0: loaded firmware version 46.3cfab8da.0 op_mode iwlmvm
% cat iwlwifi-processed.log | sed -e 's/^.* \(sys-net\|localhost\) \(kernel\|NetworkManager\[809\]\): /(time + host): /' -e 's/ 0x[0-9A-F]\{8\}/ (0xHEXAHEXA) /' -e 's/\(rfkill\|phy\)[0-9]\+/(\1 + number)/g' -e 's/(time + host): <info> \[[0-9.]\+\] /(time + host): <info> [(timestamp)] /' | sort -u
$ sudo journalctl | grep iwlwifi
(some sudo-related logs)
(time + host): <info> [(timestamp)] (rfkill + number): found Wi-Fi radio killswitch (at /sys/devices/pci0000:00/0000:00:06.0/ieee80211/(phy + number)/(rfkill + number)) (driver iwlwifi)
(time + host): _iwl_op_mode_start.isra.0+0x42/0x80 [iwlwifi]
(time + host): iwl_req_fw_callback+0x191e/0x1d30 [iwlwifi]
(time + host): iwl_trans_pcie_gen2_send_hcmd+0x3d8/0x3e0 [iwlwifi]
(time + host): ? iwl_trans_send_cmd+0x51/0xb0 [iwlwifi]
(time + host): iwl_trans_send_cmd+0x51/0xb0 [iwlwifi]
(time + host): iwlwifi 0000:00:06.0: (0xHEXAHEXA) | beacon time
@v6ak
v6ak / gist:7cdf4d2054739d1868f750ecee8134cb
Created February 5, 2020 23:47
CShack + numpad emulation
// CShack for Linux, version 1.1, 2016-03-14
// (C) 2012-2016 Ladislav Matula <ladislav.matula*gmail.com>, www.xakru.com/cshack/
// (C) 2008 Michal Berg <m.berg*centrum.cz>
// (C) 2014-2016 Vít Šesták https://contact.v6ak.com
// Public domain
// CShack - Czech and Slovak 1337 keyboard layout
// - Caps-Lock is a new 'shift', without pressing this new 'shift' it behaves like the standard en_US layout
// - almost every key has two new characters - Caps-Lock + <char> and Shift + Caps-Lock + <char>
// - chars with diacritics are at (or close to) their basic glyph, Caps-Lock + a => á, Shift + Caps-Lock + a => Á, Caps-Lock + t => ť ...