Skip to content

Instantly share code, notes, and snippets.

Avatar

Mariano Gappa marianogappa

View GitHub Profile
@marianogappa
marianogappa / str_repeat_func.php
Last active Aug 29, 2015
PHP function equivalent to str_repeat but taking a callable instead.
View str_repeat_func.php
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;
}
View BinaryCraziness.scala
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 */