Skip to content

Instantly share code, notes, and snippets.

Avatar

Rati Wannapanop ratiw

  • Nonthaburi, Thailand
View GitHub Profile
@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
View install-laravel-project.sh
#!/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
@ratiw
ratiw / VuetableCssBootstrap4FontAwesome.js
Last active November 14, 2018 08:15
Vuetable CSS for Bootstrap4
View VuetableCssBootstrap4FontAwesome.js
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 / MyVuetable.vue
Created March 14, 2017 07:02
MyVuetable -- using `__slot`
View MyVuetable.vue
<template>
<div class="ui container">
<div class="vuetable-pagination ui basic segment grid">
<vuetable-pagination-info ref="paginationInfoTop"
></vuetable-pagination-info>
<vuetable-pagination ref="paginationTop"
@vuetable-pagination:change-page="onChangePage"
></vuetable-pagination>
</div>
<vuetable ref="vuetable"
@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
View Using Bower with Laravel 5.2 and Laravel Elixir.md
  • 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 / Use static function to call internal function.md
Last active April 13, 2016 15:32
Use static function to call internal function
View Use static function to call internal function.md

Instead of doing this

  $p = new PurchasePodcast;
  $p->handle();

This feels better

  PurchasePodcast::perform();
@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
View Set DB_CONNECTION to use sqlite in-memory database when testing.md

#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
View extract_vars.js
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++) {
View Setting up Laravel & Vuejs.md

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
@ratiw
ratiw / Using Laravel Elixir on Windows 7_8_8.1.md
Created April 11, 2015 08:10
Using Laravel Elixir on Windows 7/8/8.1
View Using Laravel Elixir on Windows 7_8_8.1.md

Setup

  • Windows 7/8/8.1
  • Git (git-scm with Git Bash)
  • Fresh install of Laravel 5.0

** Do not install Elixir from within Homestead. It will not work! **

Steps

  • Run Git Bash
  • cd to the project directory
@ratiw
ratiw / javascript-util-functions.js
Last active February 2, 2018 01:07
Javascript Utility Functions
View javascript-util-functions.js
// http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
// Trim
String.prototype.trim = function(){
return this.replace(/^\s+|\s+$/g, "");
};
// Camel Case
String.prototype.toCamel = function(){
return this.replace(/(\-[a-z])/g, function($1){return $1.toUpperCase().replace('-','');});