Skip to content

Instantly share code, notes, and snippets.

@rutcreate
rutcreate / UserBlockCommand.php
Last active August 6, 2021 13:03
Laravel User Console Commands
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
class UserBlockCommand extends Command
{
/**
@rutcreate
rutcreate / README.md
Created October 2, 2020 11:33
วิธีแก้ฟอนต์วรรณยุกต์ลอย

วิธีแก้ฟอนต์วรรณยุกต์ลอย

โปรแกรมที่ต้องใช้

ขั้นตอน

1. คัดลอกตัวอักษรที่ไม่มี

  • เปิดโปรแกรม Font Forge แล้วเลือกฟอนต์ที่ต้องการ
@rutcreate
rutcreate / client.dart
Last active July 20, 2020 07:51
Make HTTP Request with SSL Client Certificate (PCSK12)
import 'dart:convert';
import 'dart:io';
Future getToken() async {
var context = SecurityContext.defaultContext;
var filepath = './file.p12';
var password = '';
context.useCertificateChain(filepath, password: password);
context.usePrivateKey(filepath, password: password);
@rutcreate
rutcreate / .bash_profile
Created December 7, 2019 03:16
Create MySQL database, user, and grant permissions for local development
# $ create_mysql_database_and_user dbname [username [password]]
function create_mysql_database_and_user() {
DB=$1
USR=$1
if [[ $2 ]]; then
USR=$2
fi
PWD=$USR
if [[ $3 ]]; then
PWD=$3
@rutcreate
rutcreate / js-coding-style.md
Created February 22, 2019 08:57
JavaScript and VueJS Coding Style

JavaScript Coding Style

Naming Convention

  • Use camelCase for variable name.
// Bad
const number_of_people = 20
const NumberOfPeople = 20
const person = {
@rutcreate
rutcreate / default.conf
Last active July 31, 2018 10:33
Docker WordPress with NGINX
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
@rutcreate
rutcreate / .htaccess
Created July 23, 2018 07:29
Splash page using .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^\/(.*)-(anteroexternal)([0-9]+)\/slum([0-9]+)\/(.*)$ ?anteroexternal$3=$4&%{QUERY_STRING}[L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{REQUEST_URI} ^/$ [NC]
@rutcreate
rutcreate / archive.php
Last active July 6, 2018 07:57
WordPress cheat sheet
<?php
/**
* Check page is category.
*/
if ( is_category() && $term = get_queried_object() ) {
print_r($term);
}
@rutcreate
rutcreate / docker-container
Created May 18, 2018 09:07
Logrotate for Docker containers
/var/lib/docker/containers/*/*.log {
rotate 7
daily
compress
size=1M
missingok
delaycompress
copytruncate
}
@rutcreate
rutcreate / Dockerfile
Last active July 24, 2018 09:14
Docker Laravel
FROM php:7.1-apache
# Update apache document root.
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!/var/www/html/public!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Enable mod write.
RUN a2enmod rewrite