Skip to content

Instantly share code, notes, and snippets.

#include <assert.h>
#include <fcntl.h> /* For O_* constants */
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h> /* For mode constants */
#include <unistd.h>
#include <wayland-client.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <wayland-client.h>
#include <wayland-server.h>
static struct wl_display *display = NULL;
static struct wl_event_loop *loop = NULL;
static bool running = true;
@kraftwerk28
kraftwerk28 / main.c
Created April 17, 2022 17:00
xdg activation v1 demo
#include <fcntl.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <wayland-client.h>
version: "3"
services:
ovpn:
image: dperson/openvpn-client
cap_add:
- NET_ADMIN
security_opt:
- label:disable
@kraftwerk28
kraftwerk28 / convert-to-telegram-webm-sticker.sh
Last active June 14, 2023 10:34
Telegram video sticker tool
#!/bin/bash
#
# Convert a video file to suitable format for Telegram video stickers.
# See: https://core.telegram.org/stickers#video-stickers
# If the video stream has duration larger than required, it will be sped up
# to match 3 seconds.
# Script requires `ffmpeg`, `ffprobe` and `jq` to be present in $PATH.
#
set -euo pipefail
if [[ $# -lt 2 ]]; then
#!/bin/bash
[[ -z $TOKEN ]] && { echo "No bot token provided" >&2; exit 1; }
URL="https://api.telegram.org/bot$TOKEN"
while :; do
res=$(curl -s "$URL/getUpdates" -F offset="${last_upd_id:-0}")
last_upd_id=$(jq -r '.result[-1].update_id + 1' <<<"$res")
while read -r msg; do
mention=$(jq -r \
'.new_chat_members[0]
| if .username then "@\(.username)"
#!/bin/bash
dx=10
dy=10
tree=$(swaymsg -t get_tree)
cur_window=$(jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)' <<<"$tree")
if [[ $(jq -r '.type' <<<"$cur_window") != "floating_con" ]]; then
echo "Script must be executed inside a floating window" 1>&2
exit 1
fi
cur_ws=$(jq -r 'recurse(.nodes[]?) | select(.type == "workspace" and (recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)))' <<<"$tree")
#include <assert.h>
#include <linux/input-event-codes.h>
#include <stdlib.h>
#include <wayland-client.h>
#include <wayland-cursor.h>
#include "list.h"
#include "log.h"
#include "swaybar/bar.h"
#include "swaybar/config.h"
#include "swaybar/input.h"
@kraftwerk28
kraftwerk28 / main.py
Created October 23, 2021 19:16
By @gofr from tsoding discord
std=type("",(),{"__getitem__":lambda _,__:__.step})();cout=type("",(),{"__lshift__":lambda _,__:_+print(__,end=""),"__add__":lambda _,__:_})();endl="\n";kw=type("",(),{"__sub__":lambda _,__:_+exec("_.__=str(__)",globals(),locals()),"__add__":lambda _,__:_,"__eq__":lambda _,__:exec("globals()[_.__]=var(__)",globals(),locals())});int=kw();float=kw();string=kw();char=kw();double=kw();unsigned=kw();long=kw();short=kw();struct=type("",(),{"__sub__":lambda _,__:_+exec("_.__=__" if isinstance(__,str) else "globals()[_.__]=struct_type()",globals(),locals()),"__add__":lambda _,__:_})();struct_type=type("",(),{"__add__":lambda _,__:_,"__sub__":lambda _,__:_+exec("globals()[__]=struct_val()",globals(),locals())});struct_val=type("",(),{"__getattr__":lambda _,__:_+exec("_.__dict__[__]=var()\n_.__=__",globals(),locals()),"__add__":lambda _,__:_.__dict__[_.__]});var=type("",(),{"__eq__":lambda _,__:_.__init__(__),"__init__":lambda _,__=None:exec("_.__=__",globals(),locals()),"__pow__":lambda _,__:_,"__repr__":lambda _:str(
@kraftwerk28
kraftwerk28 / init.lua
Created October 23, 2021 13:35
not-LUA
local http = require"ssl.https"
local url = require"socket.url"
local json = require"cjson"
local token = os.getenv("TOKEN")
local tguri = "https://api.telegram.org/bot"..token
local last_update_id = 0
local function process_update(update)
if not update.message then return end