Skip to content

Instantly share code, notes, and snippets.

View mjbalcueva's full-sized avatar

Mark John Balcueva mjbalcueva

  • University of Sto. Tomas - Legazpi
  • Albay, Philippines
  • X @mj_balcueva
View GitHub Profile
@mjbalcueva
mjbalcueva / Server-Side Conditional Rendering.md
Last active July 20, 2024 12:47
Server-Side Device-Based Conditional Rendering in Next.js

Server-Side Device-Based Conditional Rendering in Next.js

Problem

You want to conditionally render components on the server side based on the device type (mobile, tablet, desktop). The goal is to avoid rendering all components server-side and hiding them with CSS, and to prevent client-side JavaScript from causing a flash of content as it loads.

Solution

Create a hook that determines the device type based on window size and stores it in a cookie. Use this context to conditionally render components according to the device type.

@mjbalcueva
mjbalcueva / password-input.tsx
Last active July 16, 2024 14:48
shadcn ui custom password input
"use client"
import { forwardRef, useState } from "react"
import { EyeIcon, EyeOffIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Input, InputProps } from "@/components/ui/input"
import { cn } from "@/lib/utils"
const PasswordInput = forwardRef<HTMLInputElement, InputProps>(
({ className, ...props }, ref) => {
@mjbalcueva
mjbalcueva / BinarySearchTree.java
Last active October 14, 2023 13:09
A collection of programming challenges
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class BinarySearchTree {
Scanner console = new Scanner(System.in);
Node root;
public static void main(String[] args) throws Exception {
BinarySearchTree program = new BinarySearchTree();
@mjbalcueva
mjbalcueva / OmekaClassic.md
Created August 27, 2023 18:57
Omeka Classic Installation Guide for Debian Based Distros

Omeka Classic Installation Guide (Ubuntu 22.04.3)

Installation Prerequisites

  1. Download virtualbox
  2. Download ubuntu

Virtual Machine (Ubuntu) Setup

  1. Launch VirtualBox and create a new virtual machine instance using the downloaded Ubuntu ISO.
# Get editor completions based on the config schema
"$schema" = 'https://starship.rs/config-schema.json'
# ---------------------------------------------------------------------------------------------------------------------
format = """
[](#9A348E)\
$os\
$hostname\
[](bg:#DA627D fg:#9A348E)\
@mjbalcueva
mjbalcueva / calendar.tsx
Last active July 17, 2024 07:26
shadcn ui calendar custom year and month dropdown
"use client"
import * as React from "react"
import { buttonVariants } from "@/components/ui/button"
import { ScrollArea } from "@/components/ui/scroll-area"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { cn } from "@/lib/utils"
import { ChevronLeft, ChevronRight } from "lucide-react"
import { DayPicker, DropdownProps } from "react-day-picker"
@mjbalcueva
mjbalcueva / ohmyposhv3-v2.json
Last active August 19, 2022 23:31
Terminal Config
{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,