Skip to content

Instantly share code, notes, and snippets.

View juji's full-sized avatar
💭
feeling awesome

Tri Rahmat Gunadi juji

💭
feeling awesome
View GitHub Profile
@juji
juji / clean-clipboard-text.ts
Last active July 25, 2024 03:28
clean clipboard text
export function cleanClipboardText(e: ClipboardEvent){
const pastedText = e.clipboardData?.getData('text/plain');
return pastedText ? stripBom(pastedText) : ''
}
export function onPaste(e: ClipboardEvent){
e.preventDefault()
const sel = window.getSelection()
if(!sel) return;
if (!sel.rangeCount) return;
@juji
juji / download.zsh
Last active July 10, 2024 13:16
Wget Download File
#!/bin/zsh
startTime=$(date)
url="$1"
if [ "$url" = "" ]; then
echo "url can't be empty"
echo "usage: download url"
exit 1
fi
@juji
juji / download.zsh
Created July 10, 2024 13:03
Wget Download File
#!/bin/zsh
url="$1"
if [ "$url" -eq "" ]; then
echo "url can't be empty"
echo "usage: download url"
exit 1
fi
@juji
juji / reset-button-style.css
Created May 12, 2024 16:28 — forked from tavareshenrique/reset-button-style.css
Reset CSS button style
button {
background: none;
color: inherit;
border: none;
padding: 0;
font: inherit;
cursor: pointer;
outline: inherit;
}
@juji
juji / contentful-style.css
Last active May 4, 2024 14:37
Contentful Fullscreen Editor & Selection Color
/*
Dark mode by UltimaDark, on firefox
https://addons.mozilla.org/en-US/firefox/addon/ultimadark/
*/
/* selection color */
@juji
juji / gfm.md
Last active May 2, 2024 18:19
GFM Example, I forgot where i got this

Headers

# h1 Heading 8-)
## h2 Heading
### h3 Heading
#### h4 Heading
##### h5 Heading
###### h6 Heading
@juji
juji / detect-dark-mode.js
Created April 27, 2024 18:03
Detect dark mode
((w,d) => {
w && d &&
w.matchMedia('(prefers-color-scheme:dark)')?.matches &&
d.getElementsByTagName('html')[0]?.classList.add('dark')
})(window,document)
@juji
juji / fpsMeter.js
Created December 12, 2023 21:09 — forked from capfsb/fpsMeter.js
JavaScript FPS meter - Calculating frames per second
fpsMeter() {
let prevTime = Date.now(),
frames = 0;
requestAnimationFrame(function loop() {
const time = Date.now();
frames++;
if (time > prevTime + 1000) {
let fps = Math.round( ( frames * 1000 ) / ( time - prevTime ) );
prevTime = time;
@juji
juji / image-resize.js
Last active November 24, 2023 14:45
Resize images using sharp, convert them to webp
const fs = require('fs/promises')
const sharp = require('sharp')
// this will create 2 images
// one with 1200 width and one with 600 width
// it will place them in the current directory
// note that the original image(s) will be expected to be png
@juji
juji / easeOutElastic.js
Last active November 24, 2023 14:41
create easeOutElastic tween in css keyframes
function easeOutElastic(x) {
const c4 = (2 * Math.PI) / 3;
return x === 0
? 0
: x === 1
? 1
: Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1;
}