Skip to content

Instantly share code, notes, and snippets.

@tarruda
tarruda / README.md
Last active April 8, 2024 23:13
LXD: Full Debian KDE desktop

Intro

This script will create a local LXD image that has a full KDE desktop environment with Xspice as the display server.

Instructions

./setup-debian-kde-desktop-xspice.sh    
lxc init debian-kde-desktop-xspice kde
lxc config device add kde xspicesocket proxy bind=host listen=unix:/tmp/kde.unix connect=unix:/run/xspice/spice.unix uid=1000 gid=1000

lxc start kde

@tarruda
tarruda / userns-with-vpn.xml
Last active December 23, 2023 10:05
Libvirt lxc configurations
<domain type='lxc'>
<name>vpntest</name>
<uuid>ffee008c-ec6b-48ab-af6d-4aba830847a1</uuid>
<memory unit='GiB'>8</memory> <!-- The container can use at most 8G of memory -->
<idmap>
<uid start='0' target='300000' count='65536'/>
<gid start='0' target='300000' count='65536'/>
</idmap>
<os>
<type arch='x86_64'>exe</type>
@tarruda
tarruda / bulk-rename.py
Created December 23, 2023 09:59
Deluge torrent bulk renamer
#!/usr/bin/env python3
# This script does batch renaming of torrents served by deluge. Useful to
# quickly rename all episodes of a TV show to match the expected patterns of
# local streaming services such as Plex or Jellyfin while still seeding the
# torrent.
# For example, consider you have a TV show that has a strange name not
# recognized by jellyfin, just use a regex replace to capture the episode
# number and rename to a pattern understood by Jellyfin:
@tarruda
tarruda / nvim_clipboard.py
Last active April 28, 2023 05:39
Neovim clipboard plugin
import xerox
class NvimClipboard(object):
def __init__(self, vim):
self.provides = ['clipboard']
def clipboard_get(self):
return xerox.paste().split('\n')
def clipboard_set(self, lines):
@tarruda
tarruda / gtk3-pyenv.sh
Created January 9, 2015 06:38
Install pygtk3 in pyenv
#!/bin/bash
# script for pyenv installation of pygtk3 in ubuntu 12.04
# Adapted from https://gist.github.com/mehcode/6172694
system_package_installed() {
if ! dpkg -l | grep -q $1; then
sudo apt-get install $1
fi
}
@tarruda
tarruda / setup-debian-mate-desktop-xspice.sh
Created July 29, 2022 01:38
Debian Mate Xspice desktop
#!/bin/bash
XSERVER_DISPLAY_NUMBER=15
set -eu -o pipefail
new_image_name=debian-mate-desktop-xspice
if lxc image info local:$new_image_name &> /dev/null; then
echo "Image already exists" >&2
@tarruda
tarruda / deploy.js
Created January 3, 2022 13:04 — forked from tuncatunc/deploy.js
Hardhat deploy script to deploy UniswapV2Factory, and create token pairs.
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
//
// When running the script with `hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
const hre = require("hardhat");
async function main() {
// Hardhat always runs the compile task when running scripts with its command
// line interface.
@tarruda
tarruda / .README.md
Last active September 27, 2021 13:21
Tmux/Vim integration

Some scripts/configurations that greatly improve tmux/vim workflows. The shell scripts target zsh but should be adaptable without much effort for other unix shells.

Features:

  • Transparently move between tmux panes and vim windows
  • Using the shell, open files in one vim instance per project or directory
  • Fully integrated copy/paste between tmux, vim and x11 using simple keybinds(need to install the xclip program)
  • Easily send text to any tmux pane without breaking your edit workflow(needs slimux

'vim-tmux-move.zsh', '.vimrc' and '.tmux.conf' cooperate so you can move transparently between tmux panes and vim windows using ALT + (arrow keys or jkhl). It was based on this gist

@tarruda
tarruda / snake.py
Last active June 11, 2021 00:01
snake.py
# Snake for Neovim! Adapted from https://gist.github.com/sanchitgangwar/2158084
# To install, create a ~/.vim/rplugin/python/snake.py file with this
# code, then run `nvim -c 'UpdateRemotePlugins' -c 'q'` from a shell.
#
# Make sure you have read the internal help explaining how to setup python
# host for external plugins(:help nvim-python)
#
# To start a new game, use the `:SnakeStart` command on an empty buffer(uses 80
# columns and 20 rows)
from threading import Thread, Lock
@tarruda
tarruda / .gitignore
Created May 14, 2021 19:25
Electron 10+ crash on windows 32-bit
node_modules
downloads
crashes