Skip to content

Instantly share code, notes, and snippets.

@Sciss
Sciss / NimbusTheme.java
Created February 17, 2012 15:09
NimbusTheme.java
package ;
import javax.swing.*;
import java.awt.*;
// the problem is, NimbusThemeCreater misses keys which seem to be used,
// e.g. Button[Enabled].textForeground, and so forth.
public class NimbusTheme {
public static void loadTheme() {
@Sciss
Sciss / LED_Ring.sc
Created February 18, 2012 06:07
LED_Ring.sc
(
w = JSCWindow.new.front;
w.view.background_( Color.white );
w.drawFunc = {
// set the Color
JPen.translate( 100, 100 );
JPen.color = Color.black;
JPen.addArc( 100 @ 100, 15, 0.4 * 2pi, 0.66 * pi );
JPen.lineDash = FloatArray[ 2, 1 ];
JPen.width = 2;
@Sciss
Sciss / mac_infrared.sh
Created February 23, 2012 00:03
mac_infrared.sh
# on a "managed" mac where some idiot disabled certain preferences panes?
# just do it in the shell... enable/disable infrared reception:
defaults read /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled
defaults write /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled -bool yes
defaults write /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled -bool no
@Sciss
Sciss / gist:1995057
Created March 7, 2012 18:44 — forked from ryo1kato/gist:1949096
SSH key fingerprint
require 'base64'
require 'digest/md5'
ssh_pubkey='AAAAB3NzaC1yc2EAAAABIwAAAQEAxCw2nrIcdQ+7/tKy+6fk1qmICpl2qa8jxCLoG3pnGniDUUIOtRdEfnpHNHYWfwBVYIdGD5bmcFnXEfoxRjR2VpLXNeY/8PlCG5lARuQqkc720ZfoxsEQo3m+ixV4ylbuQfo8eDrELrn+MWiPluh699lWyvgZ/6oTW1nf2gsKabG+nV8uLvr7Znr230S8o8vhgo6O3cmfLGcfApUnG9kce1YOlz1D9F2x6vzDSO2W3s5/UTBmDvLj3Cza+yzmLp2fzAw97FL6LLwS2cLaVUayc6pZKqN+4Gu9LDPXFl4jkD2xzPTp7cuKdrJFaDsIa0OHzG+yVlDvWi8FkdU9O+xiuw=='
fingerprint = Digest::MD5.hexdigest(Base64.decode64(ssh_pubkey)).scan(/../).join(':')
puts fingerprint
@Sciss
Sciss / NaturalCompare.scala
Created March 13, 2012 19:29
Compare Strings 'naturally', i.e. respecting embedded integers
def naturalCompare( a: String, b: String ) : Int = {
val asz = a.length()
val bsz = b.length()
var sz = math.min( asz, bsz )
var ai = 0
var bi = 0
while( ai < asz && bi < bsz ) {
val ac = a.charAt( ai ).toUpperCase
val bc = b.charAt( bi ).toUpperCase
if( ac.isDigit && bc.isDigit ) {
@Sciss
Sciss / OnceMoreImplicits.scala
Created March 17, 2012 16:01
OnceMoreImplicits.scala
// this compiles and finds all implicits,
// so no clue why it doesn't work in the real case
trait _Var[ Tx, A ]
trait Sys[ S <: Sys[ S ]] {
type Tx
type Var[ A ] <: _Var[ S#Tx, A ]
def atomic[ A ]( fun: S#Tx => A ) : A
}
@Sciss
Sciss / FingerTreeBench.scala
Created March 22, 2012 19:52
FingerTreeBench.scala
// a few finger tree operations benchmarked on large
// trees, 22-mar-2012, using scala 2.9.1 / java 1.6.0_20 64-bit server.
// each test series performs from fresh 'sbt console'
// -------- preliminaries --------
def t() = System.currentTimeMillis()
def runOp( warmUp: Int, main: Int )( op: => Unit ) : Long = { var i = 0; while( i < warmUp ) { op; i += 1 }; val t1 = t(); i = 0; while( i < main ) { op; i += 1 }; val t2 = t(); t2 - t1 }
@Sciss
Sciss / SerializeSynthGraph.scala
Created March 27, 2012 23:21
SerializeSynthGraph.scala
import java.io._
import de.sciss.synth._; import ugen._
trait SomeOut
// it seems crucial that the UGenSource.SingleOut is annotated @serializable
// for some reason. While `SomeOut` doesn't need that.
@serializable abstract class SingleOut( val name: String ) extends SomeOut
case class LFSaw (rate: Rate, freq: GE, iphase: GE) extends SingleOut( "LFSaw" )
@Sciss
Sciss / sfnet2github.sh
Created April 19, 2012 21:47 — forked from stwalkerster/sfnet2github.sh
SourceForge.net svn repo to github git repo import script

Licence (MIT Licence)

Copyright (c) 2011 Simon Walker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@Sciss
Sciss / WordCountTeXShop.md
Created May 1, 2012 10:06
Enable Word Count in TeXShop

Word counting questions almost always lead to statements about its impossibility and/or uselessness. However, if you use TeXShop there is an engine for counting words (texcount) in the ~/Library/TeXShop/Inactive/texcount folder. Drag either of the engines out of its folder into the Engines folder, and you can use that to count words. To use it, choose it as the engine and then "typeset" the document. It will open a web summary of the counts and how it did it. It works off of the latex source, but is pretty good for most things.

From comp.tex.macosx