This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if ps -ef | grep -v grep | grep my_script.php ; then | |
exit 0 | |
else | |
php /var/www/my_script.php | |
exit 0 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertVideoToH264($original_file_path, $converted_file) | |
{ | |
//convert it | |
$cmd = "ffmpeg -i ".$original_file_path." -crf 20 -bufsize 20000k -maxrate 25000k -vcodec libx264 $converted_file"; | |
shell_exec($cmd); | |
if (!is_file($converted_file)) | |
{ | |
echo "FFMPEG conversion failed!, Skipping..."; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMeta($original_file_path) | |
{ | |
ob_start(); | |
passthru("ffmpeg -i ". $original_file_path . " 2>&1"); | |
$meta_data = ob_get_contents(); | |
ob_end_clean(); | |
return $meta_data; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Util.print_r = function(t, indent, done) | |
done = done or {} | |
indent = indent or '' | |
local nextIndent -- Storage for next indentation value | |
for key, value in pairs (t) do | |
if type (value) == "table" and not done [value] then | |
nextIndent = nextIndent or | |
(indent .. string.rep(' ',string.len(tostring (key))+2)) | |
-- Shortcut conditional allocation | |
done [value] = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Util.trim = function(s) | |
return (string.gsub(s, "^%s*(.-)%s*$", "%1")) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Util.round = function(num, idp) | |
local mult = 10^(idp or 0) | |
return math.floor(num * mult + 0.5) / mult | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Util.format_num = function(amount, decimal, prefix, neg_prefix) | |
local str_amount, formatted, famount, remain | |
decimal = decimal or 2 -- default 2 decimal places | |
neg_prefix = neg_prefix or "-" -- default negative sign | |
famount = math.abs(Util.round(amount,decimal)) | |
famount = math.floor(famount) | |
remain = Util.round(math.abs(amount) - famount, decimal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- load the JSON library. | |
local Json = require("json") | |
local JsonStorage = {} | |
-- Function to save a table. Since game settings need to be saved from session to session, we will | |
-- use the Documents Directory | |
JsonStorage.saveTable = function(t, filename) | |
local path = system.pathForFile( filename, system.DocumentsDirectory) | |
local file = io.open(path, "w") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Util:hex2rgb(hex) | |
hex = hex:gsub("#","") | |
return tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6)) | |
end |
OlderNewer