Skip to content

Instantly share code, notes, and snippets.

@bogomolov-dev
bogomolov-dev / frame-breakout.js
Created February 21, 2014 14:25
Frame breakout
if (top.location != self.location) {
top.location = self.location.href;
}
@bogomolov-dev
bogomolov-dev / responsive-iframe.scss
Created February 21, 2014 13:21
Responsive embedded iframe
.wrapper {
position:relative;
padding-bottom:56.25%;
padding-top:30px;
height:0;
overflow:hidden;
iframe {
position:absolute;
top:0;
@bogomolov-dev
bogomolov-dev / formatFileSize
Created January 28, 2014 13:18
Rechnet die übergebenen Bytes in die nächste passende Einheit um.
function formatFileSize($bytes)
{
$units = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB');
$result = "0.00 B";
if($bytes > 0)
{
$result = log($bytes) / log(1024);
$index = floor($result);
$result = round(pow(1024, $result - ($index)), 2)." ".$units[$index];
public static function slugify($text)
{
$search = array('ö', 'ä', 'ü', 'ß');
$replace = array('oe', 'ae', 'ue', 'ss');
// replace german letters
$text = str_replace($search, $replace, strtolower($text));
// replace all non letters or digits by -
$text = preg_replace('/\W+/', '-', $text);