This file contains 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
const account = { | |
email, | |
password, | |
...(nickname && {nickname}), | |
} | |
// https://medium.freecodecamp.org/how-to-conditionally-build-an-object-in-javascript-with-es6-e2c49022c448 |
This file contains 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
const list = new Array(100) | |
function set (i, item) { | |
list[i % list.length] = item | |
} | |
// and something on performance: https://www.nearform.com/blog/wormholes-in-javascript/ |
This file contains 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
/* https://thread.engineering/searching-and-sorting-text-with-diacritical-marks-in-javascript-45afef20e7f2 */ | |
const animal = 'žluťoučký kůň'.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); | |
/* sorting with locale */ | |
arr.sort((a, b) => a.localeCompare(b)); |
This file contains 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
function whiteOrBlack(color) { | |
const colorArr = color.length === 4 ? color.match(/[\da-fA-F]{1}/g) : color.match(/[\da-fA-F]{2}/g); | |
return colorArr | |
.map(s => s.length > 1 ? parseInt(s, 16) : parseInt(s, 16) * 16) | |
.reduce((a, c) => a + c) > 381 ? '#000' : '#FFF'; | |
} |
This file contains 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
touch ~/.android/repositories.cfg | |
brew cask install caskroom/versions/java8 | |
brew cask install android-sdk | |
brew cask install intel-haxm | |
brew install qt | |
export ANDROID_SDK_ROOT="/usr/local/share/android-sdk" | |
sdkmanager "platform-tools" "platforms;android-27" "extras;intel;Hardware_Accelerated_Execution_Manager" "build-tools;27.0.0" "system-images;android-27;google_apis;x86" "emulator" | |
avdmanager create avd -n test -k "system-images;android-27;google_apis;x86" --tag google_apis | |
/usr/local/share/android-sdk/tools/emulator -avd test |
This file contains 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
document.documentElement.webkitRequestFullScreen(); |
This file contains 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
git log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | |
-p (with commit changes) | |
--graph (displayed as graph) | |
via Filipe Kiss |
This file contains 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
const angle = (x, y) => { | |
let result = Math.atan(y / x); | |
if (x < 0) { | |
result += Math.PI; | |
} else if (y < 0) { | |
result += 2 * Math.PI; | |
} | |
return result; | |
}; |
This file contains 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
~"calc(100% - @{variable})"; | |
// or | |
calc(100% ~"-" @variable); |
This file contains 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
### Terminal Syntax Highlighting | |
# Setup: "brew install highlight" | |
# Pipe Highlight to less | |
export LESSOPEN="| $(which highlight) %s --out-format xterm256 --line-numbers --quiet --force --style solarized-light" | |
export LESS=" -R" | |
alias less='less -m -N -g -i -J --line-numbers --underline-special' | |
alias more='less' |
NewerOlder