Skip to content

Instantly share code, notes, and snippets.

@M4R14
M4R14 / start project react by docker.md
Last active July 31, 2021 04:52
start project react by docker

start project react by docker

$ sudo docker run -w /app -v $(pwd):/app node npx create-react-app my-app

How to Migrate in Artisan GUI

  1. open 127.0.0.1/~artisan
  2. click Migrate
  3. check Force
  4. click Run

Artisan_GUI

@M4R14
M4R14 / deploy.sh
Created December 30, 2020 03:06 — forked from BenSampo/deploy.sh
Laravel deploy script
# Change to the project directory
cd /home/forge/domain.com
# Turn on maintenance mode
php artisan down || true
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin master
@M4R14
M4R14 / php-code-inspection.md
Last active December 22, 2020 08:24 — forked from hassanjamal/php-code-inspection.md
How to install PHP code inspection tools using homebrew-php and how to integrate with JetBrain's IntelliJ or PhpStorm

Inspection Tools with homebrew-php

Prerequisites

  • Homebrew is installed

Step 1: Installing homebrew-php##

  1. brew tap homebrew/dupes
  2. brew tap josegonzalez/homebrew-php
  3. brew install PHP53 (or other version of your choice)
@M4R14
M4R14 / .zshrc
Created November 10, 2020 08:21 — forked from ktrysmt/.zshrc
using zplug in zsh
if [[ ! -d ~/.zplug ]];then
git clone https://github.com/zplug/zplug ~/.zplug
fi
source ~/.zplug/init.zsh
zplug "plugins/git", from:oh-my-zsh
zplug "plugins/git", from:oh-my-zsh
zplug "plugins/sudo", from:oh-my-zsh
zplug "plugins/command-not-found", from:oh-my-zsh
zplug "zsh-users/zsh-syntax-highlighting"
zplug "zsh-users/zsh-history-substring-search"
@M4R14
M4R14 / get_child.js
Last active September 18, 2020 03:18
const data = [
{ id: 1, name: '1111', ref: 2 },
{ id: 2, name: '222', ref: 3 },
{ id: 3, name: '3333', ref: 0 }
];
const getOne = (_id) => data.find(item => item.id == _id)
const render = (it) => {
let text = [it.name]
@M4R14
M4R14 / .htaccess
Created April 17, 2020 03:09
.htaccess for deploy Laravel to Apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
</IfModule>
@M4R14
M4R14 / deploy_laravel.md
Last active April 7, 2020 10:32
Deploy Laravel on Vesta base on linux

Deploy Laravel to Vesta base on linux

โฟเดอร์ Path สำหรับ Laravel คือ /home/$user/web/$domain/public_html

ลบ public_html ออก ด้วยคำสั่ง

cd /home/$user/web/$domain/
rm -rf public_html

29-02-2020 vs 29-02-2563

mysql

อย่าใช่ DATE_ADD INTERVAL 543 YEAR

Bad

SELECT DATE_FORMAT(DATE_ADD('29-02-2020', INTERVAL 543 YEAR), "%d/%m/%Y");

Good

SELECT CONCAT(DATE_FORMAT('29-02-2020', "%d/%m/"),  DATE_FORMAT(selected_date, "%Y") + 543);

Exporting entire database:

$ mysqldump -u user -p database --opt | gzip > database.sql.gz

Export table

$ mysqldump -uroot --opt --databases DB_NAME --tables TABLE_NAME | gzip > /tmp/TABLE_NAME.export.sql.gz