Skip to content

Instantly share code, notes, and snippets.

View niyabits's full-sized avatar

niya niyabits

View GitHub Profile
@niyabits
niyabits / html-templ-go-setup.md
Created October 21, 2024 10:10
HTMX, Templ and Go Setup

Setting up HTMX and Templ for Go

Motivation

Sites built with JavaScript frameworks like Next.js are often complicated and rely a lot on JavaScript for even primitive tasks like submitting form, state management, hydration etc.

Modern sites built with React tend to use JavaScript as a holistic language for serving, rendering, and routing in a website. The problem with this approach is that if you have your business logic in a different programming language you need to create more abstractions and APIs to use it within JavaScript or write the business logic in Node.js.

HTMX

HTMX is a small (~14k minified and gzipped), dependency-free JavaScript library, it doesn't care about which language you use for your backend or business logic, which is a great thing, because now we can use our existing business logic code in Go to make a website.

You can use a Go templating language to generate HTML markup and use HTMX to put it in your website.

Templ and Go

window:
padding:
x: 2
y: 2
font:
normal:
family: monospace
style: Regular
@niyabits
niyabits / Atomic Habits Notes.md
Created August 2, 2020 09:29
Atomic Habit Notes

Atomic Habits: Tiny Changes, Remarkable Results - James Clear (Highlight: 53; Note: 0)

───────────────

◆ 1: The Surprising Power of Atomic Habits

▪ Meanwhile, improving by 1 percent isn’t particularly notable—sometimes it isn’t even noticeable—but it can be far more meaningful, especially in the long run.

▪ a slight change in your daily habits can guide your life to a very different destination

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
// Launch Settings
"initialCols": 120,
@niyabits
niyabits / configure-ssh.md
Last active December 23, 2019 08:45
Configure SSH for GitHub

Configure SSH on GitHub

All the commands at one go - (For lazy beings)

ssh-keygen -t rsa -b 4096 -C [email protected] # Generate SSH Key

ls -al ~/.ssh # Verify It

eval "$(ssh-agent -s)" # Max/Linux
@niyabits
niyabits / settings.json
Last active April 7, 2020 12:13
Visual Studio Code Settings
{
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"editor.fontSize": 18,
"terminal.integrated.fontSize": 18,
"editor.wordWrap": "on",
"editor.tabSize": 2,
"prettier.singleQuote": true,
"python.linting.pylintArgs": [
"--load-plugins=pylint_django",
"--errors-only"