add blog posts
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="115" height="48"><path fill="#17191E" d="M7.77 36.35C6.4 35.11 6 32.51 6.57 30.62c.99 1.2 2.35 1.57 3.75 1.78 2.18.33 4.31.2 6.33-.78.23-.12.44-.27.7-.42.18.55.23 1.1.17 1.67a4.56 4.56 0 0 1-1.94 3.23c-.43.32-.9.61-1.34.91-1.38.94-1.76 2.03-1.24 3.62l.05.17a3.63 3.63 0 0 1-1.6-1.38 3.87 3.87 0 0 1-.63-2.1c0-.37 0-.74-.05-1.1-.13-.9-.55-1.3-1.33-1.32a1.56 1.56 0 0 0-1.63 1.26c0 .06-.03.12-.05.2Z"/><path fill="url(#a)" d="M7.77 36.35C6.4 35.11 6 32.51 6.57 30.62c.99 1.2 2.35 1.57 3.75 1.78 2.18.33 4.31.2 6.33-.78.23-.12.44-.27.7-.42.18.55.23 1.1.17 1.67a4.56 4.56 0 0 1-1.94 3.23c-.43.32-.9.61-1.34.91-1.38.94-1.76 2.03-1.24 3.62l.05.17a3.63 3.63 0 0 1-1.6-1.38 3.87 3.87 0 0 1-.63-2.1c0-.37 0-.74-.05-1.1-.13-.9-.55-1.3-1.33-1.32a1.56 1.56 0 0 0-1.63 1.26c0 .06-.03.12-.05.2Z"/><path fill="#17191E" d="M.02 30.31s4.02-1.95 8.05-1.95l3.04-9.4c.11-.45.44-.76.82-.76.37 0 .7.31.82.76l3.04 9.4c4.77 0 8.05 1.95 8.05 1.95L17 11.71c-.2-.56-.53-.91-.98-.91H7.83c-.44 0-.76.35-.97.9L.02 30.31Zm42.37-5.97c0 1.64-2.05 2.62-4.88 2.62-1.85 0-2.5-.45-2.5-1.41 0-1 .8-1.49 2.65-1.49 1.67 0 3.09.03 4.73.23v.05Zm.03-2.04a21.37 21.37 0 0 0-4.37-.36c-5.32 0-7.82 1.25-7.82 4.18 0 3.04 1.71 4.2 5.68 4.2 3.35 0 5.63-.84 6.46-2.92h.14c-.03.5-.05 1-.05 1.4 0 1.07.18 1.16 1.06 1.16h4.15a16.9 16.9 0 0 1-.36-4c0-1.67.06-2.93.06-4.62 0-3.45-2.07-5.64-8.56-5.64-2.8 0-5.9.48-8.26 1.19.22.93.54 2.83.7 4.06 2.04-.96 4.95-1.37 7.2-1.37 3.11 0 3.97.71 3.97 2.15v.57Zm11.37 3c-.56.07-1.33.07-2.12.07-.83 0-1.6-.03-2.12-.1l-.02.58c0 2.85 1.87 4.52 8.45 4.52 6.2 0 8.2-1.64 8.2-4.55 0-2.74-1.33-4.09-7.2-4.39-4.58-.2-4.99-.7-4.99-1.28 0-.66.59-1 3.65-1 3.18 0 4.03.43 4.03 1.35v.2a46.13 46.13 0 0 1 4.24.03l.02-.55c0-3.36-2.8-4.46-8.2-4.46-6.08 0-8.13 1.49-8.13 4.39 0 2.6 1.64 4.23 7.48 4.48 4.3.14 4.77.62 4.77 1.28 0 .7-.7 1.03-3.71 1.03-3.47 0-4.35-.48-4.35-1.47v-.13Zm19.82-12.05a17.5 17.5 0 0 1-6.24 3.48c.03.84.03 2.4.03 3.24l1.5.02c-.02 1.63-.04 3.6-.04 4.9 0 3.04 1.6 5.32 6.58 5.32 2.1 0 3.5-.23 5.23-.6a43.77 43.77 0 0 1-.46-4.13c-1.03.34-2.34.53-3.78.53-2 0-2.82-.55-2.82-2.13 0-1.37 0-2.65.03-3.84 2.57.02 5.13.07 6.64.11-.02-1.18.03-2.9.1-4.04-2.2.04-4.65.07-6.68.07l.07-2.93h-.16Zm13.46 6.04a767.33 767.33 0 0 1 .07-3.18H82.6c.07 1.96.07 3.98.07 6.92 0 2.95-.03 4.99-.07 6.93h5.18c-.09-1.37-.11-3.68-.11-5.65 0-3.1 1.26-4 4.12-4 1.33 0 2.28.16 3.1.46.03-1.16.26-3.43.4-4.43-.86-.25-1.81-.41-2.96-.41-2.46-.03-4.26.98-5.1 3.38l-.17-.02Zm22.55 3.65c0 2.5-1.8 3.66-4.64 3.66-2.81 0-4.61-1.1-4.61-3.66s1.82-3.52 4.61-3.52c2.82 0 4.64 1.03 4.64 3.52Zm4.71-.11c0-4.96-3.87-7.18-9.35-7.18-5.5 0-9.23 2.22-9.23 7.18 0 4.94 3.49 7.59 9.21 7.59 5.77 0 9.37-2.65 9.37-7.6Z"/><defs><linearGradient id="a" x1="6.33" x2="19.43" y1="40.8" y2="34.6" gradientUnits="userSpaceOnUse"><stop stop-color="#D83333"/><stop offset="1" stop-color="#F041FF"/></linearGradient></defs></svg>
|
||||
|
Before Width: | Height: | Size: 2.8 KiB |
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="1440" height="1024" fill="none"><path fill="url(#a)" fill-rule="evenodd" d="M-217.58 475.75c91.82-72.02 225.52-29.38 341.2-44.74C240 415.56 372.33 315.14 466.77 384.9c102.9 76.02 44.74 246.76 90.31 366.31 29.83 78.24 90.48 136.14 129.48 210.23 57.92 109.99 169.67 208.23 155.9 331.77-13.52 121.26-103.42 264.33-224.23 281.37-141.96 20.03-232.72-220.96-374.06-196.99-151.7 25.73-172.68 330.24-325.85 315.72-128.6-12.2-110.9-230.73-128.15-358.76-12.16-90.14 65.87-176.25 44.1-264.57-26.42-107.2-167.12-163.46-176.72-273.45-10.15-116.29 33.01-248.75 124.87-320.79Z" clip-rule="evenodd" style="opacity:.154"/><path fill="url(#b)" fill-rule="evenodd" d="M1103.43 115.43c146.42-19.45 275.33-155.84 413.5-103.59 188.09 71.13 409 212.64 407.06 413.88-1.94 201.25-259.28 278.6-414.96 405.96-130 106.35-240.24 294.39-405.6 265.3-163.7-28.8-161.93-274.12-284.34-386.66-134.95-124.06-436-101.46-445.82-284.6-9.68-180.38 247.41-246.3 413.54-316.9 101.01-42.93 207.83 21.06 316.62 6.61Z" clip-rule="evenodd" style="opacity:.154"/><defs><linearGradient id="b" x1="373" x2="1995.44" y1="1100" y2="118.03" gradientUnits="userSpaceOnUse"><stop stop-color="#D83333"/><stop offset="1" stop-color="#F041FF"/></linearGradient><linearGradient id="a" x1="107.37" x2="1130.66" y1="1993.35" y2="1026.31" gradientUnits="userSpaceOnUse"><stop stop-color="#3245FF"/><stop offset="1" stop-color="#BC52EE"/></linearGradient></defs></svg>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
15
src/assets/social-email.svg
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 21"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path
|
||||
d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"
|
||||
>
|
||||
</path>
|
||||
<polyline points="22,6 12,13 2,6"></polyline>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 334 B |
14
src/assets/social-facebook.svg
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path
|
||||
d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z"
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 276 B |
14
src/assets/social-github.svg
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path
|
||||
d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 502 B |
16
src/assets/social-linkedin.svg
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path
|
||||
d="M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z"
|
||||
>
|
||||
</path>
|
||||
<rect x="2" y="9" width="4" height="12"></rect>
|
||||
<circle cx="4" cy="4" r="2"></circle>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 379 B |
9
src/assets/social-x.svg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
class="w-6 h-6"
|
||||
>
|
||||
<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z">
|
||||
</path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 291 B |
51
src/components/BlogPost.astro
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
interface Props {
|
||||
title: string;
|
||||
description: string;
|
||||
date: Date;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
const { title, description, date, tags } = Astro.props;
|
||||
---
|
||||
|
||||
<article>
|
||||
<header class="mb-12">
|
||||
<h1 class="text-4xl font-bold mb-2">{title}</h1>
|
||||
<h2 class="text-lg mb-2">{description}</h2>
|
||||
<div class="flex gap-4 text-gray-600 text-sm">
|
||||
<time datetime={new Date(date).toISOString()}>
|
||||
{
|
||||
date.toLocaleDateString("en-US", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
})
|
||||
}
|
||||
</time>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div
|
||||
class="max-w-3xl mb-8
|
||||
prose dark:prose-invert
|
||||
prose-h1:border-b prose-h1:pb-4
|
||||
prose-a:underline prose-a:underline-offset-4
|
||||
prose-p:text-justify prose-img:rounded-xl
|
||||
prose-headings:text-zinc-300"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{
|
||||
tags?.map((tag) => (
|
||||
<a href={`/tags/${tag}`}>
|
||||
<span class="text-sm text-zinc-400 font-semibold rounded-md bg-zinc-800 px-2 py-2 hover:bg-zinc-700">
|
||||
#{tag}
|
||||
</span>
|
||||
</a>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</article>
|
||||
34
src/components/BlogPostCard.astro
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
interface Props {
|
||||
id: string;
|
||||
date: Date;
|
||||
title: string;
|
||||
description: string;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
const { id, date, title, description, tags } = Astro.props;
|
||||
---
|
||||
|
||||
<a href={`/posts/${id}`}>
|
||||
<div class="rounded-lg p-4 bg-zinc-800">
|
||||
<div class="flex items-center text-zinc-400 text-sm mb-2">
|
||||
{
|
||||
date.toLocaleDateString("en-US", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
})
|
||||
}
|
||||
</div>
|
||||
<h2 class="text-2xl font-semibold mb-1">{title}</h2>
|
||||
<p class="text-sm mb-3">{description}</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{
|
||||
tags?.map((tag) => (
|
||||
<span class="text-xs text-zinc-400 font-semibold">#{tag}</span>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
5
src/components/Footer.astro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<footer class="py-4 w-full text-center">
|
||||
<p class="text-xs text-zinc-600 dark:text-zinc-400">
|
||||
© {new Date().getFullYear()} Dhemas Nurjaya. All rights reserved.
|
||||
</p>
|
||||
</footer>
|
||||
19
src/components/Header.astro
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
import NavLink from "./NavLink.astro";
|
||||
---
|
||||
|
||||
<header class="py-4 text-black dark:text-white w-full">
|
||||
<nav class="flex flex-row justify-between" aria-label="Main navigation">
|
||||
<div class="flex gap-2 items-center">
|
||||
<a href="/" aria-label="Home">
|
||||
<p class="text-2xl font-semibold">#!</p>
|
||||
</a>
|
||||
{/* <ThemeToggle /> */}
|
||||
</div>
|
||||
<div class="flex gap-4 items-center justify-end">
|
||||
<NavLink href="/posts" ariaLabel="Posts">Posts</NavLink>
|
||||
<NavLink href="/tags" ariaLabel="Tags">Tags</NavLink>
|
||||
<NavLink href="/about" ariaLabel="About">About</NavLink>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
16
src/components/NavLink.astro
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
interface Props {
|
||||
href: string;
|
||||
ariaLabel?: string;
|
||||
}
|
||||
|
||||
const { href, ariaLabel } = Astro.props;
|
||||
---
|
||||
|
||||
<a
|
||||
href={href}
|
||||
class="hover:underline underline-offset-4 decoration-transparent hover:decoration-current transition-colors duration-300 aria-[current]:underline aria-[current]:decoration-current aria-[current]:font-semibold"
|
||||
aria-label={ariaLabel}
|
||||
>
|
||||
<slot />
|
||||
</a>
|
||||
|
|
@ -1,210 +1,38 @@
|
|||
---
|
||||
import astroLogo from '../assets/astro.svg';
|
||||
import background from '../assets/background.svg';
|
||||
import socialEmail from "../assets/social-email.svg";
|
||||
import socialFacebook from "../assets/social-facebook.svg";
|
||||
import socialGithub from "../assets/social-github.svg";
|
||||
import socialLinkedIn from "../assets/social-linkedin.svg";
|
||||
import socialX from "../assets/social-x.svg";
|
||||
---
|
||||
|
||||
<div id="container">
|
||||
<img id="background" src={background.src} alt="" fetchpriority="high" />
|
||||
<main>
|
||||
<section id="hero">
|
||||
<a href="https://astro.build"
|
||||
><img src={astroLogo.src} width="115" height="48" alt="Astro Homepage" /></a
|
||||
>
|
||||
<h1>
|
||||
To get started, open the <code><pre>src/pages</pre></code> directory in your project.
|
||||
</h1>
|
||||
<section id="links">
|
||||
<a class="button" href="https://docs.astro.build">Read our docs</a>
|
||||
<a href="https://astro.build/chat"
|
||||
>Join our Discord <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 127.14 96.36"
|
||||
><path
|
||||
fill="currentColor"
|
||||
d="M107.7 8.07A105.15 105.15 0 0 0 81.47 0a72.06 72.06 0 0 0-3.36 6.83 97.68 97.68 0 0 0-29.11 0A72.37 72.37 0 0 0 45.64 0a105.89 105.89 0 0 0-26.25 8.09C2.79 32.65-1.71 56.6.54 80.21a105.73 105.73 0 0 0 32.17 16.15 77.7 77.7 0 0 0 6.89-11.11 68.42 68.42 0 0 1-10.85-5.18c.91-.66 1.8-1.34 2.66-2a75.57 75.57 0 0 0 64.32 0c.87.71 1.76 1.39 2.66 2a68.68 68.68 0 0 1-10.87 5.19 77 77 0 0 0 6.89 11.1 105.25 105.25 0 0 0 32.19-16.14c2.64-27.38-4.51-51.11-18.9-72.15ZM42.45 65.69C36.18 65.69 31 60 31 53s5-12.74 11.43-12.74S54 46 53.89 53s-5.05 12.69-11.44 12.69Zm42.24 0C78.41 65.69 73.25 60 73.25 53s5-12.74 11.44-12.74S96.23 46 96.12 53s-5.04 12.69-11.43 12.69Z"
|
||||
></path></svg
|
||||
>
|
||||
</a>
|
||||
</section>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<a href="https://astro.build/blog/astro-5/" id="news" class="box">
|
||||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"
|
||||
><path
|
||||
d="M24.667 12c1.333 1.414 2 3.192 2 5.334 0 4.62-4.934 5.7-7.334 12C18.444 28.567 18 27.456 18 26c0-4.642 6.667-7.053 6.667-14Zm-5.334-5.333c1.6 1.65 2.4 3.43 2.4 5.333 0 6.602-8.06 7.59-6.4 17.334C13.111 27.787 12 25.564 12 22.666c0-4.434 7.333-8 7.333-16Zm-6-5.333C15.111 3.555 16 5.556 16 7.333c0 8.333-11.333 10.962-5.333 22-3.488-.774-6-4-6-8 0-8.667 8.666-10 8.666-20Z"
|
||||
fill="#111827"></path></svg
|
||||
>
|
||||
<h2>What's New in Astro 5.0?</h2>
|
||||
<p>
|
||||
From content layers to server islands, click to learn more about the new features and
|
||||
improvements in Astro 5.0
|
||||
</p>
|
||||
</a>
|
||||
<div class="flex flex-col min-h-full items-center justify-center">
|
||||
<img
|
||||
src="/images/profile.jpg"
|
||||
alt="profile picture of Dhemas Nurjaya"
|
||||
class="w-48 h-48 rounded-2xl"
|
||||
/>
|
||||
<h1 class="text-5xl font-bold mt-4">Dhemas Nurjaya</h1>
|
||||
<h2 class="text-xl mt-2">Passionate Software Engineer</h2>
|
||||
<div class="flex flex-row gap-8 mt-8" aria-label="social links">
|
||||
<a
|
||||
href="https://www.linkedin.com/in/dhemas-nurjaya-030890bb"
|
||||
aria-label="Linkedin"
|
||||
>
|
||||
<img src={socialLinkedIn.src} alt="" fetchpriority="high" class="w-6 h-6 invert" />
|
||||
</a>
|
||||
<a href="https://github.com/dhemasnurjaya" aria-label="Github">
|
||||
<img src={socialGithub.src} alt="" fetchpriority="high" class="w-6 h-6 invert" />
|
||||
</a>
|
||||
<a href="https://x.com/dhemaseka" aria-label="X">
|
||||
<img src={socialX.src} alt="" fetchpriority="high" class="w-6 h-6 invert" />
|
||||
</a>
|
||||
<a href="https://www.facebook.com/Dhemas" aria-label="Facebook">
|
||||
<img src={socialFacebook.src} alt="" fetchpriority="high" class="w-6 h-6 invert" />
|
||||
</a>
|
||||
<a href="mailto:dhemasnurjaya@gmail.com" aria-label="Email">
|
||||
<img src={socialEmail.src} alt="" fetchpriority="high" class="w-6 h-6 invert" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="mt-24"></div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
#background {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: -1;
|
||||
filter: blur(100px);
|
||||
}
|
||||
|
||||
#container {
|
||||
font-family: Inter, Roboto, 'Helvetica Neue', 'Arial Nova', 'Nimbus Sans', Arial, sans-serif;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
main {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#hero {
|
||||
display: flex;
|
||||
align-items: start;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 22px;
|
||||
margin-top: 0.25em;
|
||||
}
|
||||
|
||||
#links {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
#links a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px 12px;
|
||||
color: #111827;
|
||||
text-decoration: none;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
#links a:hover {
|
||||
color: rgb(78, 80, 86);
|
||||
}
|
||||
|
||||
#links a svg {
|
||||
height: 1em;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
#links a.button {
|
||||
color: white;
|
||||
background: linear-gradient(83.21deg, #3245ff 0%, #bc52ee 100%);
|
||||
box-shadow:
|
||||
inset 0 0 0 1px rgba(255, 255, 255, 0.12),
|
||||
inset 0 -2px 0 rgba(0, 0, 0, 0.24);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#links a.button:hover {
|
||||
color: rgb(230, 230, 230);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-family:
|
||||
ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono',
|
||||
monospace;
|
||||
font-weight: normal;
|
||||
background: linear-gradient(14deg, #d83333 0%, #f041ff 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0 0 1em;
|
||||
font-weight: normal;
|
||||
color: #111827;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
p {
|
||||
color: #4b5563;
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
letter-spacing: -0.006em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
code {
|
||||
display: inline-block;
|
||||
background:
|
||||
linear-gradient(66.77deg, #f3cddd 0%, #f5cee7 100%) padding-box,
|
||||
linear-gradient(155deg, #d83333 0%, #f041ff 18%, #f5cee7 45%) border-box;
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
|
||||
.box {
|
||||
padding: 16px;
|
||||
background: rgba(255, 255, 255, 1);
|
||||
border-radius: 16px;
|
||||
border: 1px solid white;
|
||||
}
|
||||
|
||||
#news {
|
||||
position: absolute;
|
||||
bottom: 16px;
|
||||
right: 16px;
|
||||
max-width: 300px;
|
||||
text-decoration: none;
|
||||
transition: background 0.2s;
|
||||
backdrop-filter: blur(50px);
|
||||
}
|
||||
|
||||
#news:hover {
|
||||
background: rgba(255, 255, 255, 0.55);
|
||||
}
|
||||
|
||||
@media screen and (max-height: 368px) {
|
||||
#news {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
#container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#hero {
|
||||
display: block;
|
||||
padding-top: 10%;
|
||||
}
|
||||
|
||||
#links {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
#links a.button {
|
||||
padding: 14px 18px;
|
||||
}
|
||||
|
||||
#news {
|
||||
right: 16px;
|
||||
left: 16px;
|
||||
bottom: 2.5rem;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
18
src/content.config.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { glob } from "astro/loaders";
|
||||
import { z } from "astro/zod";
|
||||
import { defineCollection } from "astro:content";
|
||||
|
||||
const BlogPostSchema = z.object({
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
date: z.date(),
|
||||
draft: z.boolean().optional(),
|
||||
tags: z.array(z.string()).optional(),
|
||||
});
|
||||
|
||||
const blog = defineCollection({
|
||||
loader: glob({ pattern: "**/*.md", base: "./src/content/blog" }),
|
||||
schema: BlogPostSchema,
|
||||
});
|
||||
|
||||
export const collections = { blog };
|
||||
130
src/content/blog/crdt-conflict-free-replicated-data-types.md
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
---
|
||||
title: 'CRDT - Conflict Free Replicated Data Types'
|
||||
description: 'A brief intro to Conflict Free Replicated Data Types'
|
||||
date: 2025-02-24T09:58:08+07:00
|
||||
draft: false
|
||||
tags:
|
||||
- programming
|
||||
- dart
|
||||
- data
|
||||
---
|
||||
|
||||
# Background
|
||||
When searching techniques for syncing data between peers, I stumbled upon CRDT (Conflict-free Replicated Data Types). It's basically a algorithm for syncing for distributed systems. CRDT ensures all data changes between peer will be synced with correct order and no data loss.
|
||||
|
||||
Since I working with Dart (for Flutter project), I use a [CRDT library for Dart](https://github.com/cachapa/crdt). This library implements core concept of CRDT and it's pretty basic. Here some types of CRDT that often used:
|
||||
|
||||
1. **G-Counter (Grow-only Counter)**: A counter that can only be incremented.
|
||||
2. **P-Counter (Decrement Counter)**: A counter that can be both incremented and decremented.
|
||||
3. **G-Set (Grow-only Set)**: A set that only allows elements to be added.
|
||||
4. **2P-Set (Two-Phase Set)**: A set that allows elements to be added and removed, maintaining two sets (one for additions and one for removals).
|
||||
5. **OR-Set (Observed Remove Set)**: A set that allows elements to be added and removed, using unique identifiers to track additions and removals.
|
||||
6. **LWW-Register (Last Write Wins Register)**: A register that stores the last written value, using a timestamp to determine the most recent update.
|
||||
7. **MV-Register (Multi-Value Register)**: A register that stores all values that have been written, using unique identifiers to track writes.
|
||||
# How it works -- basic version
|
||||
Main components:
|
||||
- HLC (Hardware Logical Clock). Combines _wall clock/local time_, a counter that increments, and an optional _node ID_ for uniqueness sake.
|
||||
- The data itself (usually contains a key, value, and the HLC object).
|
||||
## **Scenario: Two Devices Synchronizing Data**
|
||||
We have two devices, **Device A** and **Device B**, which both maintain their own local datasets. Each device can modify data independently. When they synchronize, their CRDT implementations will merge their changes and resolve conflicts.
|
||||
## Initial State
|
||||
- Both devices start with the same data:
|
||||
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 1 | Alice | false | HLC: A1 |
|
||||
| 2 | Bob | false | HLC: A2 |
|
||||
|
||||
- Device A's last modified HLC: `A2`.
|
||||
- Device B's last modified HLC: `A2`.
|
||||
|
||||
---
|
||||
## Changes Made on Each Device
|
||||
1. **Device A deletes Bob's record (key 2):**
|
||||
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 2 | null | true | HLC: A3 |
|
||||
|
||||
2. **Device B updates Alice's name to Alice Smith (key 1):**
|
||||
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 1 | Alice Smith | false | HLC: B3 |
|
||||
|
||||
---
|
||||
## Synchronization and Merge
|
||||
- Device A sends its **changeset** to Device B:
|
||||
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 2 | null | true | HLC: A3 |
|
||||
|
||||
- Device B sends its **changeset** to Device A:
|
||||
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 1 | Alice Smith | false | HLC: B3 |
|
||||
|
||||
---
|
||||
## Step-by-Step Conflict Resolution
|
||||
|
||||
The `merge` method processes these changes:
|
||||
1. **Validate Changeset**:
|
||||
Each incoming record is validated to ensure it matches the expected schema and contains valid HLC timestamps.
|
||||
|
||||
2. **Compare Records for Key 1 (`Alice`)**:
|
||||
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 1 | Alice | false | HLC: A1 |
|
||||
|
||||
Incoming record from Device B:
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 1 | Alice Smith | false | HLC: B3 |
|
||||
|
||||
**Conflict Resolution Rule**: The record with the higher `Last Modified` HLC wins. HLC `B3 > A1,` so Device A updates Alice's record to:
|
||||
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 1 | Alice Smith | false | HLC: B3 |
|
||||
|
||||
3. **Compare Records for Key 2 (`Bob`)**:
|
||||
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 2 | Bob | false | HLC: A2 |
|
||||
|
||||
Incoming record from Device A:
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 2 | null | true | HLC: A3 |
|
||||
|
||||
**Conflict Resolution Rule**: The record with the higher `Last Modified` HLC wins. HLC `A3 > A2`, so Device B updates Bob's record to:
|
||||
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 2 | null | true | HLC: A3 |
|
||||
|
||||
4. **Propagate Changes**:
|
||||
Both devices now have identical datasets after merging.
|
||||
|
||||
---
|
||||
## Final Merged Dataset on Both Devices
|
||||
|
||||
| Key | Value | isDeleted | Last Modified |
|
||||
| --- | ----- | --------- | ------------- |
|
||||
| 1 | Alice Smith | false | HLC: B3 |
|
||||
| 2 | null | true | HLC: A3 |
|
||||
|
||||
---
|
||||
## Summary of Conflict Resolution Rules
|
||||
|
||||
1. **Higher HLC Wins**
|
||||
Records with higher HLCs (later timestamps) overwrite those with lower HLCs.
|
||||
2. **Soft Deletes**
|
||||
A `null` value with `isDeleted: true` is treated as a soft delete. It wins if its HLC is higher.
|
||||
3. **Deterministic Behavior**
|
||||
All nodes independently apply the same conflict resolution logic, ensuring eventual consistency.
|
||||
|
||||
54
src/content/blog/fix-adb-unsufficient-permission-linux.md
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
title: 'Fix ADB Insufficient Permission'
|
||||
description: 'udev rules for fixing ADB Insufficient permission in Linux'
|
||||
date: 2025-02-24T11:29:30+07:00
|
||||
draft: false
|
||||
tags:
|
||||
- android
|
||||
- adb
|
||||
- linux
|
||||
---
|
||||
|
||||
# Why need this?
|
||||
Connecting an Android device to a Linux computer could has problem with permission. Listing devices with `adb devices` might show `unauthorized` status or `insufficient permission` error message.
|
||||
|
||||
```bash
|
||||
$ adb devices
|
||||
|
||||
List of devices attached
|
||||
15241JEC211677 device
|
||||
RR2M9002AHY unauthorized
|
||||
```
|
||||
|
||||
This happens because by default, in Linux, when you connect an Android device via USB, the system assigns it to the `root` user and a restrictive permission mode (often 0600), meaning that regular users cannot access it.
|
||||
|
||||
# How to fix
|
||||
|
||||
1. Check `vendor id` and `device id` from connected Android device with `lsusb`.
|
||||
|
||||
```bash
|
||||
$ lsusb
|
||||
|
||||
...some other devices
|
||||
Bus 001 Device 005: ID 18d1:4ee7 Google Inc. Nexus/Pixel Device
|
||||
```
|
||||
|
||||
`18d1` is *vendor id* and `4ee7` is the *product id*.
|
||||
|
||||
2. Create an `udev` rule for this device, I create mine in `/etc/udev/rules.d/51-android.rules`.
|
||||
|
||||
```bash
|
||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="4ee7", MODE="0666", GROUP="plugdev", SYMLINK+="google_pixel_4a_%n"
|
||||
```
|
||||
|
||||
- `SUBSYSTEM=="usb"` ensures the rule applies only to USB devices.
|
||||
- `ATTRS{idVendor}=="18d1" and ATTRS{idProduct}=="4ee7"` match the Google Pixel USB devices by their vendor and product IDs.
|
||||
- `MODE="0666"` sets the device's permission mode to 0666, meaning read/write access for all users.
|
||||
- `GROUP="plugdev"` assigns the device to the plugdev group, which allows users in that group to access it.
|
||||
- `SYMLINK+="google_pixel_4a_%n"` creates a symlink (shortcut) under /dev/ with a readable name for easier identification.
|
||||
|
||||
3. Reconnect the device to make sure the rule is correct. If not, try to reload `udev` rules and restart it.
|
||||
|
||||
```bash
|
||||
$ sudo udevadm control --reload-rules
|
||||
```
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
---
|
||||
title: 'Fix Infinix Air Pro+ Quad Speakers in Linux'
|
||||
description: 'A fix for Infinix Air Pro+ -- only 2 of 4 speakers working in Linux'
|
||||
date: 2025-02-23T23:27:49+07:00
|
||||
draft: false
|
||||
tags:
|
||||
- laptop
|
||||
- infinix
|
||||
- tweak
|
||||
- linux
|
||||
---
|
||||
|
||||
I installed Linux ([EndeavourOS](https://endeavouros.com/)) in my Infinix Air Pro+ last week and noticed that the sound coming from the speakers was bad. This laptops has 4 speakers, hence only 2 of them are working. This is how I fix this issue.
|
||||
|
||||
# Check ALSA for Hidden Speakers
|
||||
|
||||
```bash
|
||||
$ cat /proc/asound/card0/codec* | grep -i "node"
|
||||
|
||||
State of AFG node 0x01:
|
||||
Node 0x02 [Audio Output] wcaps 0x41d: Stereo Amp-Out
|
||||
Node 0x03 [Audio Output] wcaps 0x41d: Stereo Amp-Out
|
||||
Node 0x04 [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x05 [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x06 [Audio Output] wcaps 0x611: Stereo Digital
|
||||
Node 0x07 [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x08 [Audio Input] wcaps 0x10051b: Stereo Amp-In
|
||||
Node 0x09 [Audio Input] wcaps 0x10051b: Stereo Amp-In
|
||||
Node 0x0a [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x0b [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
|
||||
Node 0x0c [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
|
||||
Node 0x0d [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
|
||||
Node 0x0e [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x0f [Audio Mixer] wcaps 0x20010a: Mono Amp-In
|
||||
Node 0x10 [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x11 [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x12 [Pin Complex] wcaps 0x40040b: Stereo Amp-In
|
||||
Node 0x13 [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x14 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
|
||||
Node 0x15 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
|
||||
Node 0x16 [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x17 [Pin Complex] wcaps 0x40050c: Mono Amp-Out
|
||||
Node 0x18 [Pin Complex] wcaps 0x40058f: Stereo Amp-In Amp-Out
|
||||
Node 0x19 [Pin Complex] wcaps 0x40058f: Stereo Amp-In Amp-Out
|
||||
Node 0x1a [Pin Complex] wcaps 0x40058f: Stereo Amp-In Amp-Out
|
||||
Node 0x1b [Pin Complex] wcaps 0x40058f: Stereo Amp-In Amp-Out
|
||||
Node 0x1c [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x1d [Pin Complex] wcaps 0x400400: Mono
|
||||
Node 0x1e [Pin Complex] wcaps 0x400781: Stereo Digital
|
||||
Node 0x1f [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x20 [Vendor Defined Widget] wcaps 0xf00040: Mono
|
||||
Node 0x21 [Vendor Defined Widget] wcaps 0xf00000: Mono
|
||||
Node 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
|
||||
Node 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
|
||||
State of AFG node 0x01:
|
||||
Node 0x03 [Audio Output] wcaps 0x6611: 8-Channels Digital
|
||||
Node 0x04 [Pin Complex] wcaps 0x40778d: 8-Channels Digital Amp-Out CP
|
||||
Node 0x05 [Audio Output] wcaps 0x6611: 8-Channels Digital
|
||||
Node 0x06 [Pin Complex] wcaps 0x40778d: 8-Channels Digital Amp-Out CP
|
||||
Node 0x07 [Audio Output] wcaps 0x6611: 8-Channels Digital
|
||||
Node 0x08 [Pin Complex] wcaps 0x40778d: 8-Channels Digital Amp-Out CP
|
||||
Node 0x09 [Audio Output] wcaps 0x6611: 8-Channels Digital
|
||||
Node 0x0a [Pin Complex] wcaps 0x40778d: 8-Channels Digital Amp-Out CP
|
||||
Node 0x0b [Pin Complex] wcaps 0x40778d: 8-Channels Digital Amp-Out CP
|
||||
Node 0x0c [Pin Complex] wcaps 0x40778d: 8-Channels Digital Amp-Out CP
|
||||
Node 0x0d [Pin Complex] wcaps 0x40778d: 8-Channels Digital Amp-Out CP
|
||||
Node 0x0e [Pin Complex] wcaps 0x40778d: 8-Channels Digital Amp-Out CP
|
||||
Node 0x0f [Pin Complex] wcaps 0x40778d: 8-Channels Digital Amp-Out CP
|
||||
```
|
||||
|
||||
Looking at that output, it seems that this laptop has several nodes that could be an audio output. They are nodes with `Stereo Amp-In Amp-Out` in it's description. Filtering the result with that, I got:
|
||||
|
||||
- 0x14 - Stereo Amp-Out (I suspect this is the front speakers that are working)
|
||||
- 0x15 - Stereo Amp-Out (likely another speakers?)
|
||||
- 0x18, 0x19, 0x1a, 0x1b - Stereo Amp-In Amp-Out (might be extra speaker outputs)
|
||||
|
||||
# Enable Additional Speakers with `hdajackretask`
|
||||
|
||||
`hdajackretask` is a tool from ALSA that allow us to remap/retask those nodes/jack into different purposes.
|
||||
|
||||
```bash
|
||||
$ sudo pacman -S alsa-tools
|
||||
$ sudo hdajackretask
|
||||
```
|
||||
|
||||
After opening the tool, check the `Show unconnected pins` and there will be list of nodes that can be retasked.
|
||||
I need to experiment with this remapping. After trials and errors, I found that `0x1a` and `0x1b` is the responsible nodes for my extra speakers. Overriding them and changing their role as `Internal Speaker` solve my issue.
|
||||
|
||||

|
||||
|
||||
Now all my speakers is working! I hope this will help someone in the future.
|
||||
180
src/content/blog/fix-infinix-air-pro-plus-screen-color.md
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
---
|
||||
title: 'Fix Infinix Air Pro+ Screen Color'
|
||||
description: 'Fixing Infinix Air Pro+ washed out screen color in Windows and Linux'
|
||||
date: 2025-02-21T18:09:54+07:00
|
||||
draft: false
|
||||
tags:
|
||||
- laptop
|
||||
- infinix
|
||||
- tweak
|
||||
- script
|
||||
---
|
||||
|
||||
I have Infinix Air Pro+ and I use it for my work. I can say it is a good laptop coding mainly because it has 2.5k OLED 16:10 screen. But I found a problem with its screen color. When the screen brightness is below about 50% and the screen turned off (to save power, not necessarily going system sleep/suspend) and turns back on, the color looks washed out.
|
||||
|
||||
First time I noticed this issue is because I was using a pitch black wallpaper image (so I can flex my OLED display). After my screen turns back on, my wallpaper's black color becomes grainy, washed out, as its doesn't have pitch black color anymore. Then I noticed, the color will be fixed after I crank the brightness to above 50%. Turning the brightness down again after this still gives me correct black level.
|
||||
|
||||
So, I was wondering if I create a script that will turn the brightness to above 50% and restore it to where it was every time my screen is waking up from a sleep. With a help from Google and ChatGPT, I create these scripts as a workaround for this annoying issue.
|
||||
|
||||
# Windows
|
||||
Before continuing, I'm sorry I can't give any screenshot for this Windows section because I already switched to Linux, but I hope I can write it clearly.
|
||||
|
||||
## Get screen wake up event
|
||||
I need to listen to an event that tells me "Hey, the screen is turning on". Fortunately, Windows has [Event Viewer](https://learn.microsoft.com/en-us/shows/inside/event-viewer) that I can use for this. I found that an event from *Kernel-Power* with event ID *507* is the correct event that means the screen in turned back on.
|
||||
|
||||
## Script
|
||||
Next thing to do is create the script to control screen brightness. After trial and error, I found [NirCmd](https://www.nirsoft.net/utils/nircmd.html) can help me to change my screen brightness. Then I create this Powershell script.
|
||||
|
||||
```powershell
|
||||
# Infinix Air Pro Plus suffers from washed out colors
|
||||
# after the display goes off and back on if the brightness is below 50%.
|
||||
# This script will increase the brightness to 60% when initial brightness
|
||||
# is below 50% else it will increase 10% from current brightness and turn
|
||||
# back to initial brightness value.
|
||||
|
||||
# Path to NirCmd executable
|
||||
$nircmd = "C:\nircmd-x64\nircmd.exe"
|
||||
|
||||
# Function to temporarily adjust brightness
|
||||
function Adjust-Brightness {
|
||||
param (
|
||||
[int]$InitialBrightness,
|
||||
[int]$TargetBrightness
|
||||
)
|
||||
|
||||
# Set brightness to target
|
||||
& $nircmd "setbrightness" $TargetBrightness
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
# Restore to initial brightness
|
||||
& $nircmd "setbrightness" $InitialBrightness
|
||||
}
|
||||
|
||||
# Dummy current brightness (replace this with actual detection logic if available)
|
||||
$currentBrightness = (Get-CimInstance -Namespace root/WMI -ClassName WmiMonitorBrightness).CurrentBrightness
|
||||
|
||||
if ($currentBrightness -lt 50) {
|
||||
# If brightness is below 50%, temporarily set to 60
|
||||
Adjust-Brightness -InitialBrightness $currentBrightness -TargetBrightness 60
|
||||
} else {
|
||||
# Otherwise, increase brightness by 10%
|
||||
$newBrightness = [Math]::Min($currentBrightness + 10, 100)
|
||||
Adjust-Brightness -InitialBrightness $currentBrightness -TargetBrightness $newBrightness
|
||||
}
|
||||
```
|
||||
|
||||
## Make a schedule
|
||||
I use Windows' [Task Scheduler](https://www.windowscentral.com/how-create-automated-tasks-windows-11) to run the script each time *Kernel-Power* with event ID *507* occurs. I can't show the step-by-step guide because I'm on Linux now, but I have a backup file for this task. All you need is just to import [this task](/misc/Restore%20OLED%20Colors.xml) in Task Scheduler.
|
||||
|
||||
> Note: You have to change the command it executes to where you save the Powershell script. Also change the author into `YOUR_PC_NAME\YOUR_USERNAME`.
|
||||
|
||||
# Linux
|
||||
I'm using [EndeavourOS](https://endeavouros.com/) which use `systemd`. So this guide is applicable to `systemd` init system only. If your linux use something else, you need to adjust it with your init system.
|
||||
|
||||
## Get screen wake up event
|
||||
I already tried several ways to listen the screen wake up events. But I can't find any using `acpi` and `udev`. So I tried different approach. I check `dpms` property from screen device in `/sys/class/drm/card1-eDP-1/dpms`. It has `On` and `Off` value that I can use for triggering a script to fix the color.
|
||||
|
||||
## Script
|
||||
I have 2 scripts for this approach. One for checking `/sys/class/drm/card1-eDP-1/dpms` value and another one for fixing the color.
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# monitor /sys/class/drm/card1-eDP-1/dpms value
|
||||
# place it to /usr/local/bin/monitor_screen_power.sh
|
||||
|
||||
prev_state=""
|
||||
|
||||
while true; do
|
||||
state=$(cat /sys/class/drm/card1-eDP-1/dpms)
|
||||
|
||||
if [[ "$state" != "$prev_state" && "$state" == "On" ]]; then
|
||||
echo "Screen turned on! Running script..."
|
||||
/usr/local/bin/brightness_fix.sh
|
||||
fi
|
||||
|
||||
prev_state=$state
|
||||
sleep 1 # Adjust polling interval as needed
|
||||
done
|
||||
```
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# adjust the brightness
|
||||
# place it to /usr/local/bin/brightness_fix.sh
|
||||
|
||||
# Path to brightness control (may vary based on hardware, check /sys/class/backlight/)
|
||||
BRIGHTNESS_PATH="/sys/class/backlight/intel_backlight/brightness"
|
||||
MAX_BRIGHTNESS_PATH="/sys/class/backlight/intel_backlight/max_brightness"
|
||||
|
||||
# Read current brightness
|
||||
CURRENT_BRIGHTNESS=$(cat "$BRIGHTNESS_PATH")
|
||||
MAX_BRIGHTNESS=$(cat "$MAX_BRIGHTNESS_PATH")
|
||||
|
||||
# Convert brightness levels to percentage
|
||||
CURRENT_PERCENT=$(( CURRENT_BRIGHTNESS * 100 / MAX_BRIGHTNESS ))
|
||||
|
||||
# Function to set brightness based on percentage
|
||||
set_brightness() {
|
||||
local TARGET_PERCENT=$1
|
||||
local TARGET_BRIGHTNESS=$(( TARGET_PERCENT * MAX_BRIGHTNESS / 100 ))
|
||||
echo $TARGET_BRIGHTNESS | sudo tee "$BRIGHTNESS_PATH" > /dev/null
|
||||
}
|
||||
|
||||
# Adjust brightness logic
|
||||
if [ "$CURRENT_PERCENT" -lt 50 ]; then
|
||||
set_brightness 60
|
||||
sleep 0.5
|
||||
set_brightness "$CURRENT_PERCENT"
|
||||
else
|
||||
TARGET_PERCENT=$(( CURRENT_PERCENT + 10 ))
|
||||
if [ "$TARGET_PERCENT" -gt 100 ]; then
|
||||
TARGET_PERCENT=100
|
||||
fi
|
||||
set_brightness "$TARGET_PERCENT"
|
||||
sleep 0.5
|
||||
set_brightness "$CURRENT_PERCENT"
|
||||
fi
|
||||
```
|
||||
|
||||
## Make a systemd service
|
||||
Make a `systemd` service in `/etc/systemd/system/brightness-fix.service` to run the first script.
|
||||
|
||||
```plaintext
|
||||
[Unit]
|
||||
Description=Fix screen brightness on wake
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/monitor_screen_power.sh
|
||||
Restart=always
|
||||
User=dhemas
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
and another one to run `brightness-fix.sh` after waking up from suspend/sleep, I put it in `/etc/systemd/system/brightness-fix-wakeup.service`.
|
||||
|
||||
```plaintext
|
||||
[Unit]
|
||||
Description=Fix screen brightness after wakeup
|
||||
After=suspend.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/brightness_fix.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=suspend.target
|
||||
```
|
||||
|
||||
Then register, enable, and start it.
|
||||
|
||||
```bash
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable brightness-fix.service
|
||||
sudo systemctl enable brightness-fix-wakeup.service
|
||||
sudo systemctl start brightness-fix.service
|
||||
```
|
||||
|
||||
One more thing, you can add also `/usr/local/bin/brightness_fix.sh` to autostart (I'm using KDE) so it will run each time you login.
|
||||
25
src/content/blog/flutter-android-emulator-not-showing.md
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
title: 'Android Devices Not Showing on Flutter Project'
|
||||
description: "A fix for new Flutter project that doesn't have Android devices showing up"
|
||||
date: 2025-02-22T09:21:22+07:00
|
||||
draft: false
|
||||
tags:
|
||||
- programming
|
||||
- flutter
|
||||
- android
|
||||
- emulator
|
||||
---
|
||||
|
||||
When I create a new Flutter project targeting Android device, I can't choose which Android device to run it. Either it a real connected devices or AVDs, even the devices is available and listed in `Device Manager` tab.
|
||||
|
||||

|
||||
|
||||
All I need to do is open `File > Project Structure...` or `Ctrl + Alt + Shift + S`.
|
||||
|
||||

|
||||
|
||||
As you can see, I have no Android SDK selected for my Flutter project. So, go ahead and select one of SDK listed there and click `OK`. That's it! Now you can see all the devices available to run my Flutter project.
|
||||
|
||||

|
||||
|
||||
Hope this can help someone who has similar issues with Flutter project and Android devices.
|
||||
1216
src/content/blog/flutter-clean-architecture.md
Normal file
46
src/content/blog/kuwot-flutter-daily-quote-app.md
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
title: 'Kuwot'
|
||||
description: 'Flutter Daily Quote App'
|
||||
date: 2025-02-20T15:26:04+07:00
|
||||
draft: true
|
||||
tags:
|
||||
- programming
|
||||
- flutter
|
||||
---
|
||||
|
||||
I made [Kuwot](https://play.google.com/store/apps/details?id=com.dhemasnurjaya.kuwot) last year in my spare time. I want to share it, you can use it as an inspiration, practice app, or something else is up to you since I open-sourced the code (links below).
|
||||
|
||||
# Introduction
|
||||
The Flutter app itself was built using [Clean Architecture]({{< ref "/posts/flutter-clean-architecture/index.md" >}}). It has all basic features from a daily quote application. At first, my idea is to make a simple daily quote application. Showing random quote everytime the app is opened, and give it an image background to make it more appealing.
|
||||
|
||||
# Hunting for quote data
|
||||
First thing I did was searching some kind of quote data that available for free. I stumbled across several choices:
|
||||
|
||||
- Use available quote API, eg: [Zen Quotes](https://zenquotes.io)
|
||||
- Scraping quotes website
|
||||
- Find dataset that already compiled somewhere in [Github](https://github.com)
|
||||
|
||||
After many consideration, I'd like to use this [Quotes 500k](https://github.com/ShivaliGoel/Quotes-500K) as my quote data source. Originally, that quote data was used for a research paper and made by scraping several quote websites.
|
||||
|
||||
First problem solved, since I have the quote dataset I was thinking whether I embed this dataset as SQLite database into the app or do something else. But then I remember that I still need to get the background image for the app and it will make no sense to embed the background images into the app as well. So I decided to create a simple REST API for Kuwot.
|
||||
|
||||
# Building the API
|
||||
Now I need a simple, easy to make REST API. I was thinking to use Python's [FastAPI](https://fastapi.tiangolo.com/) but after some onboarding tutorial, I just don't like it. Then I found [dart_frog](https://dartfrog.vgv.dev/)! It's a minimalist backend framework written in Dart. There are no reason to not use this since it use same language as my Flutter app, that was I thought.
|
||||
|
||||
Building the API is straight-forward, [dart_frog](https://dartfrog.vgv.dev/) has everything I need to build the API.
|
||||
|
||||
# Reshaping dataset
|
||||
The data I got from [Quotes 500k](https://github.com/ShivaliGoel/Quotes-500K) is looking like this:
|
||||
|
||||
| Quote | Author | Tags |
|
||||
| ----- | ------ | ---- |
|
||||
| A friend is someone who knows all about you and still loves you. | Elbert Hubbard | friend, friendship, knowledge, love |
|
||||
|
||||
Now, I didn't want the tags and I don't want a long quote. So I make a Python script to filter those quotes into a new dataset I need.
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
# UI Design
|
||||
I want to make it as simple as possible while focusing on the functionality.
|
||||
44
src/content/blog/remap-copilot-key-infinix-air-pro-plus.md
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
title: 'Remap Infinix Air Pro+ Copilot Key in Linux'
|
||||
description: 'Re-using Copilot key for something else more useful'
|
||||
date: 2025-03-01T22:41:32+07:00
|
||||
draft: false
|
||||
tags:
|
||||
- linux
|
||||
- laptop
|
||||
- infinix
|
||||
- tweak
|
||||
---
|
||||
|
||||
> Since I'm moving to Linux, my Copilot key becomes useless.
|
||||
|
||||
Let me rephrase that! Even when I was using Windows, I never using this Copilot shortcut key in my keyboard 😬. Fortunately, using Linux I can remap this key for something else ~~more useful~~.
|
||||
|
||||
# Requirements
|
||||
- A laptop (I'm using Infinix Air Pro+) with a working keyboard.
|
||||
- [keyd](https://github.com/rvaiya/keyd)
|
||||
|
||||
# Finding what this Copilot key do
|
||||
- Open your favorite terminal and execute `sudo keyd monitor`. This command will print what events are triggered when a particular key is pressed.
|
||||
- Press the Copilot key and read the output. In my laptop, it print out this:
|
||||
|
||||
```bash
|
||||
AT Translated Set 2 keyboard 0001:0001:70533846 leftmeta down
|
||||
AT Translated Set 2 keyboard 0001:0001:70533846 leftshift down
|
||||
AT Translated Set 2 keyboard 0001:0001:70533846 f23 down
|
||||
```
|
||||
|
||||
- Now I know that my copilot key triggers `leftmeta`, `leftshift`, and `f23`. It's seem legit combination of modifier keys and a function key. But unfortunately when I tried to use it in my desktop environment (I use KDE) to bind a shortcut, it only detect the modifier `meta` and `shift`.
|
||||
|
||||
# `keyd` for the rescue
|
||||
Edit `/etc/keyd/default.conf` file and I added these lines:
|
||||
|
||||
```plaintext
|
||||
[ids]
|
||||
0001:0001:70533846
|
||||
|
||||
[main]
|
||||
f23 = f13
|
||||
```
|
||||
|
||||
`ids` is my keyboad ID, and the last line tells to remap `f23` key to `f13` (which is doesn't exist physically). Then reload `keyd` with `sudo keyd reload`. Now I can bind my Copilot key to something else. I'm using it for [yakuake](https://github.com/KDE/yakuake) show/hide toggle.
|
||||
23
src/content/blog/welcome.md
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
title: 'Welcome'
|
||||
description: 'Initial commit!'
|
||||
date: 2024-03-18T14:16:19+07:00
|
||||
draft: false
|
||||
tags:
|
||||
- misc
|
||||
---
|
||||
|
||||
# Introduction
|
||||
|
||||
Hi there! I'm Dhemas, an Indonesian software engineer. I grew up in a small town called Salatiga, Central Java, Indonesia. I really like to tinker with computer since I was a child. Playing games (SkiFree to Age of Empires II) in my dad's office computer, then learn some office softwares, buying a floppy disk to save my diary (encrypted with Webdings font!), buying PC magazines, leads to learn how to assemble my own computer and do an OS install. That was a good time!
|
||||
|
||||
Long story short, I decide to take an Information Technology major in my local university then got accepted in my first company right after graduated, working as a mobile application developer. Since then, it is already 7 years I work as a software developer and now I'm a part of a software house startup company.
|
||||
|
||||
I never really write anything in my 7 years journey and I feel kinda regretted it. So I decide to create this blog, where I can write anything I found interesting. Maybe it's a coding-related thing, technology heads up, or maybe just my random thought. Feel free read and share!
|
||||
|
||||
|
||||
# Bonus
|
||||
|
||||
This is a cat from my work, maybe someday she can be a good software tester to find ~~mice~~ bugs from my code.
|
||||
|
||||
  
|
||||
|
|
@ -1,22 +1,32 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>Astro Basics</title>
|
||||
</head>
|
||||
<body>
|
||||
<slot />
|
||||
</body>
|
||||
</html>
|
||||
---
|
||||
import "../styles/global.css";
|
||||
import Footer from "../components/Footer.astro";
|
||||
import Header from "../components/Header.astro";
|
||||
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
interface Props {
|
||||
title: string;
|
||||
description: string;
|
||||
contentClass?: string;
|
||||
}
|
||||
|
||||
const { title, description, contentClass = "" } = Astro.props;
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en" class="[scrollbar-gutter:stable]">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<title>{title}</title>
|
||||
<meta name="description" content={description} />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
</head>
|
||||
<body class="h-screen max-w-5xl mx-auto flex flex-col font-sans">
|
||||
<Header />
|
||||
<div class={`w-full max-w-3xl mx-auto ${contentClass ?? ""}`}>
|
||||
<slot />
|
||||
</div>
|
||||
<Footer />
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
---
|
||||
import Welcome from '../components/Welcome.astro';
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
import Welcome from "../components/Welcome.astro";
|
||||
import Layout from "../layouts/Layout.astro";
|
||||
|
||||
// Welcome to Astro! Wondering what to do next? Check out the Astro documentation at https://docs.astro.build
|
||||
// Don't want to use any of this? Delete everything in this file, the `assets`, `components`, and `layouts` directories, and start fresh.
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<Welcome />
|
||||
<Layout
|
||||
contentClass="flex-1"
|
||||
title="Dhemas Nurjaya"
|
||||
description="Welcome to my personal website"
|
||||
>
|
||||
<Welcome />
|
||||
</Layout>
|
||||
|
|
|
|||
37
src/pages/posts/[slug].astro
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
import { getCollection } from "astro:content";
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
import BlogPost from "../../components/BlogPost.astro";
|
||||
import { render } from "astro:content";
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
|
||||
interface Props {
|
||||
post: CollectionEntry<"blog">;
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getCollection("blog");
|
||||
return posts.map((post) => ({
|
||||
params: { slug: post.id },
|
||||
props: { post },
|
||||
}));
|
||||
}
|
||||
|
||||
const { post } = Astro.props;
|
||||
const renderedPost = await render(post);
|
||||
---
|
||||
|
||||
<Layout
|
||||
contentClass="py-12"
|
||||
title={`${post.data.title} - Dhemas Nurjaya`}
|
||||
description={post.data.description}
|
||||
>
|
||||
<BlogPost
|
||||
title={post.data.title}
|
||||
description={post.data.description}
|
||||
date={post.data.date}
|
||||
tags={post.data.tags}
|
||||
>
|
||||
<renderedPost.Content />
|
||||
</BlogPost>
|
||||
</Layout>
|
||||
31
src/pages/posts/index.astro
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
import { getCollection } from "astro:content";
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
import BlogPostCard from "../../components/BlogPostCard.astro";
|
||||
|
||||
const posts = await getCollection("blog");
|
||||
posts.sort((a, b) => b.data.date.getTime() - a.data.date.getTime());
|
||||
---
|
||||
|
||||
<Layout
|
||||
contentClass="py-12"
|
||||
title="Posts - Dhemas Nurjaya"
|
||||
description="Read the latest blog posts by Dhemas Nurjaya"
|
||||
>
|
||||
<h1 class="text-4xl font-bold mb-8">Posts</h1>
|
||||
<ul class="space-y-4">
|
||||
{
|
||||
posts.map((post) => (
|
||||
<li>
|
||||
<BlogPostCard
|
||||
id={post.id}
|
||||
title={post.data.title}
|
||||
date={post.data.date}
|
||||
description={post.data.description}
|
||||
tags={post.data.tags}
|
||||
/>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</Layout>
|
||||
|
|
@ -1 +1,15 @@
|
|||
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');
|
||||
@import "tailwindcss";
|
||||
@plugin '@tailwindcss/typography';
|
||||
|
||||
@theme {
|
||||
--font-sans: 'Noto Sans', sans-serif;
|
||||
--font-mono: 'JetBrains Mono', monospace;
|
||||
}
|
||||
|
||||
@layer base {
|
||||
body {
|
||||
@apply bg-zinc-900 text-zinc-300;
|
||||
}
|
||||
}
|
||||