I hereby claim:
- I am tjc on github.
- I am tjc (https://keybase.io/tjc) on keybase.
- I have a public key whose fingerprint is 928F E178 7459 A9A5 8D6E 853F 1C1E 2A07 021B 8378
To claim this, I am signing this object:
def ranges(ints: Seq[Int]): Seq[(Int, Int)] = { | |
ints.sorted.foldLeft( Seq[(Int,Int)]() )( | |
(acc: Seq[(Int,Int)], n: Int) => acc match { | |
// case Nil => acc :+ (n,n) | |
case x :: (a,z) if (z == n) => acc | |
case x :: (a,z) if (z+1 == n) => x :+ (a, n) | |
case _ => acc :+ (n,n) | |
} | |
) | |
} |
// This method works, but I'm trying to shrink it in the form further down.. | |
def ranges(ints: Seq[Int]): Seq[(Int, Int)] = { | |
ints.sorted.foldLeft( Seq[(Int,Int)]() )( | |
(acc: Seq[(Int,Int)], n: Int) => acc match { | |
case acc if (acc.nonEmpty) => acc.last match { | |
case (a,z) if (z == n) => acc | |
case (a,z) if (z+1 == n) => acc.init :+ (a, n) | |
case _ => acc :+ (n,n) | |
} |
// This is a fairly ugly solution; in a hurry and didn't spend much time on it. | |
import scala.util.Random | |
case class WeightedItem[T](item: T, weight: Double) | |
val items = Seq(WeightedItem("Red", 1d/6), WeightedItem("Blue", 2d/6), | |
WeightedItem("Green", 3d/6) ) | |
def weightedSelection[T]( |
This query plan results from a query that basically looks like | |
UPDATE line SET status = 'X' | |
WHERE line IN ( | |
SELECT id FROM a_view_based_on_views | |
WHERE file_id = 1 | |
) | |
AND file_id = 1; | |
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
my @args = @ARGV; | |
my $real = $0 . ".real"; | |
if (grep { /cortex.m/ } @args) { | |
my @new_args = grep { ! /^\-lm$/ } @args; | |
push @new_args, "-L/home/tobyc/git/arduino/lib", "-larm_cortexM4l_math", "-lm"; |
#define ARM_MATH_CM4 | |
#include "arm_math.h" | |
#define TEST_LENGTH_SAMPLES 1024 | |
#include "arm_fft_bin_data.h" | |
// static float32_t testOutput[TEST_LENGTH_SAMPLES/2]; | |
// NOTE: q15t is int16_t in arm_math.h | |
// Run with "scala convert.scala" | |
import scala.xml.XML | |
import scala.xml.Node | |
// Given a node, return a trimmed string containing its coordinates | |
def toCoords(node: Node): String = node match { | |
case node if ! (node \ "Point").isEmpty => (node \ "Point" \ "coordinates").text.trim | |
case node if ! (node \ "LineString").isEmpty => (node \ "LineString" \ "coordinates").text.trim | |
case node if ! (node \ "Polygon").isEmpty => (node \ "Polygon" \ "outerBoundaryIs" \ "LinearRing" \ "coordinates").text.trim | |
case _ => println(f"node unknown coords: %s", node \ "name"); "unknown" |
package main | |
import "fmt" | |
import "time" | |
import "github.com/mgutz/ansi" | |
const ledsAcross = 12 // rows of display | |
const ledsDown = 16 // columns of display (was 8) | |
const ledTotal = 12*16 | |
type Colour struct { |
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/env perl | |
use 5.12.0; | |
use warnings; | |
use IPC::Run qw(run); | |
use autodie; | |
=head1 NAME | |
convert_flac_to_mp3.pl |