Skip to content

Instantly share code, notes, and snippets.

View sentenza's full-sized avatar

Alfredo Torre sentenza

View GitHub Profile
@sentenza
sentenza / ngrxintro.md
Last active August 8, 2018 14:03 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series
@sentenza
sentenza / introrx.md
Created August 8, 2018 13:42 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@sentenza
sentenza / pwa.md
Created July 12, 2018 07:43
Writing Progressive Web Apps - Useful online resources
@sentenza
sentenza / quaternions.scala
Created May 26, 2018 21:41 — forked from propensive/quaternions.scala
Quaternions in Scala
object Algebra {
// Build up increasingly complex algebras
trait Magma[T] {
def add(x : T, y : T) : T
}
trait Monoid[T] extends Magma[T] {
def zero : T
}
@sentenza
sentenza / test_extract_thumbnail.php
Created October 26, 2017 11:03
Extract a thumbnail using PHP and FFmpeg
<?php
class Extract {
const FFMPEG_PATH = '/usr/bin/ffmpeg';
public function exec($psSource, $psDest) {
$aOutput = [];
$aError = null;
$sCommand = sprintf("%s -i %s -vframes 1 %s 2>&1", self::FFMPEG_PATH, $psSource, $psDest);
echo 'Executing: ' . $sCommand;
@sentenza
sentenza / formatBytes.php
Created October 26, 2017 08:58
Bytes formatting (KB, MB, GB)
<?php
/**
* Format an amount of bytes using a SI metric conversion
*
* Note: 1024 to express the format in KiB, MiB
*
* @author Alfredo Torre <[email protected]>
* @see https://en.wikipedia.org/wiki/Kibibyte
* @param string/int $pBytes
* @param int $piPrecision

Installing ffmpeg 3.4 and all the needed libraries

Dependencies

# From the official ffmpeg docs
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev \
libsdl1.2-dev libtheora-dev libtool libvorbis-dev pkg-config texinfo zlib1g-dev \
yasm libx264-dev libmp3lame-dev libvpx-dev libfdk-aac-dev
@sentenza
sentenza / scala_algorithms.md
Last active August 20, 2017 12:00
A list of resources and tutorials to start working with Scala and do everything properly

scalalgorithms

A collection of algorithms written in Scala. The target is to make a pure excersize playground for testing data structures and algorithms.

Any external dependency should be possibly avoided.

Sorting

Algorithms to be implemented:

  • quickSort
@sentenza
sentenza / version_natural_sorting_mysql.sql
Created August 15, 2017 14:16 — forked from alfred-dub/version_natural_sorting_mysql.sql
Natural ordering of migrations' versions using MySQL and Postgre
SELECT
SUBSTRING_INDEX(number, '.', 1) AS FIRST_INT,
SUBSTRING_INDEX(SUBSTRING_INDEX(number, '.', 2), '.', -1) AS SECOND_INT,
SUBSTRING_INDEX(number, '.', -1) AS THIRD_INT,
number as VERSION,
description as TITLE
FROM _version
ORDER BY
LENGTH(SUBSTRING_INDEX(number, '.', 1)) DESC,
SUBSTRING_INDEX(number, '.', 1) DESC,