Skip to content

Instantly share code, notes, and snippets.

import scala.swing._
class BangIcon(ext: Int = 16) extends javax.swing.Icon {
def getIconWidth = ext
def getIconHeight = ext
var selected = false
def paintIcon(c: java.awt.Component, g: java.awt.Graphics, x: Int, y: Int) =
if (selected) {
// version 02-Apr-2019 - Mellite 2.33.0
// written by Hanns Holger Rutz
// license: CC BY-SA 4.0
val in0 = ImageFileIn("in")
val w = in0.width
val h = in0.height
val hm = h - 1
val in1 = in0.out(0)
val dur = "dur" .attr(10)
// quick and dirty from
// https://math.stackexchange.com/questions/40164/how-do-you-rotate-a-vector-by-a-unit-quaternion
def quaternion_mult(q: Vector[Double],r: Vector[Double]) =
Vector(r(0)*q(0)-r(1)*q(1)-r(2)*q(2)-r(3)*q(3),
r(0)*q(1)+r(1)*q(0)-r(2)*q(3)+r(3)*q(2),
r(0)*q(2)+r(1)*q(3)+r(2)*q(0)-r(3)*q(1),
r(0)*q(3)-r(1)*q(2)+r(2)*q(1)+r(3)*q(0))
def point_rotation_by_quaternion(point: Vector[Double],q: Vector[Double]) = {
val in1 = ImageFileIn("in1")
val in2 = ImageFileIn("in2")
val width = 1116
val height = 372
val f1 = Real2FullFFT(in1,rows = height, columns = width)
val f2 = Real2FullFFT(in2,rows = height, columns = width)
val mixA = f1 atan2 f2
val mixB = f1 roundTo f2
val mix = mixA.complex * mixB
val back = Real2FullIFFT(mix, rows = height, columns = width)
@Sciss
Sciss / 40-usb_modeswitch.rules
Created September 2, 2018 18:48
sudo vi /lib/udev/rules.d/40-usb_modeswitch.rules
# Huawei E353/E3131 - HHR 02-Sep-2018
ATTR{idVendor}=="12d1", ATTR{idProduct}=="1506", RUN +="usb_modeswitch '%b/%k'"
  • T165
  • T167
import javax.imageio.ImageIO
import java.awt.image.BufferedImage
////////////////////
val f = file("/data/temp/imperfect-reader.jpg") // JPEG colour
val in = ImageIO.createImageInputStream(f)
val reader = ImageIO.getImageReaders(in).next()
import de.sciss.kollflitz.Vec
import de.sciss.kollflitz.Ops._
case class Segment(numFrames: Int, targetLevel: Double, curve: Curve = Curve.linear) {
require (numFrames > 0)
}
object Envelope {
implicit def constant(f: Double): Envelope = Envelope(f, Vector.empty)
}
package foo
import scala.concurrent.stm._
object Test {
def main(args: Array[String]): Unit = {
var b = true
atomic { implicit tx =>
println("atomic")
// straight translation from Java
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed 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