Skip to content

Instantly share code, notes, and snippets.

View samcrosoft's full-sized avatar

Adebola Samuel Olowofela samcrosoft

View GitHub Profile
@samcrosoft
samcrosoft / random_dates.php
Created September 13, 2013 13:09
A PHP Method to generate random dates between two dates specificed with a format
<?php
/**
* Method to generate random date between two dates
* @param $sStartDate
* @param $sEndDate
* @param string $sFormat
* @return bool|string
*/
function randomDate($sStartDate, $sEndDate, $sFormat = 'Y-m-d H:i:s')
{
@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 / 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 / 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 / 1.html
Created September 25, 2013 12:47
This gist demonstrates how you can use a service into storing and manipulating global objects accross multiple controllers.
<!doctype html>
<html ng-app="appProject">
<head>
<title>Angular: Cross Controller Object Sharing Service example</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.0-rc2/css/bootstrap.css"/>
<script>
oSettings = new Object();
oSettings = {

Awesome PHP

A list of amazingly awesome PHP libraries, resources and shiny things.

Composer

Composer Related