Skip to content

Instantly share code, notes, and snippets.

View ratiw's full-sized avatar

Rati Wannapanop ratiw

  • Nonthaburi, Thailand
View GitHub Profile
@ratiw
ratiw / Using Bower with Laravel 5.2 and Laravel Elixir.md
Last active February 10, 2018 16:53
Using Bower with Laravel 5.2 and Laravel Elixir
  • Install bower by following instruction at bower.io
  • Make bower knows where should it keeps downloaded/installed packages
    • Create .bowerrc at the root of project directory with the following content:
    {
      "directory": "vendor/bower_components"
    }

This will tell bower to use vendor/bower_components as its default directory

  • Put .bowerrc in .gitignore file
@ratiw
ratiw / VuetableCssBootstrap4FontAwesome.js
Last active November 14, 2018 08:15
Vuetable CSS for Bootstrap4
export default {
table: {
tableWrapper: '',
tableHeaderClass: 'mb-0',
tableBodyClass: 'mb-0',
tableClass: 'table table-bordered table-hover',
loadingClass: 'loading',
ascendingIcon: 'fa fa-chevron-up',
descendingIcon: 'fa fa-chevron-down',
ascendingClass: 'sorted-asc',
@ratiw
ratiw / Using phpMyAdmin with Homestead box.md
Created December 30, 2014 04:38
#Laravel #Homestead #phpmyadmin

Using phpMyAdmin with Homestead box

Once the Homestead vagrant box is installed successfully, we can add phpMyAdmin and config it to run with Nginx.

Install phpMyAdmin

  • SSH into Homestead vagrant box with vagrant ssh and type the following command:
    sudo apt-get install phpmyadmin
@ratiw
ratiw / object_get.js
Last active May 15, 2019 22:14
Retrieve object property using dot notation. Equivalent to Laravel's object_get()
function object_get(obj, key) {
if (!key || $.trim(key) == '') return obj;
$.each(key.split('.'), function(idx, seg) {
if (typeof obj !== 'object' || obj[seg] === undefined) {
obj = undefined;
return obj;
}
obj = obj[seg];
});
return obj;
@ratiw
ratiw / Set DB_CONNECTION to use sqlite in-memory database when testing.md
Last active January 1, 2020 05:24
Set DB_CONNECTION to use sqlite in-memory database when testing

#Set DB_CONNECTION to use sqlite in-memory database when testing

  • Open `phpunit.xml' file in the current project
  • Add the following environment variables to the appropriate section
  <env name="DB_CONNECTION" value="sqlite">
  <env name="DB_DATABASE" value=":memory:">
  • in config\database.php file, change the default sqlite connection to
  'connections' => [
@ratiw
ratiw / extract_vars.js
Last active January 22, 2020 17:56
JS function to extract variables from template string
function extract_vars(template, openChar, closeChar) {
openChar = openChar || '{';
closeChar = closeChar || '}';
var i = 0;
var data = [];
do {
if (template[i] == '{') {
for (var j=i+1; j<template.length; j++) {
@ratiw
ratiw / Laravel Homestead on Windows.md
Last active February 13, 2020 11:18
#Laravel #Homestead on #Windows

Problem with VirtualBox 4.3.12

It seems there is some problems between Vagrant 1.6.2 and VirtualBox 4.3.12 (the latest at the time or writing this), switching back to VirutalBox 4.3.6 or VirtualBox 4.3.8 seems to eliminate the problem.

update 1: Try both Vagrant 1.6.2 and VirtualBox 4.3.12 on Mac and they seem to work fine!

update 2: You need to enable Virtual Machine option in your BIOS to make VirtualBox work as expected. Saw someone mention about this in Laravel forum about this and it is true.

Also, Vagrant version should be 1.6.2.

@ratiw
ratiw / install-laravel-project.sh
Created October 10, 2020 03:20 — forked from cse031sust02/install-laravel-project.sh
Bash Script to install Laravel project from Git on LEMP stack
#!/bin/sh
########################################################
# Bash script to install HeavyGari Laravel App
# Written by Talha Ibne Imam
########################################################
HC='\033[0;32m' # Heading Color
WC='\033[0;33m' # Warning Color
NC='\033[0m' # No Color

Steps

  1. Setup Laravel app
  2. Setup vue.js inside laravel app

Setup Laravel app

  • New Laravel app
  • Rename .env.example to .env
  • Config config/database.php to MySQL or SQLite
  • For SQLite, run touch storage/database.sqlite to create sqlite database