Skip to content

Instantly share code, notes, and snippets.

View samcrosoft's full-sized avatar

Adebola Samuel Olowofela samcrosoft

View GitHub Profile
@samcrosoft
samcrosoft / get_duration.bash
Created June 12, 2019 14:53
Bash script to list all media files in a folder and display their durations and the total duration
#!/bin/bash
target_folder=$1
declare -a durations
file_extension=${2:-mp4}
function get_duration() {
duration=$(ffmpeg -i "${1}" 2>&1 | grep Duration | cut -d ' ' -f 4 | sed 's/,//i');
echo "${2}: ${1} is => [${duration}]";
duration_seconds=$(echo "${duration}" | awk -F ':' '{answer=($1*60*60)+($2*60)+($3)} END{print answer}');
durations[$2]="${duration_seconds}"
}
@samcrosoft
samcrosoft / reset_id_column.sql
Created December 5, 2018 14:58 — forked from irazasyed/reset_id_column.sql
MySQL: Reset id column to auto increment from 1
-- your_table: The table to modify
-- id: The id field/column to reset
SET @num := 0;
UPDATE your_table SET id = @num := (@num+1);
ALTER TABLE your_table AUTO_INCREMENT =1;
@samcrosoft
samcrosoft / Dockerfile
Created September 14, 2018 11:15
Dockerfile for Running Laravel With PHP Local Server
FROM epcallan/php7-testing-phpunit:7.1-phpunit7
LABEL maintainer="Adebola Olowofela <samcrosoft@gmail.com>"
WORKDIR /var/www
# this will copy the code from the src folder into the working directory
ADD src ./
CMD ["php", "-S", "0.0.0.0:80", "-t", "./public", "./public/index.php"]
EXPOSE 80
@samcrosoft
samcrosoft / Basic Docker
Last active September 10, 2018 11:28
Running A Docker Container Interactively and Start In Bash
# Start an ubuntu image and go into shell
1) common way
$ docker run -it ubuntu:latest /bin/bash
2) using entrypoint
$ docker run -it --entrypoint bash ubuntu:latest
3) full options spelt out
$ docker run --interactive --tty --entrypoint bash ubuntu:latest
@samcrosoft
samcrosoft / babel.sh
Created July 27, 2018 16:25 — forked from specialunderwear/babel.sh
Install all utf8 locales on ubuntu
#! /bin/sh
cd /usr/share/locales
./install-language-pack eo
./install-language-pack ia
./install-language-pack ie
./install-language-pack io
./install-language-pack vo
./install-language-pack ca
@samcrosoft
samcrosoft / readme.md
Created April 20, 2016 13:21 — forked from max-mapper/readme.md
ffmpeg youtube live event rtmp stream from raspberry pi with raspi camera (raspivid)
  1. compile ffmpeg for arm https://github.com/fiorix/ffmpeg-arm
  2. create youtube 'live event'. get rtmp url + session id
  3. run this:
raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/<SESSION>

you can tweak -b and -fps to your liking. the settings above work well for 1080p. by not specifying width or height we get the full 1920x1080 resolution from the raspi camera

@samcrosoft
samcrosoft / symfony2_nginx.conf
Last active August 29, 2015 14:26 — forked from ZipoKing/symfony2_nginx.conf
Sample nginx configuration for Symfony2
server {
listen 80;
server_name symfony2;
root /var/www/symfony2/web;
error_log /var/log/nginx/symfony2.error.log;
access_log /var/log/nginx/symfony2.access.log;
# strip app.php/ prefix if it is present
License Key PhpStorm 8
User Name : EMBRACE
===== LICENSE BEGIN =====
43136-12042010
00002UsvSON704l"dILe1PVx3y4"B3
49AU6oSDJrsjE8nMOQh"8HTDJHIUUh
gd1BebYc5U"6OxDbVsALB4Eb10PW8"
===== LICENSE END =====
@samcrosoft
samcrosoft / edit.blade.php
Created March 2, 2015 12:08
A quick snippet to use a condition to bind the display of all errors in a laravel blade view
@if($errors->has())
@foreach ($errors->all() as $error)
<p class="error">{!! $error !!}</p>
@endforeach
@endif
@samcrosoft
samcrosoft / forms.php
Created March 2, 2015 11:27
This is a macro that will help you create a radio button that will compare a default value with the old request, this is a really helpful improvement over the radio method of laravel
/**
* Create a radio button input field.
*
* @param string $name
* @param mixed $value
* @param bool $mDefault - this can be the default value for the radio
* @param bool $checked
* @param array $options
* @return string
* @static