Skip to content

Instantly share code, notes, and snippets.

View goosehub's full-sized avatar

Goose goosehub

View GitHub Profile
@goosehub
goosehub / strtolower_vs_strtoupper_performance_test.php
Created June 27, 2017 13:49
strtolower() vs strtoupper performance test
<?php
$string = 'hello world';
$start_time = microtime();
for ($i = 0; $i < $max = 10000000; $i++) {
strtolower($string);
}
$timed = microtime() - $start_time;
echo 'strtolower ' . $string . ' - ' . $timed . '<br>';
@goosehub
goosehub / convert_url.js
Last active July 7, 2018 16:19
Convert URL into embeds
function convert_youtube(input) {
var pattern = /(?:http?s?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(\S+)/g;
if (pattern.test(input)) {
var replacement = '<iframe width="420" height="345" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>';
var input = input.replace(pattern, replacement);
// For start time, turn get param & into ?
var input = input.replace('&amp;t=', '?t=');
}
return input;
}
// http://stackoverflow.com/a/5727346/3774582
// Parse CRON frequency
// Break it down like James Brown
function parse_crontab($time, $crontab) {
// Get current minute, hour, day, month, weekday
$time = explode(' ', date('i G j n w', strtotime($time)));
// Split crontab by space
$crontab = explode(' ', $crontab);
// Foreach part of crontab
foreach ($crontab as $k => &$v) {
@goosehub
goosehub / tinyboardstyle
Created September 14, 2014 06:13
Tinyboard Alternative Style
@font-face {
font-family: hellogoodbye;
src: url(/chan/stylesheets/fonts/hellogoodbye.otf);
}
body {
background: #FFFFFF url('img/fade-miku.png') repeat-x 50% 0%;
color: black;
font-family: arial, helvetica, sans-serif;
font-size: 10pt;