Skip to content

Instantly share code, notes, and snippets.

var funStartStopMedia = function() {
console.log("play/stop");
var sl = Reveal.getCurrentSlide();
var e = sl.getElementsByTagName("audio")[0];
if (typeof e == 'undefined') {
e = sl.getElementsByTagName("video")[0];
};
if (typeof e !== 'undefined') {
if (e.paused) {
e.play();
val dirIn = userHome / "Downloads" / "bla"
val pIn = dirIn.children(_.name.endsWith(".html")).sorted(File.NameOrdering)
def getPageFiles(htmlF: File): Seq[File] = {
val dir = htmlF.parent
val in = new java.io.FileInputStream(htmlF)
val arr = new Array[Byte](in.available)
in.read(arr)
in.close()
val html = new String(arr, "UTF-8")
val ocrDir = file("/data/texts/ocr")
def all = ocrDir.children(_.extL == "txt")
// all.size
def findOCR2(words: List[String], contentsMaxChars: Int = 72, maxFileName: Int = 72): Unit =
new Thread {
override def run(): Unit = {
all.sorted(File.NameOrdering).foreach { f =>
// println(f.name)
val fIn = new java.io.FileInputStream(f)
[error] scala.MatchError: Literal(Constant(null)) (of class dotty.tools.dotc.ast.Trees$Literal)
[error] at dotty.tools.dotc.ast.tpd$.TypeApply(tpd.scala:54)
[error] at dotty.tools.dotc.ast.tpd$TreeOps$.appliedToTypeTrees$extension(tpd.scala:951)
[error] at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:3896)
[error] at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3251)
[error] at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:433)
[error] at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:853)
[error] at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:853)
[error] at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:544)
[error] at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:609)
val s = "978-3-9504622-3-"
val s0 = s.filter(_.isDigit)
val u = (s0 zip Iterator.continually(Seq(1, 3)).flatten).map { case (c, m) => c.toString.toInt * m } .sum
val v = u.roundUpTo(10)
val p = v - u // 4
s ++ p.toString // "978-3-9504622-3-4"
@Sciss
Sciss / library,js
Created December 27, 2020 19:28 — forked from aknuds1/library,js
Emscripten - how to pass an array of floating point numbers from JavaScript to a C callback, to let the latter fill it with data.
// "use strict";
var LibraryTst = {
initialize: function (callback) {
callback = Runtime.getFuncWrapper(callback, 'vi')
var numBytes = 2 * Float32Array.BYTES_PER_ELEMENT
var ptr = Module._malloc(numBytes)
try {
callback(ptr)
val OVR = 6
val F = OVR * 8
val SR = 48000.0
val mod1 = LFSaw(111.1 / (SR * OVR)).linLin(-1, 1, 10, 40)
val mod2 = LFSaw( 11.1 / (SR * OVR)).linLin(-1, 1, 190, 720)
val mod3 = LFSaw( 22.2 / (SR * OVR)).linLin(-1, 1, 11, 42)
val h = TrigHold(Metro(mod3 * F), (ArithmSeq(4, 1) % mod1) * F, Metro(mod2 * F))
val r = Resample(h, factor = 1.0/OVR) * 0.8
val l = LeakDC(r).drop(300)
//Plot1D(l, 400)
// output of 'sbt dependencyTree'
val e = scala.io.Source.fromFile(userHome/"Downloads"/"dep.txt")
.getLines.toList.filter(_.contains("+-de.sciss"))
.map { ln =>
val i = ln.indexOf("+-") + 2
val j = ln.indexOf(" ", i)
val k = ln.lastIndexOf(":", if (j < 0) ln.length else j)
ln.substring(i, k)
}
.sorted.distinct

Classes

  • java.io.BufferedInputStream
  • java.io.BufferedOutputStream
  • java.io.File
  • java.io.RandomAccessFile
  • java.io.FileInputStream
  • java.util.concurrent.ScheduledExecutorService
  • java.util.concurrent.ScheduledFuture
  • java.util.concurrent.Executors
// midiRatio( 10.5) shouldBe 1.8340080864049 +- eps
val fIn = file("/home/hhrutz/Documents/devel/Numbers/src/test/scala/de/sciss/numbers/DoubleSpecOLD.scala")
val lnIn = scala.io.Source.fromFile(fIn).getLines.toList
val lnOut = lnIn.map { ln =>
if (ln.contains("shouldBe")) {
val i_eps = ln.indexOf("+-")
val hasEps = i_eps > 0
val t_shd = " shouldBe "
val i_shd = ln.indexOf(t_shd)
val ln1 = if (!hasEps) ln else ln.substring(0, i_eps)