Skip to content

Instantly share code, notes, and snippets.

View leegeunhyeok's full-sized avatar
🎯
Focusing

Geunhyeok LEE leegeunhyeok

🎯
Focusing
View GitHub Profile
console.log('Hello, world!')
@leegeunhyeok
leegeunhyeok / index.html
Last active August 30, 2018 04:16
Google Material Button
<button id="btn-1" class="blue-default">
Google
<div class="ripple-area"></div>
</button>
<button id="btn-2" class="blue-text">
Google
<div class="ripple-area"></div>
</button>
@leegeunhyeok
leegeunhyeok / save_console_log.js
Created August 31, 2018 08:15
[ Node.js ] Print log with save
const fs = require('fs')
// Log file name, EOL (Different by platform)
console['config'] = { file: 'log.txt', eol: require('os').EOL }
console['_log'] = console.log // Original console.log function to console._log
console.log = function () { // substitution
let args = (arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)).join(' ')
fs.appendFileSync(console.config['file'], args + console.config['eol']) // save
console._log(args) // print
}
@leegeunhyeok
leegeunhyeok / .tmux.conf
Last active April 15, 2019 09:00
tmux with vim
# Reference: https://gist.github.com/tsl0922/d79fc1f8097dde660b34
# If text color issue in tmux terminal, type this commend
# alias tmux="TERM=screen-256color-bce tmux"
set-option -g prefix C-a
unbind-key C-a
bind-key C-a send-prefix
set -g base-index 1
@leegeunhyeok
leegeunhyeok / zsh-update.sh
Created June 10, 2019 09:26
oh-my-zsh update script
#!/bin/bash
# [Oh My Zsh] Would you like to check for updates?
# Type Y to update oh-my-zsh: Y
# Upgrading Oh My Zsh
# Cannot pull with rebase: You have unstaged changes.
# Please commit or stash them.
# There was an error updating. Try again later?
#
# [Set permission]
@leegeunhyeok
leegeunhyeok / optional-chaining.js
Last active August 7, 2019 03:42
[JavaScript] Optional Chaining
/*
* TC39 Proposal : https://github.com/tc39/proposal-optional-chaining
*/
Object.prototype.optionalChain = function (...ops) {
let curr = this
for (let op of ops) {
if (curr[op] == null) {
return
}
@leegeunhyeok
leegeunhyeok / 01_spread_syntax_trick.js
Last active January 15, 2020 09:06
01_spread_syntax_trick
/*
* Spread syntax trick 1
* Rest parameter
*/
const sum = (acc, ...nums) => {
for (let num of nums) {
acc += num
}
return acc
@leegeunhyeok
leegeunhyeok / 02_spread_syntax_trick.js
Last active January 15, 2020 09:07
02_spread_syntax_trick
/*
* Spread syntax trick 2
* Immutable data pattern
*/
const a = {
name: 'Tom',
age: 10
}
@leegeunhyeok
leegeunhyeok / 03_spread_syntax_trick.js
Last active November 2, 2020 10:07
03_spread_syntax_trick
/*
* Spread syntax trick 3
* Optional spreading
*/
const available = true
const obj = {
user: 'James',
age: 16,
@leegeunhyeok
leegeunhyeok / app.js
Created August 11, 2019 05:53
PWA Push - subscribe
// 알림 구독
function subscribe () {
const applicationServerKey = urlB64ToUint8Array(appServerPublicKey);
swRegist.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: applicationServerKey
})
.then(subscription => {
console.log('User is subscribed.');
updateSubscription(subscription);