Skip to content

Instantly share code, notes, and snippets.

View channprj's full-sized avatar

Park Hee Chan channprj

View GitHub Profile
@channprj
channprj / .direnvrc
Created November 5, 2024 02:18
direnv for Node.js
# Append in ~/.direnvrc below:
use_node() {
layout node
local node_version=$1
if [ "$node_version" == "package.json" ]; then
# Requires jq: `brew install jq`
if ! command -v jq &> /dev/null; then
echo -e "\033[0;31mjq is not installed. Please type 'brew install jq'.\033[0m"
@channprj
channprj / collate_query.py
Created October 28, 2024 10:16
DB Collate with Django ORM
# Use ko_KR.utf8 for lower version of Postgres
# ex: select * from sample_table order by "name" COLLATE "ko-KR-x-icu";
ko_name = Func("name", function="ko-KR-x-icu", template='(%(expressions)s) COLLATE "%(function)s"')
queryset = queryset.order_by(ko_name.asc())
@channprj
channprj / use-vscode-by-default.sh
Created October 14, 2024 07:01
Use VS Code by default code editor
brew install duti python-yq
curl "https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml" \
| yq -r "to_entries | (map(.value.extensions) | flatten) - [null] | unique | .[]" \
| xargs -L 1 -I "{}" duti -s com.microsoft.VSCode {} all
# Use duti to set defaults for specific files to VSCode
duti -s com.microsoft.VSCode public.plain-text all
duti -s com.microsoft.VSCode public.source-code all
duti -s com.microsoft.VSCode public.data all
@channprj
channprj / css-scroll-to-decrypt.markdown
Created September 12, 2024 23:14
CSS Scroll to Decrypt
@channprj
channprj / colorScheme.js
Created September 12, 2024 06:30
How to detect os color scheme in JS
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
@channprj
channprj / tailwind-safe-area.css
Created September 5, 2024 07:13
Implement iPhone safe area css for Tailwind
@layer utilities {
/* extra helper classes for iphone safe areas */
.safe-p {
padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.safe-px {
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
}
.safe-py {
@channprj
channprj / README.md
Created January 9, 2024 07:38 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@channprj
channprj / cheatsheet-elasticsearch.md
Last active August 25, 2023 07:45 — forked from ruanbekker/cheatsheet-elasticsearch.md
Elasticsearch Cheatsheet : Example API usage of using Elasticsearch with curl
@channprj
channprj / change-screenshot-path.sh
Last active October 9, 2024 04:31
Change default screenshot path to iCloud in macOS
defaults write com.apple.screencapture location $HOME/Library/Mobile\ Documents/com~apple~CloudDocs/Documents/Screenshots
@channprj
channprj / simulate.js
Created October 11, 2022 11:27 — forked from cs09g/simulate.js
Mouse/Touch Event Simulation
/**
* @desc It triggers mouse event.
* @param {HTMLElement} element target DOM element
* @param {string} type type of event
* @param {number} x clientX of event
* @param {number} y clientY of event
*/
export function simulateEvent(element, type, x, y) {
const mouseEvent = new MouseEvent(type, {
screenX: 0,