# gulp.js - Concatenate File When Gulp Watch ## package.json { "name": "gulp", "version": "3.8.7", "devDependencies": { "gulp": "^3.9.0", "gulp-concat": "^2.6.0", "gulp-watch": "^4.3.4" } } ## gulpfile.js var gulp = require('gulp'), watch = require('gulp-watch'), concat = require('gulp-concat'); var js; gulp.task('concat', function (cb) { var options = {}; watch('dev/*.js', options, function (e) { // console.log('e:'+JSON.stringify(e)); // console.log('\n'); console.log(new Date() + ' -- ' + e.history[0].replace(e.base, '')); js = e.history[0].replace(e.base, ''); gulp.
...
# Apache - Apache Command Line on Mac / Ubuntu ## Mac sudo apachectl start sudo apachectl restart sudo apachectl status sudo apachectl stop ## Ubuntu sudo /etc/init.d/apache2 start sudo /etc/init.d/apache2 restart sudo /etc/init.d/apache2 status sudo /etc/init.d/apache2 stop sudo service apache2 start sudo service apache2 restart sudo service apache2 status sudo service apache2 stop Refer - Ubuntu Linux: Start / Restart / Stop Apache Web Server
...
# JavaScript - scrollTop ## scrollTop Element.scrollTop - Web API Interfaces | MDN
## Issue in firefox Normal
element.scrollTop = intValue; But when I use
document.body.scrollTop = 0; It doesn’t work in firefox.
Solution
document.documentElement.scrollTop = 0; // for firefox Refer - document.body.scrollTop vs document.documentElement.scrollTop
...
# Mac - hide desktop icon ## Hide defaults write com.apple.finder CreateDesktop -bool false Then
killall Finder ## Show defaults write com.apple.finder CreateDesktop -bool true Then
killall Finder Refer - Hide All Desktop Icons in Mac OS X
...
# CSS3 - object-fit We can use CSS3 property object-fit handle image show area and fit it.
But only IE no support.
Example
See the Pen img object-fit by Ted (@tedshd) on CodePen.
Refer - object-fit Refer - object-fit
...
# JavaScript - insertBefore & insertAfter ## insertBefore This is native JavaScript api
var insertedElement = parentElement.insertBefore(newElement, referenceElement);
var vDom = document.createElement('div'), dom = document.querySelector('#list'); dom.insertBefore(vDom, dom.childNodes[1]); // or var vDom = document.createElement('div'), dom = document.querySelector('#target'); dom.parentNode.insertBefore(vDom, dom); Refer - Node.insertBefore()
## insertAfter JavaScript doesn’t have any api handle insert DOM after reference DOM
We can use this way
function insertAfter(newNode, referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } Refer - How to do insert After() in JavaScript without using a library?
...
# Linux - Set Encoding In Linux Environment Add
export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8 in .bashrc or .zshrc
Refer - How to set up a clean UTF-8 environment in Linux
...
# JavaScript - Dynamic Load script || JSONP Callback ## Intro Sometimes we need dynamic load script or handle jsonp callback
And we need handle script onload or jsonp callback onload or something error
## How to do? Use onload, onerror method
## Code if (typeof UTIL == 'undefined' || !UTIL) { var UTIL = {}; } UTIL.createEl = { get: function(sTag, oAttr, handleOnLoad, handleError) { var el = document.
...
# Docker - Mac research log Install by Mac
## Register Docker Hub Docker Hub
## Use Kitematic kitematic
## Install Ubuntu Search ubuntu on docker hub
Run command
docker pull ubuntu ### Use docker images docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest 07f8e8c5e660 3 weeks ago 188.3 MB ### build dockerfile docker build . -t ubuntu_dev:16.04 -f local.Dockerfile ### run container docker run -t -i ubuntu /bin/bash
...
# Apache - dir permission cnfig If yooouo want use virtual host
Yoou can set /etc/apache2/extra/httpd-vhosts.conf this file
Add
<Directory /Users/ted/tedadev/local/bomb01> AllowOverride All Options Indexes MultiViews FollowSymLinks Require all granted </Directory> <VirtualHost *:80> DocumentRoot "/Users/ted/tedadev/local/bomb01" ServerName www.bomb01.com ErrorLog "/Volumes/RamDisk/ysm-error.log" CustomLog "/Volumes/RamDisk/ysm-access.log" common </VirtualHost> Refer - Forbidden 403, You don’t have permission to access /~username/ on this server
...