Skip to content

Instantly share code, notes, and snippets.

View firmware updates
$ sudo fwupdmgr get-updates
Firmware metadata has not been updated for 30 days and may not be up to date.
Update now? (Requires internet connection) [y|N]: y
Fetching metadata https://cdn.fwupd.org/downloads/firmware.xml.gz
Downloading… [***************************************]
Fetching signature https://cdn.fwupd.org/downloads/firmware.xml.gz.asc
Successfully downloaded new metadata: 2 local devices supported
• Integrated Camera has no available firmware updates
@pedrocr
pedrocr / test_popcnt.rs
Created Jun 12, 2021
Test popcnt implementations
View test_popcnt.rs
use std::time::Instant;
use std::thread::sleep;
use std::time::Duration;
macro_rules! do_timing {
($name:expr, $body:expr) => {
{
let from_time = Instant::now();
let value = {
$body
View gist:74fcbba6ae2812f07ce18793647ddfaa
thread '<unnamed>' panicked at 'attempted to leave type `nodrop::NoDrop<(epoch::Epoch, garbage::Bag)>` uninitialized, which is invalid', /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/mem/mod.rs:658:9
stack backtrace:
0: 0x561f836807f0 - std::backtrace_rs::backtrace::libunwind::trace::h72c2fb8038f1bbee
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/../../backtrace/src/backtrace/libunwind.rs:96
1: 0x561f836807f0 - std::backtrace_rs::backtrace::trace_unsynchronized::h1e3b084883f1e78c
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/../../backtrace/src/backtrace/mod.rs:66
2: 0x561f836807f0 - std::sys_common::backtrace::_print_fmt::h3bf6a7ebf7f0394a
at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:79
3: 0x561f836807f0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::f
View gist:2d4dd8785655307833185ebbf557e3d1
$ wayland-info
interface: 'wl_shm', version: 1, name: 1
formats: 'AB24'(0x34324241) 'XB24'(0x34324258) XRGB8888 ARGB8888
interface: 'wl_drm', version: 2, name: 2
interface: 'zwp_linux_dmabuf_v1', version: 3, name: 3
formats:
'UYVY'(0x59565955), modifier: 0x0100000000000002
'UYVY'(0x59565955), modifier: 0x0100000000000001
'UYVY'(0x59565955), modifier: 0x0000000000000000
'YUYV'(0x56595559), modifier: 0x0100000000000002
@pedrocr
pedrocr / gist:e9fa2e2bc58348b4f4840d928b4dcd53
Created May 20, 2021
Custom xkb map to remap CAPS in sway
View gist:e9fa2e2bc58348b4f4840d928b4dcd53
In your .config/sway/config:
input * xkb_layout pt-custom
In .xkb/symbols/pt-custom:
default partial alphanumeric_keys modifier_keys
xkb_symbols "basic" {
include "pt"
name[Group1] = "Portuguese (Custom)";
@pedrocr
pedrocr / debug.log
Created May 18, 2021
sway having too much latency when doing no-op output commands
View debug.log
00:00:00.000 [sway/main.c:326] Sway version 1.5.1-eca57594 (May 18 2021, branch 'HEAD')
00:00:00.003 [sway/main.c:153] Linux coulson 5.8.0-53-generic #60~20.04.1-Ubuntu SMP Thu May 6 09:52:46 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
00:00:00.004 [sway/main.c:169] Contents of /etc/lsb-release:
00:00:00.004 [sway/main.c:153] DISTRIB_ID=Ubuntu
00:00:00.004 [sway/main.c:153] DISTRIB_RELEASE=20.04
00:00:00.004 [sway/main.c:153] DISTRIB_CODENAME=focal
00:00:00.004 [sway/main.c:153] DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
00:00:00.005 [sway/main.c:169] Contents of /etc/os-release:
00:00:00.005 [sway/main.c:153] NAME="Ubuntu"
00:00:00.005 [sway/main.c:153] VERSION="20.04.2 LTS (Focal Fossa)"
@pedrocr
pedrocr / debug.log
Created May 18, 2021
Sway log of XWayland overreacting to "output * dpms on"
View debug.log
00:00:00.000 [sway/main.c:326] Sway version 1.5.1-eca57594 (May 18 2021, branch 'HEAD')
00:00:00.001 [sway/main.c:153] Linux coulson 5.8.0-53-generic #60~20.04.1-Ubuntu SMP Thu May 6 09:52:46 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
00:00:00.001 [sway/main.c:169] Contents of /etc/lsb-release:
00:00:00.001 [sway/main.c:153] DISTRIB_ID=Ubuntu
00:00:00.001 [sway/main.c:153] DISTRIB_RELEASE=20.04
00:00:00.001 [sway/main.c:153] DISTRIB_CODENAME=focal
00:00:00.001 [sway/main.c:153] DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
00:00:00.001 [sway/main.c:169] Contents of /etc/os-release:
00:00:00.001 [sway/main.c:153] NAME="Ubuntu"
00:00:00.001 [sway/main.c:153] VERSION="20.04.2 LTS (Focal Fossa)"
View gist:f00d7327bcdc282052b715b8bde86c4b
May 18 11:47:47 coulson /usr/lib/gdm3/gdm-wayland-session[27557]: The XKEYBOARD keymap compiler (xkbcomp) reports:
May 18 11:47:47 coulson /usr/lib/gdm3/gdm-wayland-session[27557]: > Warning: Unsupported maximum keycode 569, clipping.
May 18 11:47:47 coulson /usr/lib/gdm3/gdm-wayland-session[27557]: > X11 cannot support keycodes above 255.
May 18 11:47:47 coulson /usr/lib/gdm3/gdm-wayland-session[27557]: > Internal error: Could not resolve keysym Invalid
May 18 11:47:47 coulson /usr/lib/gdm3/gdm-wayland-session[27557]: Errors from xkbcomp are not fatal to the X server
May 18 11:47:47 coulson /usr/lib/gdm3/gdm-wayland-session[27559]: The XKEYBOARD keymap compiler (xkbcomp) reports:
May 18 11:47:47 coulson /usr/lib/gdm3/gdm-wayland-session[27559]: > Warning: Unsupported maximum keycode 569, clipping.
May 18 11:47:47 coulson /usr/lib/gdm3/gdm-wayland-session[27559]: > X11 cannot support keycodes above 255.
May 18 11:47:47 coulson /usr/lib/gdm3/gdm-wayland-s
View gist:4bdc14d034248e7a39914a58045ecf33
These happen regularly without doing anything:
May 18 10:29:00 coulson /usr/lib/gdm3/gdm-wayland-session[2254]: 00:57:45.176 [ERROR] [backend/drm/atomic.c:36] DP-1: Atomic commit failed (pageflip): Device or resource busy
These happen every time I move the trackpoint after a few moments of inactivity and result in noticeable lag in reacting to the initial movement:
May 18 10:29:26 coulson /usr/lib/gdm3/gdm-wayland-session[2254]: 00:58:11.645 [ERROR] client bug: timer event5 trackpoint: scheduled expiry is in the past (-91ms), your system is too slow
May 18 10:29:26 coulson /usr/lib/gdm3/gdm-wayland-session[13317]: [
May 18 10:29:26 coulson /usr/lib/gdm3/gdm-wayland-session[13317]: {
May 18 10:29:26 coulson /usr/lib/gdm3/gdm-wayland-session[13317]: "success": true
View collatz.rs
extern crate rayon;
use rayon::prelude::*;
use std::sync::atomic::{AtomicU8, Ordering};
fn main() {
let pos = AtomicU8::new(0);
(2..(u32::MAX as u64)).into_par_iter().for_each(|num| {
let mut inter = num;
while inter >= num {