Skip to content

Instantly share code, notes, and snippets.

@soraxas
soraxas / gnome-terminal-prompt-closer.py
Last active June 4, 2020 14:33
script:Close excessive amount of Gnome-terminal instance
#!/bin/python
import subprocess
from time import sleep
from pprint import pprint
window_name = "\"Gnome-terminal\"" # exact name, can be changed to other window name
default_delay_time = 1
import sys
@soraxas
soraxas / git-go_next
Last active July 1, 2020 16:46
Git utilities! :) It's now being tracked in a standalone repository https://github.com/soraxas/git-utils
#!/bin/bash
# test git is working in cwd
# git || exit 1
# declare a wrapper function for git
git() {
command git "$@" || exit 1
}
@soraxas
soraxas / package.sh
Last active October 3, 2023 22:33
script:Open reverse port (or a range of ports), let it run in the background, and you can easily Ctrl-C it when you are done.
FISH_COMPLETIONS=reverse_port.sh.fish
@soraxas
soraxas / compress
Last active September 1, 2023 05:03
script:Auto extraction tool based on the file extension
#!/bin/bash
SAVEIFS=$IFS
IFS="$(printf '\n\t')"
DEFAULT_FNAME=compressed_output
DEFAULT_FORMAT=tar.gz
SCRIPT="$(basename $0)"
function help {
printf "Usage: %s [-o|--output FNAME] [-f|--format FORMAT] <file1> [file2] ... [-- [OPTS_TO_PASSTHROUGH]]\n" "$SCRIPT"
@soraxas
soraxas / pdfcrop.sh
Last active June 4, 2020 14:34
script:Cropping pdf to remove white boarder
#!/bin/bash
# from https://tex.stackexchange.com/questions/42236/pdfcrop-generates-larger-file/42259
function usage () {
echo "Usage: `basename $0` [Options] <input.pdf> [<output.pdf>]"
echo
echo " * Removes white margins from every page in the file. (Default operation)"
echo " * Trims page edges by given amounts. (Alternative operation)"
echo
@soraxas
soraxas / assh_parse_config.sh
Last active June 4, 2020 14:33
script:assh.yaml online parser, useful for system without assh installed.
#!/bin/sh
result="$(curl https://assh-dev.herokuapp.com/assh-to-ssh -X POST -F "assh_config=<$HOME/.ssh/assh.yml" | jq -r .ssh_config)"
# uncomment Hostname and remove colon
result="$(echo "$result" | sed 's/# HostName:/HostName/g')"
# delete proxycommand line
result="$(echo "$result" | sed '/ProxyCommand/d')"
@soraxas
soraxas / gist+x.sh
Last active August 23, 2023 04:02
script:Add executable permissions to Gist files. (based on https://gist.github.com/tueda/7741614)
#! /bin/sh
#
# @file gist+x.sh
#
# Gives executable file permissions to files in a Gist.
#
set -e
prog=`basename "$0"`
# Command line options.
@soraxas
soraxas / on-exit-sync.sh
Last active February 22, 2023 06:55
script:Taskwarrior auto sync script, with the ability to sync in background (non-blocking) and with delays so that it waits for you to finish modifing all files. In additions, it allows you to perform task undo (because once you have synced, you cannot undo). Requires tmux or screen for some form of background session.
#!/bin/bash
# This hooks script syncs task warrior to the configured task server.
# The on-exit event is triggered once, after all processing is complete.
# let's do a quick check. If the taskw command already is synchronize, we
# wouldn't need to run this script:)
for arg in $*; do
if [[ "$arg" == api:* ]]; then
IFS=':'
read -ra api_level <<< "$arg"
@soraxas
soraxas / taskwarrior-datetime-parser-wrapper
Last active February 6, 2023 23:38
script:Taskwarrior wrapper for intelligently parses datetime format (due, scheduled, etc.) in human language.
#!/bin/bash
# By soraxas
# This file shall be the wrapper for taskwarrior
# Do something like:
# alias task="taskwarrior-datetime-parser-wrapper"
# argunments that contain datetime format
TIME_FORMAT="(^|\W)(until|wait|due|scheduled):"
TASK="$(which task)"
@soraxas
soraxas / SurfingKeys.js
Last active November 3, 2023 21:09
SurfingKeys settings (vim keybindings for browser)
// git.io url: https://tinyurl.com/SurfingKeys-settings or https://git.io/JfXjB
// inspired by https://github.com/Foldex/surfingkeys-config/blob/master/config.js
// remove conflict with browser's history, download pannel toggle
// unmap('<Ctrl-j>');
// iunmap('<Ctrl-j>');
// vunmap('<Ctrl-j>');
// unmap('<Ctrl-h>');
// iunmap('<Ctrl-h>');
// vunmap('<Ctrl-h>');