Skip to content

Instantly share code, notes, and snippets.

View achmadfatoni's full-sized avatar
🏠
Working from home

Achmad Fatoni achmadfatoni

🏠
Working from home
View GitHub Profile
@achmadfatoni
achmadfatoni / slug-validation.php
Created September 8, 2016 03:36
Laravel slug validation
Validator::extend('slug', function($attribute, $value, $parameters, $validator) {
return preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/', $value);
});
@achmadfatoni
achmadfatoni / resize_scale_change_video_resolution_using_ffmpeg.md
Last active April 9, 2022 17:13
Resize/Scale/Change video resolution using ffmpeg

Check original video resolution

ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 filename-here.mp4

you will see file resolution like 1280x720

then resize to expected resolution:

@achmadfatoni
achmadfatoni / guzzle_raw_post_request.php
Created August 29, 2017 09:21
Guzzle Raw POST request
$client = new Client();
$array = [];
$res = $client->request('POST', $url, [
'body' => json_encode($array),
'headers' => [
'Content-Type' => 'application/json',
]
]);
@achmadfatoni
achmadfatoni / example.puml
Created December 10, 2020 08:02 — forked from QuantumGhost/example.puml
A simple template for PlantUML to draw ER diagram.The basic idea comes from http://plantuml.sourceforge.net/qa/?qa=331/database-modeling
@startuml
' uncomment the line below if you're using computer with a retina display
' skinparam dpi 300
!define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
' we use bold for primary key
' green color for unique
' and underscore for not_null
!define primary_key(x) <b>x</b>
!define unique(x) <color:green>x</color>
!define not_null(x) <u>x</u>
@achmadfatoni
achmadfatoni / node_nginx_ssl.md
Created July 30, 2020 15:38 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@achmadfatoni
achmadfatoni / generate_ssh_key
Created July 21, 2020 22:24
Generate ssh key
ssh-keygen -t rsa -b 4096 -C "achmadfatoni(replace with name)"
@achmadfatoni
achmadfatoni / simple_api_lumen_create_controller
Created August 18, 2017 11:59
simple_api_lumen_create_controller
<?php
namespace App\Http\Controllers;
use App\Models\Post;
use Illuminate\Http\Request;
class PostController extends Controller
{
public function store(Request $request)
@achmadfatoni
achmadfatoni / Laravel PHP7 LEMP and Mysql
Last active September 24, 2019 08:43 — forked from santoshachari/Laravel PHP7 LEMP AWS.md
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x and Mysql
#Steps to install latest Laravel, LEMP on AWS Ubuntu 14.4 version.
This tutorial is the improvised verision of this [tutorial on Digitalocean](https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-an-nginx-web-server-on-ubuntu-14-04) based on my experience.
## Install PHP 7 on Ubuntu
Run the following commands in sequence.
```
sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
<?php
/**
* It's an algorithm for generating a random permutation of a finit sequence - in plain terms, the algorithm shuffles the sequence.
*
* Reference: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
*/
function MyShuffle(&$arr) {
@achmadfatoni
achmadfatoni / ssl_nginx.conf
Last active December 26, 2017 21:15
letsencrypt laravel configuration
## http://domain.com and http://www.domain.com redirect to https://www.domain.com
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name domain.com www.domain.com;
include /etc/nginx/snippets/letsencrypt.conf;
location / {
return 301 https://www.domain.com$request_uri;