Skip to content

Instantly share code, notes, and snippets.

View timokoola's full-sized avatar

Timo Koola timokoola

  • Skadi Oy
  • Helsinki
View GitHub Profile
#!/bin/bash
#
# Chrome Profile Lister
# Lists all Google Chrome profiles with email addresses only
# Format designed for easy selection and extraction in Keyboard Maestro
#
# Process command-line options
SHOW_HEADER=true
FORMAT="default"
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: cyan; icon-glyph: bus;
let [argsStop, topColorStr, bottomColorStr, textColorStr] = cleanParameters(
args?.widgetParameter
);
let topColor = new Color(topColorStr);
let bottomColor = new Color(bottomColorStr);
@timokoola
timokoola / scrapegrammar.js
Created October 13, 2020 14:45
Node.js snippet for quick json creation from scraped webpage (Chinese Grammar Wiki)
const cheerio = require("cheerio");
const got = require("got");
const fs = require("fs");
const hsk3URL =
"https://resources.allsetlearning.com/chinese/grammar/HSK_3_grammar_points";
(async () => {
const response = await got(hsk3URL);
const $ = cheerio.load(response.body);
@timokoola
timokoola / verb_end_syllable.py
Created August 24, 2017 19:31
End syllables of Finnish language verbs in base form (using Kotus sanalist)
import xmltodict
from libvoikko import Voikko
f = open("kotus-sanalista_v1.xml")
text = f.read()
f.close()
kotus = xmltodict.parse(text)
verbs = [x["s"] for x in kotus["kotus-sanalista"]["st"] if "t" in x and "tn" in x["t"] and int(x["t"]["tn"]) >= 52 and int(x["t"]["tn"]) <99 ]
@timokoola
timokoola / s3_uploader.py
Created August 23, 2017 12:58
Snippet to (crudely) resize images in a directory and upload to a S3 bucket
import os
from PIL import Image
desired_w = 300.0
bucket_name = "mybucket"
files = [x for x in os.listdir() if x.endswith("jpg")]
for i in files:
@timokoola
timokoola / adjective.py
Created July 6, 2017 11:43
Function to check if a word is an adjective in its baseform in Finnish using libvoikko
from libvoikko import Voikko
v = Voikko("fi")
def adjective(w):
analyzed = v.analyze(w)
for item in analyzed:
if "CLASS" in item and "laatusana" in item["CLASS"] and "SIJAMUOTO" in item and item[
"SIJAMUOTO"] == "nimento" and w == item["BASEFORM"]:
return True
return False
@timokoola
timokoola / release_notes.py
Created February 23, 2017 02:13
Python project release note in code
import os.path
import datetime
text = """
# Release note
Creating semi-autoupdated Python release notes with some timestamp magic.
Timestamp updates when document is saved and/or is `touch`:ed by a build script.
"""
timestamp = datetime.datetime.fromtimestamp(os.path.getmtime("release_notes.py")).isoformat()
@timokoola
timokoola / RecycleViewMatcher.java
Created November 30, 2016 08:29 — forked from baconpat/RecycleViewMatcher.java
RecycleViewMatcher (updated for scrolling)
package com.foo.RecyclerViewMatcher;
import android.content.res.Resources;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
@timokoola
timokoola / index.html
Created September 13, 2016 05:35 — forked from Culho/index.html
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<label t="translate(0,346)">
@timokoola
timokoola / gitlog.sh
Created January 6, 2016 12:11
My git log format line to create hourly reports from commit messages
# Prints out a tab separated line that includes short date format, placeholder for daily hours, double-slash, commit message and a full date in isoformat
git log --reverse --date=short --format="%cd%x0908:00%x09%s%x2F%x2F%ci"