Skip to content

Instantly share code, notes, and snippets.

View sheenobu's full-sized avatar
🙃
smug

Sheena Artrip sheenobu

🙃
smug
View GitHub Profile
@sheenobu
sheenobu / aiohttp_example.py
Created January 19, 2023 22:16
aiohttp_example
import asyncio
import aiohttp
import logging
async def fetchurl(session, url: str):
async with session.get(url) as response:
return len(await response.text())
def strip_lifespan_events(app):
"""
handlers/ignores lifespan events from being routed to the given app.
"""
async def _app(scope, receive, send):
if scope.get("type") == "lifespan":
payload = await receive()
await send({'type': payload['type'] + ".complete"})
return
await app(scope, receive, send)
(gdb) i thr
Id Target Id Frame
* 1 Thread 0x7f1781b0a0c0 (LWP 9315) "fish" 0x00007f1782122420 in free@plt ()
from /nix/store/784rh7jrfhagbkydjfrv68h9x3g4gqmk-gcc-8.3.0-lib/lib/libstdc++.so.6
2 Thread 0x7f17737fe700 (LWP 9392) "fish" 0x00007f1781cceee2 in pthread_cond_wait@@GLIBC_2.3.2 ()
from /nix/store/wx1vk75bpdr65g6xwxbj4rw0pk04v5j3-glibc-2.27/lib/libpthread.so.0
3 Thread 0x7f1773fff700 (LWP 9401) "fish" 0x00007f1781cceee2 in pthread_cond_wait@@GLIBC_2.3.2 ()
from /nix/store/wx1vk75bpdr65g6xwxbj4rw0pk04v5j3-glibc-2.27/lib/libpthread.so.0
4 Thread 0x7f1779806700 (LWP 9402) "fish" 0x00007f1781cceee2 in pthread_cond_wait@@GLIBC_2.3.2 ()
from /nix/store/wx1vk75bpdr65g6xwxbj4rw0pk04v5j3-glibc-2.27/lib/libpthread.so.0
@sheenobu
sheenobu / sway-mock-build.sh
Created October 27, 2019 23:30
sway building in mock environment in fc31
#!/usr/bin/env bash
echo "include('/etc/mock/templates/fedora-31.tpl')
config_opts['target_arch'] = 'x86_64'
config_opts['legal_host_arches'] = ('x86_64',)
config_opts['plugin_conf']['bind_mount_enable'] = True
config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('$PWD/sway-tmp', '/d'))
" > swaymock.cfg
gdb) i thr
Id Target Id Frame
* 1 Thread 0x7ffff539b080 (LWP 18338) "waybar" 0x00007ffff7123dc9 in pthread_mutex_lock () from /lib64/libpthread.so.0
2 Thread 0x7fffe83ed700 (LWP 18346) "gmain" 0x00007ffff70435c7 in poll () from /lib64/libc.so.6
3 Thread 0x7fffe7bec700 (LWP 18347) "pool-waybar" 0x00007ffff7048fad in syscall () from /lib64/libc.so.6
4 Thread 0x7fffe73ad700 (LWP 18348) "gdbus" 0x00007ffff70435c7 in poll () from /lib64/libc.so.6
5 Thread 0x7fffe6bac700 (LWP 18349) "dconf worker" 0x00007ffff70435c7 in poll () from /lib64/libc.so.6
6 Thread 0x7fffe60ac700 (LWP 18354) "waybar" 0x00007ffff712a93d in __lll_lock_wait () from /lib64/libpthread.so.0
7 Thread 0x7fffe58ab700 (LWP 18355) "waybar" 0x00007ffff712ae7c in recv () from /lib64/libpthread.so.0
9 Thread 0x7fffe48a9700 (LWP 18359) "threaded-ml" 0x00007ffff70435c7 in poll () from /lib64/libc.so.6
@sheenobu
sheenobu / sway-4133-gdb.txt
Created June 1, 2019 01:55
gdb session. drag window to top of the screen
> gdb ./build/sway/sway
(gdb) run -c config
...
Thread 2 "sway:disk$0" received signal SIG33, Real-time event 33.
(gdb) list handle_cursor_motion_absolute
264 e->unaccel_dx, e->unaccel_dy);
265 transaction_commit_dirty();
266 }
267
268 static void handle_cursor_motion_absolute(
@sheenobu
sheenobu / docker-compose.yml
Created February 23, 2017 14:08
consul 0.7 in compose
version: "2"
services:
consul:
build: ./consul/0.7/consul
image: gliderlabs/consul:0.7
consul-agent:
build: ./consul/0.7/consul-agent
image: gliderlabs/consul-agent:0.7
consul-server:
build: ./consul/0.7/consul-server
@sheenobu
sheenobu / .nixpkgs.config.nix
Last active February 18, 2017 14:11
[BAD, don't do this] wrapBinary for wrapping chromium with additional flags (not sure if i like this yet)
with import <nixpkgs> {};
let
# wrapBinary builds a new derivation that wraps the given package and binary file with makeWrapper,
# using the given params. Supports wrapping a binary without forcing a recompilation.
# * name - Package name
# * package - The package we are wrapping
# * binary - Binary the binary name within $package/bin/$binary
@sheenobu
sheenobu / .nixpkgs.config.nix
Created February 11, 2017 04:42
Create a desktop entry for a webapp using Chromium --app and Nix
with import <nixpkgs> {};
let
webApp = { name, title, url }: stdenv.mkDerivation rec {
inherit name;
src = pkgs.writeText "src" ''
[Desktop Entry]
Version=1.0
Terminal=false
{
wine = {
release = "staging"; # "stable", "unstable", "staging"
build = "wineWow"; # "wine32", "wine64", "wineWow"
pulseaudioSupport = true;
};
packageOverrides = pkgs: {
wine = pkgs.stdenv.lib.overrideDerivation pkgs.wine (oldAttrs : {
wineBuild = "wineWow";