Skip to content

Instantly share code, notes, and snippets.

View wzulfikar's full-sized avatar
💭
Set status

Wildan Zulfikar wzulfikar

💭
Set status
View GitHub Profile
@wzulfikar
wzulfikar / notes.md
Last active November 2, 2022 18:24
Notes

Hello world! 🌎

I write notes in this gist as comments. My original goal was to have a workflow where I can't have an excuse to not write. No websites to manage, no codes to push, no styles to update. Just write. I found Github gist fitting and I don't have issues with writing markdown.

This gist contains "problem-based", technical notes. I encounter a problem, I "google" the solution, I document the solution. Hopefully, I can accumulate the learning and don't have to google again when I encounter the same problem.

Besides problem-based, I also write my "TIL" notes here. They are the new things I learnt that often gave me that "nice" feeling when I first found about it.

There are other things I write like electronics, observations, etc. which I put in different gists. If you want to check it, here's the "sitemap" of all my notes:

@wzulfikar
wzulfikar / mermaid_test.md
Last active September 15, 2022 18:06
Mermaid: Test mermaid diagram in gist.
@wzulfikar
wzulfikar / lexorank-example.ts
Last active August 30, 2022 01:25
Lexorank example in TS
import sortBy from "lodash/sortBy"; // https://github.com/kvandake/lexorank-ts
import { LexoRank } from "lexorank";
const cards = [
{ id: 1, rank: "", flag: "0" }, // flag 0: first card, flag 1: last card. We use flag so we don't have to recalculate first and last card.
{ id: 2, rank: "", flag: "" },
{ id: 3, rank: "", flag: "1" },
];
function parseRank(rank: string) {
@wzulfikar
wzulfikar / pull_request_template.md
Last active October 12, 2022 18:30
PR Template

🚧 Work in progress

What

What does this PR change, add, or delete?

Why

Why is this PR needed?

Screenshots

| Before | After |

@wzulfikar
wzulfikar / greeting.ts
Created August 20, 2022 21:44
DEV.to Post: Typing for Next.js API - pages/api
import { ApiHandler, handle, z } from "@backend";
const schema = z.object({
query: z.object({
name: z.string(),
}),
});
export const response = z.object({
greeting: z.string(),
@wzulfikar
wzulfikar / handler.ts
Last active August 20, 2022 21:02
DEV.to Post: Typing for Next.js API
import { captureException } from '@sentry/nextjs';
import { StatusCodes } from 'http-status-codes';
import { NextApiRequest } from 'next';
import { z } from 'zod';
import { NextApiResponseWithData } from '.';
import { validateSchema } from './validateSchema';
type RootOptions = {
schema?: z.SomeZodObject;
@wzulfikar
wzulfikar / tira.txt
Created August 12, 2022 09:24
Hello Tira
Hello world from Tira!
@wzulfikar
wzulfikar / active_record_sqlite.rb
Last active May 25, 2022 13:52
Example of using active record without Rails
# Run `gem install active_record sqlite3` to install the dependencies
ENV['DATABASE_URL'] = 'sqlite3:/tmp/sqlite.test' # Change this to anything you want
require 'sqlite3' # Make sure to require the correct adapter for your `DATABASE_URL`
require 'active_record'
ActiveRecord::Base.establish_connection
ActiveRecord::Schema.define do
@wzulfikar
wzulfikar / run.sh
Last active December 4, 2020 08:45
Setup wordpress using docker. Tested on Ubuntu.
#!/bin/sh
# File: /opt/wordpress/run.sh
APP_NAME=acme-blog
WORKDIR=/opt/wordpress
if [ ! -f "uploads.ini" ]; then
touch ${WORKDIR}/uploads.ini
fi
@wzulfikar
wzulfikar / run.sh
Last active December 4, 2020 08:44
Setup nginx with letsencrypt automatic https using docker. Tested on Ubuntu.
#!/bin/sh
# File: /opt/nginx-proxy/run.sh
# If you are on ubuntu and have docker installed, you can automate the setup by running below command.
# Make sure to adjust the DEFAULT_EMAIL and WORKDIR according to your need. The command:
: '
export DEFAULT_EMAIL=myemail@mydomain.com WORKDIR=/opt/nginx-proxy && \
sudo mkdir ${WORKDIR} && \
curl -o /tmp/nginx-proxy.sh https://gist.githubusercontent.com/wzulfikar/957917c8ad84a6047bdb0831215daa51/raw/cf7acfe4fecbcd2cd9acf83ef0382cfc03fbbc63/run.sh && \