Skip to content

Instantly share code, notes, and snippets.

@mhaulo
mhaulo / foo.rb
Last active August 26, 2020 12:38
def detect_text(input_file)
input = MiniMagick::Image.open(input_file.path)
Tempfile.open(["", ".tif"]) do |tempfile|
MiniMagick::Tool::Convert.new do |convert|
convert.density 300
convert << input.pages.first.path
convert.alpha "off"
convert << tempfile.path
end
@mhaulo
mhaulo / gist:cb52d5498f8ccfa58925031a3ed06c88
Created September 4, 2016 19:03
fuck! : bash alias to repeat last command using sudo
# Add the following line to .bashrc
#
# Usage:
# $ mkdir /some/dir/foo
# mkdir: cannot create directory ‘/some/dir/foo’: Permission denied
# $ fuck!
# [sudo] password for username:
#
alias fuck!='sudo $(history -p !!)'
@mhaulo
mhaulo / jalki_new_routes.js
Last active October 16, 2018 15:09
Jälki.fi-reittipalvelun uusien reittien tuonti REST-rajapinnan yli
var request = new XMLHttpRequest();
request.open("GET", "https://jalki.fi/routes.json?sort_by=created_at desc&max_results=5", false);
request.send(null);
var response = JSON.parse(request.responseText);
for (i in response) {
var title = response[i].title;
var date = new Date(response[i].created_at);
var dateString = date.getDate() + "." + (date.getMonth()+1) + "." + date.getFullYear();
var url = "https://jalki.fi/routes/" + response[i].id;