Skip to content

Instantly share code, notes, and snippets.

View marianogappa's full-sized avatar

Mariano Gappa marianogappa

View GitHub Profile
@marianogappa
marianogappa / str_repeat_func.php
Last active August 29, 2015 14:17
PHP function equivalent to str_repeat but taking a callable instead.
function str_repeat_func($function, $multiplier) {
if(!is_callable($function) || !is_integer($multiplier) || $multiplier <= 0)
return "";
$accumulator = "";
for($i = 0; $i < $multiplier; $i++)
$accumulator .= call_user_func($function);
return $accumulator;
}
import scala.io.Source
/* Boilerplate to make Java not throw Exceptions on non UTF-8 characters */
import java.nio.charset.CodingErrorAction
import scala.io.Codec
implicit val codec = Codec("UTF-8")
codec.onMalformedInput(CodingErrorAction.REPLACE)
codec.onUnmappableCharacter(CodingErrorAction.REPLACE)
/* Put your WAV file here. You might want to slice it; a full WAV file will exceed JVM memory limit */