Skip to content

Instantly share code, notes, and snippets.

View jasalt's full-sized avatar

Jarkko Saltiola jasalt

View GitHub Profile
@jasalt
jasalt / gist:bd29e4fc773a5b8f6c0faeb7b4bd3ba7
Created June 28, 2020 20:07 — forked from jaukia/gist:1d41a0045ab8e9f411ff
Most active public GitHub users in Finland — Feb 2015

Most active public GitHub users in Finland

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 12 Feb 2014 13:09:28 GMT till Thu, 12 Feb 2015 13:09:28 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter((user) -> user.followers > 11)
# record frames from a public camera in jyväskylä city centre for timelapse purposes etc
# uses threads, probably to not miss any frames, non threaded version commented in bottom
# written in 2016 during random student event happening in the city centre
# demo video https://youtu.be/tMSrBDwmtUo compiled with ffmpeg.
# stutters a bit cause duplicate frames are not processed
import requests
from io import open as iopen
from urlparse import urlsplit
#!/bin/bash
# Adjust homserver, room, and accesstoken to your particular setup
# Script is expecting data to be piped in on STDIN
# Example:
# echo "some text" | sendmatrix
msgtype=m.text
homeserver=<homeserver>
room=<room id>
#! /usr/bin/env python3
import toga
from toga.style.pack import CENTER, COLUMN, ROW, Pack
import asyncio
# Both are failing on Windows 10, Python 3.9.7, 3.8.6,
# Toga not installing on 3.9.1 cause pythonnet not supported yet.
@jasalt
jasalt / pdfplumber-tesseract.py
Created January 26, 2021 06:25
Extract tables from pdf using pdfplumber and pytesseract
# Extracting tabular data from pdf using Python pdfplumber together with Tesseract OCR
# Author Jarkko Saltiola 2021 (MIT License, Python 3.8.6)
# Pdfplumber, tabula, camelot and probably some other PDF parser utilities have hard
# time parsing tables that have column data overlapping over other columns, and
# probably on many other cases too.
# Pdfplumber gives a good level of control for splitting pdf into parts which can
# be read with it's methods or be passed for pytesseract as PIL image.
@jasalt
jasalt / woo_rest_cat_urls.php
Created May 25, 2021 12:22
Add product category urls to WooCommerce REST API v3
/* Adds category term links to /products/categories endpoint giving full urls / permalinks to the category archive pages. */
add_filter('woocommerce_rest_prepare_product_cat', 'rest_add_cat_url', 10, 3);
function rest_add_cat_url($response, $object, $request) {
if (empty($response->data)){ return $response; }
$response->data['term_link'] = get_term_link($object->term_id);
return $response;
}
@jasalt
jasalt / hacklabjkl_kävijäseuranta.html
Last active August 4, 2022 08:46
jkl.hacklab.fi Wordpress kävijäseuranta Block rev220804
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>HTML 5 Boilerplate</title>
<!-- <link rel="stylesheet" href="style.css"> -->
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
</head>
@jasalt
jasalt / wp-ajax-add-tag.js
Created May 17, 2022 14:40
Leftover plugin code doing ajax call securely with nonce and sanitisation. Discarded cause mixed up with existing states in post editor Tags -box.
// html page has a list of possible suggested tags rendered (see php file) which have a button from which they can be added as post tag eg:
// <p class="demo_tag">New demo tag<button class="button demo_add_keyword_as_tag_btn " data-nonce="XXX" data-demo_keyword="New demo tag" data-post_id="XXX">+</button></p>
// Click handler for buttons and ajax call
jQuery('.demo_add_keyword_as_tag_btn').click(function(e) {
e.preventDefault();
if (e.target.classList.contains("button-disabled")){
return;
};
@jasalt
jasalt / deshortcut_path.py
Created May 31, 2022 17:02
Replace file shortcuts in given path with files they point to (on MacOS).
#!/usr/bin/env python
import glob
import os
import sys
def print_help():
print(''' Replaces file shortcuts in given path with files they represent (on MacOS).
Directory shortcuts are skipped. Requires Python 3.10.