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 / 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 / makeAttributes.js
Last active August 29, 2015 14:05
Combine associative array into html attributes or query string
function makeAttributes(arr, connector, separator) {
var out = '';
if (!connector) connector = '=';
if (!separator) separator = ' ';
for (var k in arr) {
out += (out === '') ? '' : separator;
out += k + connector + arr[k];
}
@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 / str_replace.js
Last active August 29, 2015 14:05
javascript str_replace
function str_replace(search, replace, subject) {
var result = subject;
for (var i = 0; i < search.length; i++) {
result = result.replace(search[i], replace[i]);
}
return result;
}
@ratiw
ratiw / RunningNumberGenerator.php
Last active April 25, 2022 10:53
Make new running number (e.g. doc no., invoice no.) based on the given pattern and the last number.
<?php
namespace App\Services;
class InvalidPatternException extends \Exception
{
}
/**
* Pattern is enclosed in the open and close delimiter
@ratiw
ratiw / Bahttext.php
Last active July 19, 2021 09:31
convert number to thai baht text
<?php
/**
* Convert number amount to Thai text as in Excel
*
* author: Rati Wannapanop
* email: rati.wannapanop@gmail.com
* since: 2014-09-06
*/
@ratiw
ratiw / update-homestead.md
Last active August 29, 2015 14:07
Updating and Separating the Homestead folder and Project folder

My homestead VM used to be in D:\www\Homestead and all projects lived inside its folder. I want to update homestead to the updated version and separate my projects to a new folder (e.g. D:\www\projects), so that I do not acidentally delete them when I need to delete Homestead folder.

  1. Update Homestead box. From command prompt, run

    vagrant box update
    
  2. Create a new folder for Projects. (D:\www\projects)

@ratiw
ratiw / install-l5-dev.md
Last active August 29, 2015 14:07
Fresh Install of L5-dev
  1. Create new project
composer create-project laravel/laravel l5-view dev-develop

l5-view is the project folder name.

  1. Add new project site to nginx
serve l5-view.app /home/vagrant/Code/l5-view/public
@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 / save-facebook-lookback-video.md
Last active August 29, 2015 14:12
How to save your Facebook Lookback video

##How to save your Facebook Lookback video #####ratiw (Jan. 1, 2015)

  • You need to use Google Chrome Browser
  • Open a new tab in Chrome and type the following in the address bar

chrome://cache

  • Open another tab and go to your www.facebook.com/lookback

  • Select HD quality by clicking at the HD icon on the lower-right of the video and let the video play for a few seconds, then switch back to previous tab (the chrome://cache)