Skip to content

Instantly share code, notes, and snippets.

@wincentbalin
wincentbalin / Makefile
Created January 31, 2014 08:03
Makefile for batch OCR
CONVERT = convert
IMFLAGS = -verbose -colorspace gray -median 3x3 -resize 300% -blur 10
TESSERACT = tesseract
RM = rm
SRCS = $(wildcard *.pbm)
INTERMEDIATES = ${SRCS:.pbm=.tiff}
RESULTS = ${SRCS:.pbm=.txt}
@wincentbalin
wincentbalin / denumerate-files.sh
Last active September 25, 2016 10:27
Remove prepended 4-digits numbers from filenames.
#!/bin/sh
#
# Denumerate all files
for weekday in [0-9]*
do
cd "$weekday"
for file in *
do
if [ "$file" == "url.txt" ]
@wincentbalin
wincentbalin / ripper.sh
Created January 13, 2017 23:47
Look at the data at different offsets of a file
#!/bin/sh
#
# Rip files from the specified file using dd and file
#
# Copyright (C) 2017 Wincent Balin
# Check for supplied filename
if [ -z "$1" ]
then
echo Usage: ripper.sh file_to_rip
@wincentbalin
wincentbalin / command.js
Created October 28, 2017 15:17
Dump innerHTML at Firefox console
$x('//div[@class="content"]').forEach(function(el) { console.log(el.innerHTML); console.log('----'); })
@wincentbalin
wincentbalin / videocutter.py
Last active November 1, 2017 00:23
How to cut videos automatically using FFMPEG
#!/usr/bin/env python
"""
Cut videos specified in the description file using FFMPEG.
"""
import os
import sys
import subprocess
import argparse
@wincentbalin
wincentbalin / idle.bat
Created December 15, 2017 22:42
Run IDLE from a batch file
@echo off
if "%1" == "" goto start_without_arguments
:start_with_arguments
start /B python -m idlelib.idle %1 %2 %3 %4 %5 %6 %7 %8 %9
exit /B
:start_without_arguments
python -m idlelib.idle
@wincentbalin
wincentbalin / main.cpp
Created December 22, 2017 23:24
Get SQLite compile_options from Qt SQLite
#include <QCoreApplication>
#include <QTextStream>
#include <QSqlDatabase>
#include <QSqlQuery>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTextStream out(stdout);
QTextStream err(stderr);
@wincentbalin
wincentbalin / create-calendar.sh
Last active January 3, 2018 02:53
Create calendar form on a A4 page
#!/bin/sh
pcal -o june.ps -P a4 -M -F 1 -E 01 2018
ps2pdf june.ps
@wincentbalin
wincentbalin / remove_stopped_containers.sh
Created February 27, 2018 21:26
Remove stopped Docker containers
#!/bin/sh
docker rm $(docker ps -a -q)
@wincentbalin
wincentbalin / remove_unused_images.sh
Created February 27, 2018 21:26
Remove unused Docker images
#!/bin/sh
docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")