Skip to content

Instantly share code, notes, and snippets.

View nmfzone's full-sized avatar
🍿
I'm hungry

Nabil Muhammad Firdaus nmfzone

🍿
I'm hungry
View GitHub Profile
@nmfzone
nmfzone / ImageExtractor.php
Last active September 19, 2021 18:55
Image Extractor from WYSIWYG
<?php
namespace Spark\Utility;
use Closure;
use Illuminate\Support\Str;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\HttpFoundation\File\File;
class ImageExtractor
@nmfzone
nmfzone / AppServiceProvider.php
Last active April 9, 2019 16:20
Laravel Redirect to Query String
<?php
namespace App\Providers;
use Illuminate\Support\Arr;
use Illuminate\Routing\Redirector;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@nmfzone
nmfzone / letsencrypt.conf
Last active March 20, 2019 04:59
Nginx Config for JS Family (Nuxt, Angular, Next, Express)
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /var/www/letsencrypt;
}
@nmfzone
nmfzone / README.md
Created February 14, 2019 09:58 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@nmfzone
nmfzone / MyManagedResource.scala
Created February 5, 2019 05:54 — forked from jroper/MyManagedResource.scala
Play resource routing
class MyManagedResource extends ResourceController[String] {
def index = Action(Ok("index"))
def newScreen = Action(Ok("new"))
def create = Action {
Redirect(MyInjectableResource.reverseRoutes.index())
}
def show(id: String) = Action(Ok("Show " + id))
@nmfzone
nmfzone / .gitlab-ci.yml
Created January 21, 2019 18:47 — forked from superjose/.gitlab-ci.yml
This is an example of a .gitlab-ci.yml that is required for Continuous Integration on GitLab projects.
# Reference: https://www.exclamationlabs.com/blog/continuous-deployment-to-npm-using-gitlab-ci/
# GitLab uses docker in the background, so we need to specify the
# image versions. This is useful because we're freely to use
# multiple node versions to work with it. They come from the docker
# repo.
# Uses NodeJS V 9.4.0
image: node:9.4.0
# And to cache them as well.
@nmfzone
nmfzone / fastcgi-php.conf
Last active May 8, 2020 15:12
Full Nginx Config for Nested Site. Example uses Laravel framework.
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
@nmfzone
nmfzone / remove-all-from-docker.sh
Created January 8, 2019 18:42 — forked from beeman/remove-all-from-docker.sh
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@nmfzone
nmfzone / index.php
Last active December 3, 2018 07:20
Attendances
<?php
// Require Laravel Illuminate\Support packages.
//
// composer require illuminate/support
//
$attendancesByDate = $attendances->groupBy(function ($attendance) {
return $attendance->time->toDateString();
});
@nmfzone
nmfzone / Laravel-Container.md
Created August 17, 2018 21:49
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).