Sing's Log

Knowledge worth sharing


  • Home

  • Tags

  • Timeline

  • Portfolio

  • Search

Show "Search" button on mobile keyboard

Posted on 2019-09-18 | Edited on 2023-01-16 |

For Android

Only type="search" is required on <input>

For IOS

It is required to wrap <input type="search"> inside a <form action>, note that the attribute action is must-have.

For all mobile devices

To sum up, the minimum requirement on mobile is:

1
2
3
4
5
<form action>
<input
type="search"
>
</form>

To try on mobile device, here is a live example on JSFiddle :

[Drone CI] migrate pipeline config from 0.x to 1.x

Posted on 2019-09-11 | Edited on 2023-01-16 |

New syntax for pipeline and step

1
2
3
4
5
6
7
- pipeline:
- custom-step:
- image: some-image
+ kind: pipeline
+ steps:
+ name: custom-step
+ image: some-image

Custom plugin variables should be placed under settings

1
2
3
4
5
6
7
8
9
10
kind: pipeline
name: default
steps:
name: custom-plugin
image: some-image
- foo:
- bar: baz
+ settings:
+ foo:
+ bar: baz

GIT submodule note

Posted on 2019-08-20 | Edited on 2023-01-16 |

Clone repository with submodule

1
git clone --recursive <repo_url>

Clone submodules after repository cloned

1
2
git submodule init
git submodule update --recursive

Add submodule

1
git submodule add <submodule_clone_url> <submodule_folder>

Remove submodule

Step1 - Remove submodule folder

1
2
git rm --cached /path/to/submodule
rm -rf /path/to/submodule

Step2 - Remove submodule config in .gitmodules

1
2
3
4
5
6
-[submodule "themes/next"]
- path = themes/next
- url = https://github.com/Asing1001/hexo-theme-next.git
[submodule "themes/next-reloaded"]
path = themes/next-reloaded
url = https://github.com/Asing1001/hexo-next.git

Update submodule to latest commit

Step1 - Checkout the target version of the submodule

1
2
3
4
# Go to the submodule folder
cd projB/projA
# Checkout the target commit
git pull origin master

Step2 - Commit the update

1
2
3
4
# Back to the parent folder
cd ..
git add projB/projA
git commit -m "submodule projA updated"

Reference

  • https://stackoverflow.com/questions/8191299/update-a-submodule-to-the-latest-commit

[VSCode] settings and shortcuts

Posted on 2019-06-18 | Edited on 2023-01-16 |
  • command 0 - Focus on sidebar
  • cmd+d - For don’t save
  • gb - For multi cursor in vim mode
  • cmd+shift+. - show breadcumb

Settings.json

1
2
3
4
{
"editor.autoIndent": true,
"editor.snippetSuggestions": "top",
}

References

  • http://vimdoc.sourceforge.net/htmldoc/motion.html

[GTM] Get the item order in a list

Posted on 2019-02-21 | Edited on 2023-01-16 |

Google Tag Manager(GTM) is a back office for quickly managing HTML on webpages, basically, it enables the maintainer to do Everything on their website without changing the code base. There are three major elements in GTM which are Tag, Variable, and Trigger.

Tag

A Tag will be triggered by the Trigger you set and passing both the system defined variables and the user-defined variables to your Tag, then you could take the action such as sending it to GA or manipulate DOM on your pages.

Variable

Other than System defined variables, you could create your own by Javascript:
Select User-Defined Variables, then select the type Custom Javascript

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function() {
try {
var element = {{Click Element}}
var elementClass = {{Element class}}
if (!element || !elementClass) return
var selector = '.' + elementClass.split(' ').join('.')
var list = document.querySelectorAll(selector)
var order = [].indexOf.call(list, element) + 1
return order
} catch (e) {
if (window.dataLayer.filter(function (obj) {
return obj.errorMsg === e.message;
}).length == 0) {
window.dataLayer.push({
'event': 'variable error',
'errorMsg': e.message
});
}
}
}

Trigger

Connect to GCP MySQL through XAMPP

Posted on 2018-11-18 | Edited on 2023-01-16 |

Background

XAMPP is the most popular PHP development environment including a great GUI - phpMyAdmin, I would like to connect it to a cloud MySQL DB - Google Cloud Platform MySQL.

Requirement

  1. XAMPP installed
  2. Create a Google Cloud Platform (GCP) account
Read more »

New to Macbook guide for developer

Posted on 2018-09-19 | Edited on 2023-01-16 |

Recently I start to use Macbook Pro for software development. It is really painful that so many shortcut and software are different from Windows. I hope log it down could help some MAC new comers :)

Recommended install list

  • homebrew
    • You could almost install everything through brew install <program name> or brew install --cask <program with GUI>
  • iterm2
    • Better terminal in MAC
  • Oh-My-Zsh
    • Change default shell to zsh with chsh -s $(which zsh)
  • vscode
  • Karabiner-Elements
    • brew install --cask Karabiner-Elements
    • Keyboard mapper, if you use your own keyboard you should install it!
  • nvm
    • Handle Nodejs environment
  • 超注音
    • Enable the ability to switch language by shift
  • spectacle
    • Shortcut for docking windows
  • awesome-vim-configuration
  • manico
    • Best tool for launching app with custom shortcut
  • Scroll Reverser
    • brew install --cask scroll-reverser
    • Seperate mouse / touchpad scroll direction setting
  • diff-so-fancy
    • Make your git diff so fancy
    • brew install diff-so-fancy
    • git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"

