Skip to content

Instantly share code, notes, and snippets.

View oiva's full-sized avatar

Oiva Eskola oiva

View GitHub Profile
@oiva
oiva / position-terminals.scpt
Last active June 26, 2023 07:23
AppleScript to position newly created iTerm windows next to previous windows. Either in column or row direction
use framework "AppKit"
property ca : current application
on run {input, parameters}
-- calculate screen size
set activeScreenVisibleFrame to ca's NSScreen's mainScreen()'s visibleFrame()
set activeScreenSize to {ca's NSWidth(activeScreenVisibleFrame) as integer, ca's NSHeight(activeScreenVisibleFrame) as integer}
set screenWidth to item 1 of activeScreenSize
set screenHeight to item 2 of activeScreenSize
@oiva
oiva / janitor.py
Last active January 5, 2016 17:17
Talonmiesvuorot taulukkoon
#!/usr/bin/python
from datetime import datetime, timedelta
houses = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
# start from house number x + 1
start_index = 2
num_houses = len(houses)
start_of_year = datetime(2015, 12, 28)
@oiva
oiva / muhk.js
Last active August 29, 2015 14:23
Muhku
var fs = require('fs');
var _ = require('lodash');
var originalWords = [];
fs.readFile('alastalon_salissa.txt', 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
process(data);
@oiva
oiva / books.py
Last active August 29, 2015 14:15
Back to Work Reading List
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import codecs
from datetime import datetime
import feedparser
import sys
import re
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
@oiva
oiva / gist:e0aa2292f965f588d78f
Created November 26, 2014 13:34
IBAN to BIC test data
{
'FI1660012345678901': 'AABAFI22',
'FI8771312345678901': 'CITIFIHX',
'FI7980012345678901': 'DABAFIHH',
'FI0234012345678901': 'DABAFIHX',
'FI2637012345678901': 'DNBAFIHX',
'FI9133012345678901': 'ESSEFIHX',
'FI7531012345678901': 'HANDFIHH',
'FI0410012345678901': 'NDEAFIHH',
'FI8420012345678901': 'NDEAFIHH',
@oiva
oiva / OCR_service.applescript
Created August 2, 2013 10:34
Automator service for running PDFs through ABBYY FineReader Sprint. Saves results from OCR as .txt with same filename as the PDF.
on do_menu(app_name, menu_name, menu_item)
try
-- bring the target application to the front
tell application app_name
activate
end tell
tell application "System Events"
tell process app_name
tell menu bar 1
tell menu bar item menu_name
@oiva
oiva / ocr.applescript
Created August 2, 2013 10:32
AppleScript for Hazel, that runs given PDF's through ABBYY FineReader Sprint 8.0 and stores the resulting text as a .txt
on do_menu(app_name, menu_name, menu_item)
try
-- bring the target application to the front
tell application app_name
activate
end tell
tell application "System Events"
tell process app_name
tell menu bar 1
tell menu bar item menu_name
@oiva
oiva / pdf.py
Last active April 20, 2016 13:53
PDF.py is a small script that converts scanned images to PDFs, reads the text from the PDF with Tesseract OCR, and adds the text to the PDF metadata keywords. Currently the script looks for images in the same directory and keeps the output PDF there too. Probably only works in OS X. If the text file exists already, the OCR is not run again. Ther…
"""
Find scanned images or PDFs in directory, run Tesseract OCR on them.
Generate PDF, import the text content into the PDF's metadata.
"""
#!/usr/bin/env python
import codecs
import os
import re
from distutils.spawn import find_executable