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 / 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;
}
@juji
juji / sshperm
Created September 20, 2023 21:11
ssh permission
cd ~ && chmod 600 ~/.ssh/* && chmod 700 ~/.ssh && chmod 644 ~/.ssh/*.pub
@juji
juji / hex2rgba.js
Last active March 9, 2021 04:10
hex to rgba
(str, alpha) => {
if(!/^#([A-Fa-f0-9]{3}){1,2}$/.test(str))
throw new Error('Bad hex')
let c = str.substring(1).split('')
if(c.length === 3) c = [c[0], c[0], c[1], c[1], c[2], c[2]];
c = '0x'+c.join('');
@juji
juji / deploy.sh
Created December 14, 2017 12:40
git deploy script
#!/bin/bash
if [[ "$1" == "" ]]; then
echo 'usage: deploy <origin> <branch>'
exit
fi
if [[ "$2" == "" ]]; then
echo 'usage: deploy <origin> <branch>'
exit