Shortcut

  • Mac shortcuts
  • Spotify
  • Chrome
  • Zsh Git Alias
  • Print screen area: command + control + shift + 4 (control is optional for copy to clipboard)
  • Open link in new tab: command + click
  • Delete file: command + backspace
  • Lock screen: ctrl + command + q
  • Close window: command + w
  • Quit app: command + q
  • Fullscreen/Normalscreen: ctrl + command + f
  • Hide window: command + m
  • Show window: Hold command + tab to the app, then hold option then release command
  • Open application preference: command + ,
  • Switch different window in same application: command + `
  • Show desktop (fn) + F11

Settings

  • Finder
    View > Show Status Bar, Show Path Bar
  • Iterm
    Menu bar > iterm2 > Make iIerm2 default term
  • VSCode

    • To use zsh, edit user settings:

      1
      2
      "terminal.integrated.shell.osx": "zsh",
      "terminal.integrated.fontFamily": "Menlo for Powerline"
    • Use terminal to open vscode:
      Command + Shift + P then Shell Command : Install code in PATH, then you can type code <folder path> to open vscode

  • zsh
    • osx
    • zsh-completions
  • Disable firefox and other apps notification sound
    • System Preferences > Notifications Choose Firefox and uncheck Play sound for notifications to get rid of the sound.

Things you need to know

  • If you command + tab switch window and nothings come up, it is because there is no window for this application, to quit application just simply command + q, or you could open window for this application by top menu bar
  • Spotlight is search engine inside your Mac
  • Finder is File Manager
  • Preview has functionality of painter

Read more

  • Mac輸入法教學

Apprentice pattern 學徒模式重點筆記

Posted on 2018-09-18 | Edited on 2023-01-16 |

學徒模式一書的架構是以一篇篇的主題連接起完整的學徒Roadmap,每篇中以情境 問題 解決方案 行動來引領學徒如我邁向軟體工藝之路,本次再讀此書深覺應身體力行,決定把一些書中提及的的行動實行於部落格內

正視你的無知

明天我將顯得更加愚昧,並習慣他。

大意

本篇訴說儘管已經熟悉某些技能並讓他人倚重,但總是會遇到自身所缺的知識,此時勇於放下自尊顯露無知,說不知道,問身邊的專家為什麼才是最快的學習途徑,特別是當你問問題的對象認為你知道問題的答案!

行動 - 列出五件工作中你不理解的事放在大家看的到的地方並持續更新這份清單

  1. WebAssembly
  2. Web Worker
  3. How Vue core works?
  4. How to write a Compiler?
  5. How to build a LIFF Application?

Git commands and tricks you must know

Posted on 2018-09-08 | Edited on 2023-01-16 |

Recommend plugins

  • Make your diff so fancy - diff-so-fancy
  • ZSH Git alias

Commands

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Remove untracked files
git clean -fd

# Delete local branch
git -D <branch_name>

# Delete remote branch, there are two options
git push <remote_name> :<branch_name>
git push <remote_name> --delete <branch_name>

# Remove tracking branches no longer on remote
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done

# Roll back only one folder to one commit
git checkout <hash_of_commit> <folder_name>

# Discard every change
git reset --hard

# Undo most recent commit
git reset HEAD~

# Rebase pull
git pull --rebase

# Push to target remote, -u is short for --set-upstream
git push -u <remote-name> <branch>

# Check commit's message and change(-p)
git log -p -2

# Update to latest submodules
git submodule update --recursive --remote

# Rebase
git rebase <commit SHA or branch>

# Rebase in interactive mode
git rebase -i <commit SHA or branch>

# Rebase interactive mode commands
git rebase --skip # you will need this if no change in some steps
git rebase --continue # After resolving conflict and git add <conflict file>

$ git rebase -i HEAD~3 # You need to edit "pick" part to tell git to do commands on the commit
pick 8b9100d commit message 1
pick f175572 commit message 2
pick 9bac799 commit message 3

# Rebase 9a4f60e..9bac799 onto 9a4f60e (3 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# . create a merge commit using the original merge commit's
# . message (or the oneline, if no original merge commit was
# . specified). Use -c <commit> to reword the commit message.

Check a JPEG is progressive or baseline

Posted on 2018-09-04 | Edited on 2023-01-16 |

Determine progressive JPEG by it’s content

From wiki-JPEG, we could see a baseline/progressive JPEG have byte marker mapping differently as following:

Short name Bytes Payload Name
SOF0 0xFF, 0xC0 variable size Start Of Frame (baseline DCT)
SOF2 0xFF, 0xC2 variable size Start Of Frame (progressive DCT)

So to tell the image is progressive JPEG, we need to check if it contains 0xFF, 0xC0 which is c2ff in Two-byte hexadecimal display.

Read more »
123…8
Sing Ming Chen

Sing Ming Chen

Sing's log, a developer's blog

77 posts
193 tags
GitHub E-Mail Linkedin Facebook StackOverflow
© 2023 Sing Ming Chen
Powered by Hexo v3.9.0
|
Theme — NexT.Gemini v6.3.0