Skip to content

Instantly share code, notes, and snippets.

@nileshtrivedi
nileshtrivedi / app.exs
Created June 11, 2025 11:57
single-file todo with ash without auth
Mix.install([
{:ash, "~> 3.0"},
{:phoenix_playground, "== 0.1.6"},
], consolidate_protocols: false)
defmodule Helpdesk do
end
defmodule Helpdesk.Support do
use Ash.Domain, validate_config_inclusion?: false
@nileshtrivedi
nileshtrivedi / todo.exs
Created June 11, 2025 11:16
single-file todo list app with ash framework and elixir
Mix.install([
{:ash, "== 3.5.17"},
{:ash_authentication, "== 4.9.0"},
{:ash_authentication_phoenix, "== 2.8.0"},
{:phoenix_playground, "== 0.1.6"},
{:picosat_elixir, "== 0.2.3"},
{:jason, "== 1.4.4"},
{:bcrypt_elixir, "== 3.3.2"}
], consolidate_protocols: false)
@nileshtrivedi
nileshtrivedi / app.exs
Created December 9, 2024 12:17
Attempt to make a single-file multi-user liveview-based ToDo application
# postgres should be running
# it should have a table called todos
# See Migrations module on how to create the table
# The application can be started with
# JWT_SECRET=6fa91f11ca785e9a73d340ea8d3d03ed SECRET_KEY_BASE=6fa91f11ca785e9a73d340ea8d3d03ed6fa91f11ca785e9a73d340ea8d3d03ed elixir app.exs
# To access the app with authentication, visit this URL that includes the JWT token:
# http://localhost:4000/?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.keYoDT2sQMzTicz_1oqmfduw0HYrwnxc4iwoq9Vr-hQ
# Current issues:
# LiveView's second mount() does not include session data
@nileshtrivedi
nileshtrivedi / create_google_cal_event.js
Created September 8, 2024 15:47
Create Google Calendar event from selected text on web via OpenRouter LLM
// ==UserScript==
// @name Create Google Calendar Event from Selected Text
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Create a Google Calendar event using selected text and current page URL as the description
// @match *://*/*
// @grant GM_openInTab
// @grant GM_registerMenuCommand
// @grant GM_xmlhttpRequest
// ==/UserScript==
@nileshtrivedi
nileshtrivedi / app.ru
Created August 16, 2024 03:29
Single-file Rails app experiment
# frozen_string_literal: true
# Run this app as: puma app.ru
# Most of this was taken from: https://greg.molnar.io/blog/a-single-file-rails-application/
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
@nileshtrivedi
nileshtrivedi / 4chess.py
Created June 9, 2024 06:18
Generating a 4-player chess board SVG using Python
import svgwrite
def create_4player_chess_board():
# Dimensions and colors
margin = 10
square_size = 40
board_size = 14 * square_size + 2*margin
light_color = '#ebecd0'
dark_color = '#739552'
light_extra_color = '#fdfee3'
@nileshtrivedi
nileshtrivedi / README.md
Last active June 18, 2024 08:22
Elixir LiveView Agent Chat Experiment
@nileshtrivedi
nileshtrivedi / README.md
Last active March 1, 2025 08:44
How to set up your own fediverse instance

How to set up your own fediverse instance

FYI, we offer free managed hosting to Indian organizations (media, academia, institutions and non-profit/for-profit companies).

We're sharing our approach here to make it easy for those who want to do it themselves.

What you need

  • A domain name: A typical practice is to use a subdomain. For example, if your org website is at thinktank.com, you can set up your fediverse instance at social.thinktank.com. This will allow your users to have an email address like [email protected] and fediverse address as @[email protected]. It's also possible to run the fediverse instance on your top-level domain (eg: thinktank.com). In this case, both the email address and fediverse address will be [email protected]. But users visiting thinktank.com in the browser will directly land on your fediverse instance which can't be customized as much as a proper website can be.
@nileshtrivedi
nileshtrivedi / README.md
Created December 3, 2022 09:39
Ruby on Rails helpers for Apple M1 for missing libpq or missing libidn
brew install libpq
bundle config build.pg --with-pg-config="$(brew --prefix)/opt/libpq/bin/pg_config"

brew install icu4c
brew install libidn
bundle config build.idn-ruby --with-idn-dir="$(brew --prefix)"
@nileshtrivedi
nileshtrivedi / README.md
Created August 15, 2022 04:22
Self-hosting Tutorial 2022

Why self-host?

Not only does it give you control of your own data, it also enables you to explore the amazing possibilities of computation, free from restricted environments like mobile/tablet/desktop/laptop operating systems. As you increase your technical skills and capabilities, you can then use those to solve problems for your own communities.

What do you need?

Familiarity with English language, willingness to learn, and a credit/debit card.

Steps