Skip to content

Instantly share code, notes, and snippets.

@ayosec
ayosec / list-images.sh
Last active Jul 14, 2022
Show image thumbnails using Sixel graphics.
View list-images.sh
#!/bin/bash
#
# Usage:
#
# $ list-images [files]*
#
# This script is a demo to show how to use hyperlinks with images in Alacritty.
# It can be used on any terminal emulator with Sixel support, but it is not
# intended to be used for regular use, mostly because it lacks a proper way to
# handle errors (it just dies).
@ayosec
ayosec / clear-sixel-reg.rb
Created Jul 14, 2022
Clear pixels on a specific color register in a Sixel image.
View clear-sixel-reg.rb
#!/usr/bin/env ruby
#
# Usage:
#
# $ clear-sixel-reg register? files*
#
# The script reads Sixel images, are replaced every pixel using the
# specified color register with holes. The output is always sent to stdout.
#
# The `background selector` parameter of the protocol selector is forced
View list-files-in-sandbox.py
import os, sys
from ctypes import CDLL
libc = CDLL("libc.so.6")
CLONE_NEWNS = 0x00020000
CLONE_NEWCGROUP = 0x02000000
CLONE_NEWUTS = 0x04000000
CLONE_NEWIPC = 0x08000000
CLONE_NEWUSER = 0x10000000
@ayosec
ayosec / mpv-remove-files.md
Created Apr 30, 2022
Use MPV to remove unwanted media files with <d>
View mpv-remove-files.md

Use MPV to remove unwanted media files with d.

  • mpv.conf:

    d run mv -v "${filename}" /tmp/discard/ ; show-text "moved" ; playlist-next
    
@ayosec
ayosec / index.js
Created Mar 19, 2022
Function for CloudFlare Pages to use an `index.txt` file as the main page.
View index.js
// Path: <root>/functions/index.js
export async function onRequest(ctx) {
const url = new URL(ctx.request.url);
return await fetch(`${url.origin}/index.txt`);
}
@ayosec
ayosec / android-app-data.md
Last active Jan 10, 2022
Get data from an Android application
View android-app-data.md

Get data from an Android application

  • Find the package name of the application:

    $ adb shell pm list packages
  • Download a backup, with no password:

@ayosec
ayosec / remove-bright-colors.rb
Created Jan 6, 2022
Launch a program and remove bright colors from its output.
View remove-bright-colors.rb
#!/usr/bin/ruby
CHILD_CMD = ARGV.dup
# If either stdout or stderr is not a TTY, executes the program with no color
# translation.
if !STDOUT.tty? or !STDERR.tty?
exec(*CHILD_CMD)
end
@ayosec
ayosec / taskwarrior-recurring-tasks.sh
Last active Jan 4, 2022
Recurring tasks in TaskWarrior
View taskwarrior-recurring-tasks.sh
# On the 15th of every month.
#
# Show the task 5 days before the date.
PROJECT=foo.bar
DESCRIPTION='Something to do'
task add "$DESCRIPTION" \
project:"$PROJECT" \
View render.gnuplot
set term svg size 1400,1000 font "sans,30"
set output "plot.svg"
set style data fsteps
set timefmt "%Y-%m-%d"
set xlabel "Fecha (día/mes)"
set xdata time
set xrange [ '2021-11-01' : '2021-12-15' ]
View combine-squashfs.sh
#!/bin/bash
#
# Combine multiple squashfs files.
#
# Usage:
#
# $ ../combine-squashfs file1.squashfs file2.squashfs …
set -xeuo pipefail