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 / 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 / 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 / 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 / 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)

/*!
* jQuery lightweight plugin boilerplate
* Original author: @ajpiano
* Further changes, comments: @addyosmani
* Licensed under the MIT license
*/
// the semi-colon before the function invocation is a safety
// net against concatenated scripts and/or other plugins
// that are not closed properly.
@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

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 / Use static function to call internal function.md
Last active April 13, 2016 15:32
Use static function to call internal function

Instead of doing this

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

This feels better

  PurchasePodcast::perform();
@ratiw
ratiw / MyVuetable.vue
Created March 14, 2017 07:02
MyVuetable -- using `__slot`
<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 / javascript-util-functions.js
Last active February 2, 2018 01:07
Javascript Utility Functions
// 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('-','');});