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
| BufferedImage scaledImage = scale(sourceImage, width, height, SMOOTHING_STEPS); | |
| ByteArrayOutputStream buffer = new ByteArrayOutputStream(1024 * 1024); | |
| ImageOutputStream stream = ImageIO.createImageOutputStream(new BufferedOutputStream(buffer)); | |
| float percentage = quality; | |
| do { | |
| buffer.reset(); | |
| buildImage(scaledImage, width, height, imageType, stream, percentage); | |
| quality = percentage; | |
| percentage -= 0.005f; |
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
| private void buildImage(BufferedImage sourceImage, int width, int height, String imageType, Object target, float quality) throws IOException { | |
| ImageWriter imageWriter = writerFor(imageType, target); | |
| ImageWriteParam imageWriteParam = compressionParametersFor(imageWriter, quality); | |
| imageWriter.write(null, new IIOImage(sourceImage, null, null), imageWriteParam); | |
| imageWriter.dispose(); | |
| } | |
| private ImageWriter writerFor(String imageType, Object target) throws IOException { | |
| ImageWriter imageWriter = ImageIO.getImageWritersByFormatName(imageType).next(); | |
| imageWriter.setOutput(target); |
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 org.codehaus.jackson.annotate.{ JsonTypeInfo, JsonSubTypes, JsonProperty } | |
| import org.codehaus.jackson.annotate.JsonSubTypes.Type | |
| import org.codehaus.jackson.map.ObjectMapper | |
| @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") | |
| @JsonSubTypes(Array( | |
| new Type(value = classOf[Bingo], name = "x"), | |
| new Type(value = classOf[Bongo], name = "y"), | |
| new Type(value = classOf[Bungo], name = "z") | |
| )) |
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 | |
| ffmpeg -probesize 500000000 -i $1.mov -vcodec copy -an video.mov | |
| mplayer $1.mov -dumpaudio -dumpfile $1.raw | |
| sox -e signed-integer -b 24 -L -c 16 -r 48000 $1.raw $1.flac channels 2 | |
| ffmpeg -i video.mov -i $1.flac -vcodec libx264 $1.mp4 | |
| rm video.mov $1.raw $1.flac |
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
| ABC123D | Escort | 1973 | |
|---|---|---|---|
| BCD123E | Cortina | 1974 |
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
| ABC123D | Bob | |
|---|---|---|
| ABC123D | Sue | |
| BCD123E | Tim | |
| BCD123E | Joe | |
| BCD123E | Ann |
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 scala.io.Source | |
| case class Passenger(name: String, ridingIn: String) { | |
| def asNode = <Passenger name={ name }/> | |
| } | |
| case class Car(model: String, year: String, registration: String, passengers: Seq[Passenger]) { | |
| def asNode = | |
| <Car model={ model } year={ year } reg={ registration }> | |
| <Passengers> |
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
| <Car model="Escort" year="1973" reg="ABC123D"> | |
| <Passengers> | |
| <Passenger name="Bob"/><Passenger name="Sue"/> | |
| </Passengers> | |
| </Car> | |
| <Car model="Cortina" year="1974" reg="BCD123E"> | |
| <Passengers> | |
| <Passenger name="Tim"/><Passenger name="Joe"/><Passenger name="Ann"/> | |
| </Passengers> | |
| </Car> |
OlderNewer