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 Oct 10, 2020 — 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 Nov 14, 2018
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 Mar 14, 2017
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 Feb 10, 2018
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 Apr 13, 2016
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 Jan 1, 2020
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 Jan 22, 2020
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 Apr 11, 2015
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 Feb 2, 2018
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('-','');});