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/bash | |
# Before installing uncomment | |
# deb-src http://mirrors.online.net/ubuntu bionic main restricted | |
# in /etc/apt/sources.list | |
sudo apt update | |
sudo apt install build-essential | |
sudo apt build-dep imagemagick |
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
<?php | |
/** | |
* Input can be specified as basic array or array of arrays: | |
* - array = [key1 => weight1, key2 => weight2, ...] | |
* - array = [[..., weightKey => weight], [..., weightKey2 => weight2], ...] | |
* | |
* @param array $array Array to shuffle | |
* @param string|null $weight_key Optional weight key if input is array of arrays | |
*/ |
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
<?php | |
function randuid($len = 8) | |
{ | |
$uid = ''; | |
do { | |
$uid .= base_convert(random_int(PHP_INT_MIN, PHP_INT_MAX), 10, 36); | |
$uid .= strtoupper(base_convert(random_int(PHP_INT_MIN, PHP_INT_MAX), 10, 36)); | |
} while(strlen($uid) < $len * 2); | |
$uid = substr(str_shuffle($uid), 0, $len); |
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
<?php | |
/** | |
* @param array $data array of "key => weight" data to get random key from, all weights must be positive integers | |
* @return mixed key from $data array choosen by weighted random | |
*/ | |
function weightRandom(array $data) | |
{ | |
$c = count($data); | |
if (!$c) { |
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
<?php | |
$fp = popen('ls 2>&1', 'r'); | |
while(!feof($fp)) { | |
$str = fgets($fp); | |
} | |
pclose($fp); |
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
ffmpeg -ss <start_time> -i video.mp4 -t <duration> -q:v 2 -vf select="eq(pict_type\,PICT_TYPE_I)" -vsync 0 frame%03d.jpg |