Skip to content

Instantly share code, notes, and snippets.

@wincentbalin
wincentbalin / Makefile
Created Jan 31, 2014
Makefile for batch OCR
View Makefile
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 Sep 25, 2016
Remove prepended 4-digits numbers from filenames.
View denumerate-files.sh
#!/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 Jan 13, 2017
Look at the data at different offsets of a file
View ripper.sh
#!/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 Oct 28, 2017
Dump innerHTML at Firefox console
View command.js
$x('//div[@class="content"]').forEach(function(el) { console.log(el.innerHTML); console.log('----'); })
@wincentbalin
wincentbalin / videocutter.py
Last active Nov 1, 2017
How to cut videos automatically using FFMPEG
View videocutter.py
#!/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 Dec 15, 2017
Run IDLE from a batch file
View idle.bat
@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 Dec 22, 2017
Get SQLite compile_options from Qt SQLite
View main.cpp
#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 Jan 3, 2018
Create calendar form on a A4 page
View create-calendar.sh
#!/bin/sh
pcal -o june.ps -P a4 -M -F 1 -E 01 2018
ps2pdf june.ps
@wincentbalin
wincentbalin / remove_stopped_containers.sh
Created Feb 27, 2018
Remove stopped Docker containers
View remove_stopped_containers.sh
#!/bin/sh
docker rm $(docker ps -a -q)
@wincentbalin
wincentbalin / remove_unused_images.sh
Created Feb 27, 2018
Remove unused Docker images
View remove_unused_images.sh
#!/bin/sh
docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")