Skip to content

Instantly share code, notes, and snippets.

View micseydel's full-sized avatar

Michael Seydel micseydel

View GitHub Profile
import os
import sys
import json
import whisper
from time import perf_counter, ctime
# dependency: https://github.com/openai/whisper#setup
def log(s) -> None:
from typing import List, Optional
def get_array_from_dict(d: dict, key: str, default: List[object] = list()) -> List[object]:
"""Gets an array from a dict. Casts the type to List. Allows defaults to be set - no errors thrown."""
return d.get(key, default)
foo = get_array_from_dict({}, "foo")
bar = get_array_from_dict({}, "bar")
foo.append(1)
#!/usr/bin/env python3
import sys
from urllib.request import urlopen
# python3 -m pip install --user textblob
# python3 -m textblob.download_corpora
from textblob import TextBlob
def relevant_words():
trait A {
val foo: Int = {
println("A.foo")
1
}
println(s"foo on construction: $foo")
}
class B extends A {
import scala.collection.mutable
object Example {
case class Parent(private val childLocator: ChildLocator) {
lazy val child = childLocator.locate(from = this)
}
case class Child(parent: Parent)
class ChildLocator { // mutable
@micseydel
micseydel / TransportServer.java
Created May 17, 2018 23:05
Slightly modified copy of TransportServer.java from spark-networking-common v2.2.0.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
MONTHLY_INVESTMENT = 188.0
MONTHS_TO_INVEST = 120
YEARLY_INTEREST = 0.04
MONTHLY_INTEREST = (1 + YEARLY_INTEREST)**(1.0/12) - 1
def main():
balance = 0
for month in xrange(MONTHS_TO_INVEST):
@micseydel
micseydel / syntax.c
Created June 12, 2016 17:45
Weird C syntax from Pebble watch face tutorial
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload
});