Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Anh Nguyen <anh.ng8@gmail.com>
# 2016-04-30
# MIT License
# This script takes in same-size images from a folder and make a crossfade video from the images using ffmpeg.
# Make sure you have ffmpeg installed before running.
# The output command looks something like the below, but for as many images as you have in the folder.
<?php
$files = glob('orig/*.jpg');
foreach($files as $file) {
$newname = substr($file, 7, 2) . substr($file, 5, 2) . substr($file, 9);
$txt = substr($file, 5, 2) . '.' . substr($file, 7, 2) . '.' . substr($file, 9, 4);
exec('convert '.$file.' -resize 666x1170 \( xc:transparent -font PT_Sans-Narrow-Web-Bold.ttf -pointsize 50 -fill black -draw "rotate -4 text 20,60 '."'".$txt."'".'" -blur 0x1 \) -geometry +2+2 -composite -font PT_Sans-Narrow-Web-Bold.ttf -fill white -pointsize 50 -draw "text 20,60 '."'".$txt."'".'" renamed/'.$newname);
}
## karšu lasītājs
apt-get install pcscd pcsc-tools
pcsc_scan
## eparakstītājs: https://www.eparaksts.lv/lv/lejupielades
## pārējā draza
wget https://www.eparaksts.lv/files/ep3updates/debian/pool/eparaksts/l/latvia-eid-middleware/latvia-eid-middleware_2.0.6-1_amd64.deb
dpkg -i latvia-eid-middleware_2.0.6-1_amd64.deb
@Mad182
Mad182 / frame_drop.sh
Created May 9, 2018 13:27
Drop every second frame from GIF image
#!/bin/bash
# Drop every second frame from GIF image,
# using the same process as https://ezgif.com/optimize
#
# usage:
# frame_drop.sh in.gif out.gif
numframes=`gifsicle $1 -I | grep -P "\d+ images" --only-matching | grep -P "\d+" --only-matching`
frames=`expr $numframes - 1`
@Mad182
Mad182 / gist:169af152c7f8c720a3f8
Last active September 1, 2017 11:53
gif resize
//coalesce and resize as seen on https://ezgif.com/resize
exec(CONVERT . " '" . IMG_PATH . "/tmp/" . $file . "' -coalesce '" . IMG_PATH . "/tmp/coalesce_" . $file . "'");
exec(CONVERT . " -size " . $imsize[0] . "x" . $imsize[1] . " '" . IMG_PATH . "/tmp/coalesce_" . $file . "' -resize " . $width . "x" . $height . " '" . IMG_PATH . "/tmp/nonopt_" . $out . "'");
//compress to save bandwidth
exec(GIFSICLE . " -O3 --lossy=30 '" . IMG_PATH . "/tmp/nonopt_" . $out . "' >'" . IMG_PATH . "/tmp/" . $out . "'");
@Mad182
Mad182 / gist:afc81f622d4d80940d74
Created October 14, 2014 09:05
Create options array for cakephp form (mysql enum field)
public function getSelectOptions($column) {
$type = $this->getColumnType($column);
$menus = array();
preg_match_all("/'(.*?)'/", $type, $enums);
if (!empty($enums[1])) {
foreach ($enums[1] as $menu) {
$menus[$menu] = str_replace('_', ' ', ucfirst(__($menu)));
@Mad182
Mad182 / gist:8388401
Last active January 3, 2016 01:19
yt embed
function embed_youtube($params) {
var_dump($params);
//druka ārā embed kodu,
//var atvilkt title un sīkbildi caur api,
//pieglabāt lokāli, vai ko nu katram vajag
}
$txt = preg_replace_callback("#(^|[\n ]|<a(.*?)>)https?://(www\.)?youtube\.com/watch\?v=([a-zA-Z0-9\-_]+)((.*?)</a>)?#im", embed_youtube, $txt);
@Mad182
Mad182 / varnish-config.vcl
Created June 27, 2013 09:55
My Varnish configuration
#
# My varnish config
# caches all static files (images, js, css, txt, flash)
# but requests from backend dinamic content
#
# webserver
backend default {
.host = "127.0.0.1";
.port = "8080";
@Mad182
Mad182 / optimize.sh
Created June 27, 2013 09:55
Recursive image optimization
#!/bin/bash
optimize() {
jpegoptim *.jpg --strip-all
optipng *.png
for i in *
do
if test -d $i
then
cd $i
echo $i
0-mail.com
0815.ru
0845.ru
0clickemail.com
0wnd.net
0wnd.org
10mail.com
10mail.org
10minutemail.cf
10minutemail.co.za