This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mkType(in: String): String = in.take(4).map(_.toHexString.toUpperCase).mkString("0x", "", "") | |
mkType("Zip2") // 0x5A697032 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[10pt]{article} | |
\usepackage[paperheight=20cm,paperwidth=20cm,top=0mm,bottom=0mm,left=0mm,right=0mm]{geometry} | |
\usepackage{tikz} | |
\usepackage{graphicx} | |
\usetikzlibrary{calc} | |
\begin{document} | |
\pagestyle{empty} | |
\begin{tikzpicture}[remember picture,overlay] | |
\node[anchor=north west,inner sep=0] at ($(current page.north west)+(25mm,-25mm)$) { | |
\fbox{\includegraphics[scale=1,trim=25mm 113.82833mm 112.5mm 25mm]{test-graphics.pdf}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright (C) InnoviData GmbH <http://www.innovidata.com>, 2011. | |
# Author: Holger Widmann <[email protected]> | |
# Version: 1.2.20110610 | |
# | |
# License: | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Lesser General Public License (LGPL) as | |
# published by the Free Software Foundation, either version 3 of the | |
# License, or (at your option) any later version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys.process._ | |
def read(f: File): String = { | |
val fin = new java.io.FileInputStream(f) | |
try { | |
val sz = fin.available() | |
val arr = new Array[Byte](sz) | |
fin.read(arr) | |
new String(arr, "UTF-8") | |
} finally { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~buf = Buffer.alloc(s, 64 * 4); | |
~buf.clear; | |
({ | |
var b, x, y, out, sig; | |
b = LocalBuf(1); | |
b.set(0); | |
y = Dbufrd(b); | |
x = (y + 1) % 7; | |
out = Duty.ar(SampleDur.ir, 0, Dbufwr(x, b)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def selectEdges(nv: Int = 18, ne: Int = 12) = { | |
var m = Map.empty[Int, Set[Int]] withDefaultValue Set.empty | |
val vr = (1 to nv) | |
vr.reverse.foreach { v => | |
val s0 = m(v) | |
val cand0 = vr.filterNot(s0.contains) | |
val cand1 = cand0.filter { v2 => m(v2).size < ne } | |
val tk = ne - s0.size | |
val cand = cand1.take(tk) | |
assert (cand.size == tk, s"Woops. wanted $tk got ${cand.size}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.{Color, Font, RenderingHints, Graphics2D} | |
val f = Font.createFont(Font.TRUETYPE_FONT, | |
new java.io.FileInputStream("/home/hhrutz/Downloads/alegreya/Alegreya-Regular.otf")) | |
val f1 = f.deriveFont(Font.PLAIN, 64) | |
val c = new scala.swing.Label { | |
override def paintComponent(g: Graphics2D): Unit = { | |
g.setFont(f1) | |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) | |
g.setColor(Color.WHITE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// given the number of edges of a complete graph, | |
// determine the number of vertices. will be integer, | |
// if this is a complete graph. | |
// | |
// solves edges = vertices * (vertices - 1) / 2 | |
def vertices(edges: Int): Double = { | |
val q = -2 * edges | |
val ph = -0.5 | |
val phs = 0.25 | |
val r = math.sqrt(phs - q) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// given w = width in pixels, h = height in pixels, inches = diagonal in inches, | |
// calculate display density in ppi | |
// ex. calcPPI(640, 384, 7.5) = 84 ppi | |
def calcPPI(w: Int, h: Int, inches: Double): Double = { | |
val aspect = w.toDouble / h | |
h / (inches.squared / (aspect + 1)).sqrt | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def modUp[A](a: A, b: A)(implicit num: Integral[A]): A = { | |
import num._ | |
val am = a - one | |
val z = if (gteq(am, zero)) am % b else { | |
val c = -am % b | |
if (c == zero) zero else b - c | |
} | |
z + one | |
} |