Skip to content

Instantly share code, notes, and snippets.

View psychon's full-sized avatar

Uli Schlachter psychon

  • In front of his laptop
View GitHub Profile
// Variant of https://github.com/GNOME/pango/blob/main/examples/cairotwisted.c to shape text a bit trapezoidal
/* Example code to show how to use pangocairo to render text
* projected on a path.
*
*
* Written by Behdad Esfahbod, 2006..2007
*
* Permission to use, copy, modify, distribute, and sell this example
* for any purpose is hereby granted without fee.
@psychon
psychon / Cargo.toml
Created January 21, 2023 09:55
Sample program to download a ZIP file and show its content
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
reqwest = { version = "0.11", features = ["blocking"] }
vfs-zip = "0.2.1"
@psychon
psychon / main.rs
Last active January 28, 2022 17:37
Async Rust X11 connection PoC
use std::collections::HashMap;
use std::marker::PhantomData;
use std::sync::Arc;
use tokio::io::{AsyncReadExt as _, AsyncWriteExt as _};
use tokio::sync::mpsc::{
channel, unbounded_channel, OwnedPermit, Receiver, Sender, UnboundedReceiver,
};
use tokio::sync::Mutex;
use x11rb::connection::SequenceNumber;
use x11rb::errors::{ConnectionError, ParseError};
/*
* A simple client icon that "does nothing".
*
* Copyright © 2021 Uli Schlachter <psychon@znc.in>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
#include <cairo.h>
#include <stdio.h>
#include <stdlib.h>
#include <xcb/xcb.h>
static cairo_region_t *unobscured_space(
xcb_connection_t *conn,
xcb_window_t window,
uint16_t width,
uint16_t height) {
#!/usr/bin/python3
import select
import socket
import sys
import time
class Listener:
def __init__(self, listen_port, target_port, delay):
use std::io::{Error as IOError, ErrorKind, Read, Write};
use std::net::{TcpListener, TcpStream};
use std::os::unix::net::UnixStream;
use std::thread;
use std::env::args_os;
use std::process::Command;
use std::convert::{TryFrom, TryInto};
use std::sync::{Arc, Mutex};
use std::collections::VecDeque;
use std::os::unix::net::UnixStream;
use std::os::unix::io::AsRawFd;
use std::io::{Read, Result as IOResult, Write};
use std::error::Error;
use std::convert::TryFrom;
use nix::poll::{PollFd, PollFlags, poll};
use x11rb::protocol::xproto::{self, SetupRequest, Setup};
use x11rb::x11_utils::Serialize;
diff --git a/src/protocol/dri2.rs b/src/protocol/dri2.rs
index bf23023..f1872b9 100644
--- a/src/protocol/dri2.rs
+++ b/src/protocol/dri2.rs
@@ -462,6 +462,8 @@ pub struct ConnectReply {
pub response_type: u8,
pub sequence: u16,
pub length: u32,
+ // deducible: Some("driver_name_length")
+ // deducible: Some("device_name_length")
diff --git a/tests/test-benchmark.lua b/tests/test-benchmark.lua
index 61e4c4e54..4f6a05ace 100644
--- a/tests/test-benchmark.lua
+++ b/tests/test-benchmark.lua
@@ -77,6 +77,129 @@ benchmark(relayout_textclock, "relayout textclock")
benchmark(redraw_textclock, "redraw textclock")
benchmark(e2e_tag_switch, "tag switch")
+local function sign(x)
+ if x > 0 then