2019년 7월 31일 수요일

Chrome: How to prevent Chrome open pdf / Open pdf with your pdf viewer in Chrome downloads list

Chrome ver. 79.x.xxx

  • chrome:settings
  • Search 'pdf' in the box
  • Click 'Site Settings'
  • Click 'PDF documents' near the bottom
  • Enable 'Download PDF files instead of automatically opening them in Chrome'


No option of 'Click to open embedded PDFs' in the current version (79.0.3945.130)

Google Chrome

How to prevent Chrome open pdf / Opening pdf with your pdf viewer in Chrome downloads list

  1. Type 'about:flags' in the address bar
  2. Type 'pdf' in Search flags box
  3. Find 'Click to open embedded PDFs' (it's at the top with ver. 75.0.3770.142.)
  4. Change 'Default' menu to 'Disabled'
  5. Click 'Relaunch' button (caution: you might lose all open sites/tabs unless it's set up as 'Continue where you left off' in 'On startup' category of Settings.)

Hooray!


구글 크롬

크롬에서 pdf 파일 열리는 걸 방지하는 방법 / 크롬 다운로드 리스트에서 pdf 클릭해도 내 기본 pdf 뷰어에서 열리도록 하기

  1. 주소창에 'about:flags' 입력
  2. Flag 검색창에 'pdf' 입력
  3. 'Click to open embedded PDFs' 항목 찾기 (ver. 75.0.3770.142에서 맨 위로 검색됨)
  4. '기본값'을 '비활성'으로 바꿈
  5. '재실행' 버튼 눌러서 크롬 재시작 (경고: 열려있는 모든 탭/사이트를 잃을 수도 있음, 설정에서 '지난 번 탭 유지'가 되어 있지 않으면.)

어예!

2019년 7월 9일 화요일

Customizing Windows 7 for a Happier Life

For more PRODUCTIVE MS Windows

MS Windows 7 is a weak OS and I've never thought it's user-friendly because a user should touch many miscellaneous parts to make it usable or productive.

This article is about some tips including how to bring my apps or windows back onto the screen automatically after restart of Windows 7 for higher productivity.

Open 'My Computer', not Libraries when Windows Explorer clicked

  1. Right click on the icon of Taskbar
  2. Right click again on the small Windows Explorer icon
  3. Properties
  4. Type at the end of the Target textbox content, ' shell:MyComputerFolder', without the small quotation marks, including the space at the beginning.

 

Bring opened Windows Explorer windows back after restart

  1. Go to Folder Options (via Control Panel, for instance)
  2. View tab at top
  3. Scroll down in 'Advanced settings:' area
  4. Check 'Restore previous folder windows at logon
  5. Don't close any Windows Explorers when shutdown/restart

 

Bring your always-used apps back after restart

  1. Click Start button
  2. Type 'shell:startup'
  3. Drag & drop (making shortcuts) any program you want from Start Menu or from the application's folder (for example, C:\Program Files\Sublime Text 3)
  4. If possible, make the app's settings as it opens/recover all opened files/tabs (for example, set up your Chrome/Firefox to open all tabs back when it starts)

 

Typing Tips after Start button

  1. shell:appdata to open hidden Appdata folder
  2. shell:startup to open Startup Programs folder
  3. shell:programfiles to open C:/Program Files folder
  4. appwiz.cpl to open Programs and Features dialogue



2019년 7월 3일 수요일

Grunt (sass, jshint, concat, uglify, watch)

Gruntfile.js

module.exports = function( grunt ) {
var dir_theme = 'wp-content/themes/2017-child/',
dir_js =    'wp-content/themes/2017-child/assets/js/';

grunt.initConfig({
pkg: grunt.file.readJSON( 'package.json' ),
concat: {
// options: {
// separator: ';'
// },
dist: {
src: [dir_js + 'src/**/*.js',
'!' + dir_js + 'src/*-long.js',
'!' + dir_js + 'src/concatenated.js'],
dest: dir_js + 'src/concatenated.js'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */'
},
dist: {
src: // 'style.css': ['style.scss', '<%= concat.dist.dest %>'],
['<%= concat.dist.dest %>'],
dest: 
dir_js + '<%= pkg.name %>.js'
}
},
// qunit: {
// files: ['bl-page-content/**/*.html']
// },
jshint: {
files: [dir_js + 'src/**/*.js',
dir_js + 'global.js',
'!<%= concat.dist.dest %>'],
options: {
// verbose: true,
'-W004': true,
'-W030': true,
esversion: 6,
globals: {
jQuery: true,
console: true,
module: true,
// document: true
}
}
},
sass: {
options: {
sourceMap: true
},
dist: {
src: dir_theme + 'style.scss',
dest: dir_theme + 'style.css'
}
},
watch: {
sass: {
files: dir_theme + 'style.scss',
tasks: ['sass']
},
jshint: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
}
}
});

grunt.loadNpmTasks( 'grunt-contrib-uglify' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
// grunt.loadNpmTasks( 'grunt-contrib-qunit' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-contrib-concat' );
grunt.loadNpmTasks( 'grunt-contrib-sass' );

// grunt.registerTask( 'test', ['jshint', 'qunit']);
// grunt.registerTask( 'default', ['sass', 'jshint', 'qunit', 'concat', 'uglify']);
grunt.registerTask( 'js', ['jshint']);
grunt.registerTask( 'default', ['sass', 'jshint', 'concat', 'uglify']);
grunt.registerTask( 'cu', ['concat', 'uglify']);
};


2019년 4월 22일 월요일

Git and Github

$git init

$ssh-keygen

$ssh-add ~/.ssh/id_rsa

$git remote add origin SSH_URL_FROM_GITHUB



Set a ssh config file

$cat > ~/.ssh/config
Host github.com
  Hostname github.com
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_rsa

(CTRL+D)



Set a basic path

$cat >> ~/.bash_profile
alias la='ls -a'
alias ll='ls -l'
HOME=/d/webhome/

HOMEDRIVE=D:/
HOMEPATH=\webhome

cd
(CTRL+D)

Avoiding ssh passphrase prompt

$cat >> ~/.bash_profile
eval `ssh-agent -s`
ssh-add ~/.ssh/*_rsa
(CTRL+D)


 
Patterned upload

$git checkout -b BRANCH_NAME

(coding)

$git status

$git diff FILENAME

$git add FILENAME

$git commit- m "COMMIT MSG FOR THE FILE"

$git push

(testing)

$git checkout master

$git merge BRANCH_NAME

(if needed)

$git branch -d BRANCH_NAME_TO_DELETE



Check commit id
$git log

Create a temporary branch to check old code
$ git checkout -b <temp_branch_name> <commit_id>

Going back to the current/final version
$ git checkout master

Rename a branch
$ git checkout BRANCH
$ git branch -m NEW_NAME

Cancel 'add'
$ git reset FILENAME

Check difference of an added file
$ git diff --cache FILENAME

2018년 12월 19일 수요일

preg_replace /e to preg_replace_callback

$onAttributes = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavaible', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragdrop', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterupdate', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmoveout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload');
/*
 * Bridge Light code 2018-12-19
 * PHP7에서는 preg_replace() 첫번째 인수에서 /e가 폐기 되었으므로 대체 코드 투입: line 45~47 대신 line 48~56
 */
// $str = preg_replace('/<(.*?)>/ie',
// "'<' . preg_replace(array('/javascript:[^\"\']*/i', '/(" . implode('|', $onAttributes) . ")[ \\t\\n]*=/i', '/\s+/'), array('', '', ' '), stripslashes('\\1')) . '>'",
// $str);
$str = preg_replace_callback(
'/<(.*?)>/i',
function($matches) use ($onAttributes) {
return preg_replace(
array('/javascript:[^"\']*/i', '/('.implode('|', $onAttributes) . ')[ \\t\\n]*=/i', '/\s+/'),
array('', '', ' '),
stripslashes($matches[0]));
},
$str);


kimsq ver.1.2.2 (update 20140407)
file: _core/function/lib/getContent.lib.php

LIB_getContents() 함수에서 preg_replace()를 /e 지시자 때문에 preg_replace_callback으로 대체함.

preg_replace & preg_replace_callback, understood!


2018년 7월 23일 월요일

Wordpress tips

Child theme's Javascript file is loaded earlier than parent theme's.

For example, global-child.js is loaded right after jquery-min.js loaded and global.js of the parent theme is located at the bottom of <body> tag in the code.


In child theme, JQuery variables without $ should be declared and defined in the $(document).ready().

Weirdly some variables were found 'undefined' in the debugger, if they are defined before/out of $(document).ready()  just like twenty seventeen theme's global.js.


Firing a code after a jquery animation:

    code it in the callback function of animation().

Firing a code after a CSS transition, for instance, 'transition: 0.6s ease' which is triggered by something like addClass( 'fade-in' ) call:

    $("#selector").one("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(){ ... });

.one() means running the callback only once.

Source: https://stackoverflow.com/questions/9255279/callback-when-css3-transition-finishes


Loading a page/post-specific Javascript:
    function load_scripts() {
    global $post;
    if ( is_page() || is_single() ) {
        switch( $post->post_name ) {
            case 'home':
                wp_enqueue_script( 'home', get_template_directory_uri().'/js/home.js', array( 'jquery' ), '', false);
            case 'about-page':
                wp_enqueue_script( 'about', get_template_directory_uri().'/js/about-page.js', array( 'jquery' ), '', false);
        }
    }
    add_action( 'wp_enqueue_scripts', 'load_scripts' );

Source: https://wordpress.stackexchange.com/questions/67802/most-efficient-way-to-add-javascript-file-to-specific-post-and-or-pages



2018년 7월 8일 일요일

When Excel Prints Gray or Light-gray Colored Text in Black

(ver. MS-Office 2013)

File
Print
Page Setup (<- under the printing options)
Sheet tab
Option button (<- will lead you to Printing Preferences, but don't go there via Control Panel)
Print Quality tab
Advanced button
Print colored texts and borders in black to Disabled (<- this text is not exactly same to this, anyway disable it)

Ok, Ok, Apply, Ok, ... boom!

Xubuntu: Installing a Printer (Canon G3060 PIXMA)

$ sudo apt install system-config-printer Download the proper driver for linux from Canon website. Turn on the printer and set up its WiFi. C...