This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Install node v10 | |
| FROM node:10 | |
| # Set the workdir /var/www/myapp | |
| WORKDIR /var/www/myapp | |
| # Copy the package.json to workdir | |
| COPY package.json ./ | |
| # Run npm install - install the npm dependencies |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3' | |
| services: | |
| myapp: | |
| container_name: myapp | |
| restart: always | |
| build: . | |
| ports: | |
| - '4300:4300' | |
| - '4301:4301' | |
| links: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * flat / merge all sub array into one array | |
| * @uses [['1', '2'], ['3', '4], '5', '6'].flat(); // ['1', '2', '3', '4', '5', '6'] | |
| */ | |
| Array.prototype.flat = function(){ | |
| return [].concat.apply([], this); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * size - Object size in javascript | |
| * @uses {a:1, b:2}.size() // 2 | |
| */ | |
| Object.prototype.size = function(obj) { | |
| var size = 0, key; | |
| for (key in obj) { | |
| if (obj.hasOwnProperty(key)) size++; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * unique - Array function for unique elements | |
| * @use [2, 2, 3, 4, 3, 2].unqiue() // [2, 3, 4] | |
| */ | |
| Array.prototype.unique = function() { | |
| var unique = []; | |
| for (var i = 0; i < this.length; i++) { | |
| if (unique.indexOf(this[i]) == -1) { | |
| unique.push(this[i]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * remove all spaces (" ") from string | |
| * @uses removeSpaces("sample string with s p a c e s") // samplestringwithspaces | |
| */ | |
| function removeSpaces(str){ | |
| return (str + "").replace(/ /g,''); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * isPalindrome - function to check if a number or string is palindrome | |
| * @uses isPalindrome(141) // true | |
| */ | |
| function isPalindrome(str){ | |
| return (str + "").split("").reverse().join("") == (str + ""); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * serializeObject - jQuery plugin to serialize form elements as an object | |
| * @uses $("#form").serializeObject(); // return {input:"value", input2:"value" .. } | |
| */ | |
| $.fn.serializeObject = function(){ | |
| var o = {}; | |
| var a = this.serializeArray(); | |
| $.each(a, function() { | |
| if (o[this.name] !== undefined) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * replaceAll - JavaScript string function | |
| * @uses replace all matching substring to its corresponding replace string | |
| * Worked similarly as str_replace in PHP | |
| */ | |
| String.prototype.replaceAll = function(find, replace) { | |
| var replaceString = this; | |
| var regex; | |
| for (var i = 0; i < find.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * $.swap - jQuery plugin to swap two elements | |
| * Swap the current element with other element | |
| * @uses $("#eample").swap($("#element")) | |
| */ | |
| $.fn.swap = function(to) { | |
| return this.each(function(){ | |
| var ct = $(to).clone(true); | |
| var cf = $(this).clone(true); |