Skip to content

Instantly share code, notes, and snippets.

View vdonchev's full-sized avatar

mr.d vdonchev

View GitHub Profile
<?php
$now = new DateTime();
$run_01_start = (new DateTime())->setTime(0, 0);
$run_01_end = (new DateTime())->setTime(1, 0);
$run_02_start = (new DateTime())->setTime(12, 0);
$run_02_end = (new DateTime())->setTime(13, 0);
$run_03_start = (new DateTime())->setTime(18, 0);
$run_03_end = (new DateTime())->setTime(19, 0);

Mounting VirtualBox shared folders on Ubuntu Server 18.04 LTS (Bionic Beaver)

This guide will walk you through the steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest.

Prerequisites

This guide assumes that you are using the following setup:

You could still make this guide work with other setups (possibly with some modifications to the commands and whatnot).

@vdonchev
vdonchev / .htaccess
Created March 22, 2021 17:19
PHP Front Controller
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [NC,L]
#!/bin/bash
cd /var/www/html
echo "<?php phpinfo();" > /var/www/html/i.php && curl -s http://localhost/i.php | sed 's/<[^>]*>//g' | grep 'PHP Version' && rm /var/www/html/i.php
@vdonchev
vdonchev / video_duration.php
Created February 15, 2021 06:41 — forked from xeoncross/video_duration.php
Get video duration from ffmpeg
<?php
$file = 'TrunkMonkey_Rescue.mov';
$result = shell_exec('ffmpeg -i ' . escapeshellcmd($file) . ' 2>&1');
preg_match('/(?<=Duration: )(\d{2}:\d{2}:\d{2})\.\d{2}/', $result, $match);
print_r($match);
@vdonchev
vdonchev / icecast-kh
Created February 5, 2021 04:44 — forked from ssamjh/icecast-kh
icecast-kh init.d Script (Ubuntu 20.04)
#!/bin/bash
### BEGIN INIT INFO
# Provides: icecast-kh
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the icecast-kh audio streaming server daemon
### END INIT INFO
#
a.asc, a.desc, a.sortable {
text-decoration: none !important;
}
a.asc:after {
content: "\2193";
}
a.desc:after {
content: "\2191";
@vdonchev
vdonchev / validHtml.txt
Created February 23, 2017 17:02
Valid HTML Tags in Array
["!DOCTYPE", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "h1 to h6", "head", "header", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]
<?php
$arr = preg_split('/\s+/', trim(fgets(STDIN)));
$input = trim(fgets(STDIN));
while ($input != 'print') {
$tokens = preg_split('/\s+/', $input);
$command = $tokens[0];
array_shift($tokens);
switch ($command) {
case 'add':
<?php
$str = strtolower(trim(fgets(STDIN)));
for ($i = 0; $i < strlen($str); $i++) {
if (ctype_alpha($str[$i])) {
$pos = letterPosition($str[$i]);
echo "{$str[$i]} -> {$pos}\n";
}
}
function letterPosition($letter)