Skip to content

Instantly share code, notes, and snippets.

@mabuak
mabuak / fileUploadTrait.php
Created May 19, 2018 09:27
Laravel File Upload Trait
<?php
/**
* Created by PhpStorm.
* User: DhanPris
* Date: 15/05/2018
* Time: 11:51
*/
namespace App\Http\Traits;
@mabuak
mabuak / projects.loc.conf
Created May 27, 2018 23:52
Nginx Laravel In Subdirectory
server {
listen 80;
root /home/projects/lara;
index index.html index.htm index.php;
server_name projects.loc;
location / {
@mabuak
mabuak / ssl-projects.loc.conf
Created May 28, 2018 01:44
Install ssl for nginx localhost
# Open terminal and paste this command
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
# Add this in you nginx config
server {
listen 443 ssl;
@mabuak
mabuak / CountrySeeder
Created May 31, 2018 01:23
Seed Raw SQL file in laravel
<?php
use Illuminate\Database\Seeder;
class CountrySeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
<?php
/**
* @author Ammar Faizi <ammarfaizi2@gmail.com>
* @license MIT
* @link https://t.me/laravelindonesia/111952
*/
for ($i=0; $i<10; $i++) {
echo "Test ".$i."\n";
@mabuak
mabuak / ws.imessage.loc.ssl.conf
Created June 28, 2018 08:46
websocket nginx configuration
# Install SSL Certificate
openssl req -x509 -out imessage.loc.crt -keyout imessage.loc.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=imessage.loc' -extensions EXT -config <( \
printf "[dn]\nCN=imessage.loc\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:imessage.loc\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
# Copy paste this nginx configuration
map $http_upgrade $connection_upgrade {
default upgrade;
@mabuak
mabuak / ws.imessage.loc.ssl.conf
Last active June 28, 2018 08:53
websocket apache configuration
# Install SSL Certificate
openssl req -x509 -out imessage.loc.crt -keyout imessage.loc.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=imessage.loc' -extensions EXT -config <( \
printf "[dn]\nCN=imessage.loc\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:imessage.loc\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
sudo a2enmod proxy && sudo a2enmod proxy_http && sudo service apache2 restart
# Copy paste this apache configuration
@mabuak
mabuak / docker-compose-laravel.txt
Created October 26, 2018 02:36
docker-compose-laravel
version: "2"
services:
web:
image: "docker-nginx-php7.1:latest"
container_name: web-lara
ports:
- "80:80"
- "443:443"
- "5300:5300"
privileged: true
@mabuak
mabuak / fixed_image_orientation.swift
Created November 6, 2018 07:30
Fixed Image Orientation Swift 4.2
// Fix Image Orientation
func fixImageOrientation(image:UIImage) -> UIImage
{
UIGraphicsBeginImageContext(image.size)
image.draw(at: .zero)
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage ?? image
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
POWERLEVEL9K_MODE='nerdfont-complete'
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
POWERLEVEL9K_RPROMPT_ON_NEWLINE=true
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_beginning"