Skip to content

Instantly share code, notes, and snippets.

@bathtime
bathtime / srtssa.sh
Last active December 26, 2023 22:22
srtssa.sh
#!/bin/bash
usage() {
echo "Version 0.15.1, GNU GPLv3
*** WARNING: ALPHA VERSION CODE!!! THIS PROGRAM EATS HAMSTERS! ***
This program takes an .srt, .txt, .pdf, or .epub file, translates it, and merges both translations
into an .ssa or .txt file in a parallel manner, allowing both subtitles to be viewed at the same time.
@bathtime
bathtime / Movie .srt
Last active March 31, 2020 14:15
Temporary place for movie scripts to be translated
1
00:03:12,440 --> 00:03:14,769
Salut. J'ai rendez-vous avec M. Ullman.
2
00:03:14,980 --> 00:03:16,939
Mon nom est Jack Torrance.
3
00:03:17,110 --> 00:03:19,649
@bathtime
bathtime / transmerge.sh
Last active June 22, 2024 02:26
A simple Linux shell script for translating an .srt file into another language and merging both languages into an .ass file
#!/bin/sh
#
# This program takes an .srt file, translates it, and merges both translations into a .ass file with the user's selected
# language on top of the screen and the other language at the bottom.
#
# Usage: ./transmerge.sh [source language] [target language] [language on top (en|fri|...)] [source .srt] [target .ass (optional)]
#
# ex., $ ./transmerge.sh en fr en movie.srt
#
/*
Key/Touch/Secondary Button Stimulator
Compile with:
gcc -Wall -O2 mouse.c -o mouse -lX11 -lXtst -lXext
SendKey function courtesy of:
https://bharathisubramanian.wordpress.com/2010/03/14/x11-fake-key-event-generation-using-xtest-ext/
/*
Config file: /home/pi/.config/dunst/dunstrc
gcc -o notify `pkg-config --cflags --libs libnotify` notify.c
*/
#include <libnotify/notify.h>
int main(int argc, char **argv) {
/*
g++ -Wall -O2 editfile.cpp -o editfile
*/
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/sendfile.h>
#include <sys/stat.h>
@bathtime
bathtime / youtube.cpp
Last active April 13, 2019 12:54
Launch Youtube from Primary/Clipboard Buffer
/*
Compile with:
gcc -O3 -Wall youtube.c -o youtube -lX11
*/
#include<X11/Xlib.h>
#include<unistd.h>
#include<stdio.h>
@bathtime
bathtime / Canada.sh
Created April 2, 2018 15:00
Weather
#!/bin/sh
URL="https://weather.gc.ca/city/pages/on-77_metric_e.html"
A='center">'
B='</p>'
C='>'
D='&deg'
echo $(wget -q -O- "$URL" | awk -v v1="$A" -v v2="$B" -v v3="$C" -v v4="$D" '$0 ~ v1 ".*" v2 {sub(v2 ".*", ""); sub(".*" v1, ""); print $0; next;} $0 ~ v3 ".*" v4 {sub(v4 ".*", ""); sub(".*" v3, ""); print $0 "°C"; exit}')
@bathtime
bathtime / bar.cpp
Last active April 2, 2018 16:36
Bar
// Compile with:
//
// g++ -std=c++11 -O2 -Wall bar.cpp -o bar -lasound -lpthread
//
#include<alsa/asoundlib.h> // install libasound2-dev
#include<fstream>
#include<iostream>
#include<string>
#include<chrono>
@bathtime
bathtime / BTree
Last active March 30, 2018 16:43
// This code comes from:
// https://www.geeksforgeeks.org/b-tree-set-1-insert-2/
//
// It has been altered to support a string index and two integer values.
//
#include<iostream>
#include<string>
using namespace std;