Skip to content

Instantly share code, notes, and snippets.

View met's full-sized avatar
:octocat:

Martin Hassman met

:octocat:
View GitHub Profile
@met
met / Lua-idioms.md
Last active August 6, 2020 18:42
Lua idiomy

Lua idiomy

Idiomy jsou konstrukce, které se neřeší logikou, ale naučením. Ty první číslované pochází z oficiální knihy Roberto Ierusalimschy: Programming in Lua, 4th edition.

1. Defaultní hodnota proměnné

x = x or value

Je obdobou zápisu if not x then x = value Pokud hodnota x nemá hodnotu, přiřadí jí výchozí hodnotu value. Nefunguje správně, pokud má x hodnotu false.

@met
met / ReadNumbers
Created November 8, 2019 14:46
Language training. Listen to numbers in different voices. AppleScript.
# Different names for voices (you need to download them in macos settings)
# British: Daniel, Kate, Oliver, Serena
# Scotland: Fiona
# USA: Albert, Alex, Agnes, Kathy, Susan
# Australia: Karen, Lee
# Irland: Moira
# South Africa: Tessa
set voicesnames to {"Daniel", "Kate", "Oliver", "Serena", "Fiona", "Karen", "Lee", "Moira", "Tessa", "Albert", "Alex", "Agnes", "Kathy", "Susan"}
@met
met / sm_backup.js
Last active March 7, 2019 21:53
Backup of Supermemo.com to TSV (on page with Course editor choose Change Order and run this script in console, it will export only selected section of selected course)
(function() {
var dataPole=[];
document.querySelectorAll(".course-editor-browser-page-item").forEach(
function(line) {
var c1=line.querySelectorAll("div.page-item-content")[0].querySelector("div").innerText;
var c2=line.querySelectorAll("div.page-item-content")[1].querySelector("div").innerText;
/* transform enters */
c1 = c1.replace(/\n/g,"\\n");
c2 = c2.replace(/\n/g,"\\n");
@met
met / Sched.java
Created July 6, 2018 21:58
Spaced Repetition Implementation from AnkiDroid project https://github.com/ankidroid/Anki-Android/blob/master/AnkiDroid/src/main/java/com/ichi2/libanki/Sched.java (look for "Answering a review card" and "Interval management")
/****************************************************************************************
* Copyright (c) 2011 Norbert Nagold <norbert.nagold@gmail.com> *
* Copyright (c) 2012 Kostas Spyropoulos <inigo.aldana@gmail.com> *
* Copyright (c) 2013 Houssam Salem <houssam.salem.au@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General private License as published by the Free Software *
* Foundation; either version 3 of the License, or (at your option) any later *
* version. *
* *
@met
met / sched.py
Created July 6, 2018 21:51
Spaced Repetition implementation from Anki project https://github.com/dae/anki/blob/master/anki/sched.py (look for "Answering a review card" and "Interval management")
# -*- coding: utf-8 -*-
# Copyright: Damien Elmes <anki@ichi2.net>
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from __future__ import division
import time
import random
import itertools
from operator import itemgetter
from heapq import *
#
# SM2_mnemosyne.py <Peter.Bienstman@UGent.be>
#
import time
import random
import calendar
import datetime
from mnemosyne.libmnemosyne.translator import _
@met
met / remove_viet_accent
Created June 26, 2018 21:51
Remove Vietnamese accent in Google Spreadsheets
=REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(LOWER(A1);"[áàãảạâấầẫẩậăắằẵẳặ]";"a");"[éèẽẻẹêếềễểệ]";"e");"[íìĩỉị]";"i");"[óòõỏọôốồỗổộ]";"o");"[ớờỡởợ]";"ơ"); "[úùũủụ]";"u");"[ứừữửự]";"ư");"[yýỳỹỷỵ]";"y")