Skip to content

Instantly share code, notes, and snippets.

@Excedrin
Excedrin / gist:91cf98f60f66bf46fcdc4b3834793fb9
Created October 7, 2024 18:54
sway better image capture, with cursors and mouse over by first capturing all outputs, then displaying each captured image on each output and using slurp and grim to select and capture from these "overlay" images. Requires: sway, grim, jq, swayimg, slurp.
#!/usr/bin/env bash
# Create a temporary directory for screenshots
tmpdir=$(mktemp -d)
# Get the list of active outputs
outputs=$(swaymsg -t get_outputs | jq -r '.[] | select(.active) | .name')
initial_focus=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')
def selfdec(f):
def dec(*x, **kwa):
f.__globals__['self'] = x[0]
return f(*x[1:], **kwa)
return dec
class X():
@selfdec
def z(more, args, even="opt"):
self.hurr = 3
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Virt management features
Copyright 2007, 2012 Red Hat, Inc
Michael DeHaan <[email protected]>
Seth Vidal <[email protected]>
@Excedrin
Excedrin / bind.py
Last active December 21, 2015 01:59
#!/usr/bin/python
# This file is part of Ansible
#
# Ansible 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 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#!/bin/bash
set -e
VERSION=$1
INSTALLER="OCTGN-Setup-${VERSION}.exe"
echo $VERSION $INSTALLER
@Excedrin
Excedrin / gist:3612698
Created September 3, 2012 19:33
imperative foldl and foldr
#!/usr/bin/rdmd
import std.stdio;
int sub(int x, int y) {
return x - y;
}
void main() {
int init = 0;
@Excedrin
Excedrin / forkeval
Created August 27, 2012 08:24
2007 python multiprocessing
import os
def evalexit(code):
eval(code)
raise SystemExit
def forkexpr(s):
code = compile(s, "<string>", "eval")
os.fork() or evalexit(code)
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#define CHAR_BIT 8
#define MAXBITS (CHAR_BIT*sizeof(uintmax_t))
#define FMT_BUF_SIZE (MAXBITS+1)
char *binary_fmt(uintmax_t x, char buf[static FMT_BUF_SIZE])
{
#!/usr/bin/python2
import multiprocessing
import socket
import time
import os
def handle(socket):
import logging
logging.basicConfig(level=logging.DEBUG)