Skip to content

Instantly share code, notes, and snippets.

View laziel's full-sized avatar
🐳

JiHan Kim laziel

🐳
View GitHub Profile
@profiprog
profiprog / simple-compressing.md
Last active January 4, 2024 11:34
Simple compressing base64 string in JavaScript

Story

In needed include base64 encoded simple image into HTML page in two formats:

1st as PNG format has length 196 characters and looks like this:

iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAWElEQVR42mNkwA/qgbgRnwJGAgb8BwI7RkbGw5QYUAs0oGXUAPwGgKKqgYF0ANLTyAi1xhZI2WOYzsjYDJTbC2QewGHIwcERBsPcgHqgAX8pMQAcxfhyIwATTkxL+hgX2QAAAABJRU5ErkJggg==

2nd as CUR format has length 1536 characters and looks like this:

`AAACAAEAEBAAAAcABwBoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///z0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH////98AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////3wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////98AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

@haircut
haircut / tcc-reset.py
Last active April 5, 2024 11:27
Completely reset TCC services database in macOS
#!/usr/bin/python
"""
Completely reset TCC services database in macOS
Note: Both the system and individual users have TCC databases; run the script as both
a user and as root to completely reset TCC decisions at all levels.
2018-08-15: Resetting the 'Location' service fails; unknown cause
2018-08-16: Confirmed the 'All' service does not really reset _all_
services, so individual calls to each service is necessary.
@szxp
szxp / release.sh
Last active April 11, 2023 07:06
Automatically bump Git tag versions and create a new tag
#!/bin/sh
# BSD 3-Clause License
#
# Copyright (c) 2017, Péter Szakszon
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
@javisperez
javisperez / interceptors.js
Last active December 4, 2022 16:47
Axios interceptor for cache with js-cache
// Usually I use this in my app's config file, in case I need to disable all cache from the app
// Cache is from `js-cache`, something like `import Cache from 'js-cache';`
const cacheable = true,
cache = new Cache();
// On request, return the cached version, if any
axios.interceptors.request.use(request => {
// Only cache GET requests
if (request.method === 'get' && cacheable) {
@domfarolino
domfarolino / EventFlow.md
Last active February 26, 2022 19:14
JavaScript Event Flow - A better understanding

This gist is deprecated and now exists here

This article is intended to further your knowledge of the various phases a DOM event goes through.

Great resources to refer to:

TL;DR

@nezed
nezed / EXIF image orientation CSS transform fix.js
Created August 21, 2016 23:54
EXIF image orientation CSS transform fix / fix orientation of image picked from local FS without canvas
/*
* This gist will help you to fix orientation
* of image picked from local FS
* without canvas.
* CSS-only!
*
* @expample
* const img = document.createElement('img')
* img.src = URL.createObjectURL(file)
* img.style.transform = ORIENT_TRANSFORMS[ getOrientation(file) ]
@paulirish
paulirish / what-forces-layout.md
Last active April 16, 2024 17:32
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@marocchino
marocchino / 094607.md
Last active July 19, 2022 14:25
ES6시대의 JavaScript

ES6시대의 JavaScript

안녕하세요. 사원사업부의 마루야마@h13i32maru입니다. 최근의 Web 프론트엔드의 변화는 매우 격렬해서, 조금 눈을 땐 사이에 점점 새로운 것이 나오고 있더라구요. 그런 격렬한 변화중 하나가 ES6이라는 차세대 JavaScript의 사양입니다. 이 ES6는 현재 재정중으로 집필시점에서는 Draft Rev31이 공개되어있습니다.

JavaScript는 ECMAScript(ECMA262)라는 사양을 기반으로 구현되어있습니다. 현재 모던한 Web 브라우저는 ECMAScript 5.1th Edition을 기반으로 한 JavaScript실행 엔진을 탑재하고 있습니다. 그리고 다음 버전인 ECMAScript 6th Edition이 현재 재정중으로, 약칭으로 ES6이라는 명칭이 사용되고 있습니다.

@zerobase
zerobase / japanese_ime.html
Created December 10, 2013 01:41
"compositionstart" and "compositionend" events, and Japanese Input Method
<!DOCTYPE html>
<html>
<head>
<title>"compositionstart" and "compositionend" events, and Japanese Input Method</title>
</head>
<body>
<textarea name="textarea" id="textarea" cols="30" rows="3"></textarea>
<h2>onkeydown</h2>
<p>nowCompositioning: <span id="nowCompositioning"></span></p>
<p>keyCode: <span id="keyCode"></span></p>
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active April 2, 2024 15:59
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1