Skip to content

Instantly share code, notes, and snippets.

View bryanprimus's full-sized avatar
🏠
Working from home

Bryan Lumbantobing bryanprimus

🏠
Working from home
View GitHub Profile
@bryanprimus
bryanprimus / answer.md
Created April 13, 2025 16:57
Part 4: Bonus Firebase technical questions

Part 4: Firebase Technical Challenges

Question 1: Creating a Smart User Ranking System in Firestore

The traditional approach of simply chaining .orderBy() methods won't create a true multi-factor ranking system for our potential users. We need a more sophisticated solution that truly balances all three factors.

Here's my approach using a composite scoring method:

@bryanprimus
bryanprimus / .zshrc
Created March 28, 2025 06:17
gclb alias to clean git local branches and keep `development` as the only branch left
unalias gclb 2>/dev/null
gclb() {
git checkout development || return
local branches
branches=$(git branch --format="%(refname:short)" | grep -Fxv "development")
if [ -z "$branches" ]; then
echo $'\033[0;32mNo branches to be deleted.\033[0m'
return
fi
@bryanprimus
bryanprimus / withMoEngagePlugin.js
Last active April 28, 2024 12:27
expo config plugin for react-native-moengage. tested in v8.5.3
const {
withAppDelegate,
withInfoPlist,
withEntitlementsPlist,
withAppBuildGradle,
withMainApplication,
withStringsXml,
AndroidConfig,
} = require('@expo/config-plugins');
const { mergeContents } = require('@expo/config-plugins/build/utils/generateCode');
@bryanprimus
bryanprimus / package.json
Created April 16, 2024 10:08
Changing Expo Router Entry Point
{
"main": "index.tsx",
}
@bryanprimus
bryanprimus / extend-tamagui-themes-with-color.tsx
Created April 10, 2024 14:58
add new color to tamagui themes, the first commit is the original, check revision for extended one
import {
blue,
blueDark,
gray,
grayDark,
green,
greenDark,
orange,
orangeDark,
pink,
@bryanprimus
bryanprimus / viewModelZustand.tsx
Last active November 4, 2024 01:41
ViewModelProvider with zustand and react context
import { createContext, useContext, useRef } from 'react'
import { Button, Text } from 'tamagui'
import { createStore, useStore, type StateCreator, type StoreApi } from 'zustand'
const ViewModelContext = createContext<StoreApi<any> | null>(null)
const ViewModelProvider = <T,>({
children,
initializer,
}: React.PropsWithChildren<{ initializer: StateCreator<T> }>) => {
@bryanprimus
bryanprimus / scrollview-non-fixed-header.tsx
Created April 5, 2024 15:32
Scrollview with non fixed header
import { useState } from 'react'
import Animated, {
Extrapolation,
interpolate,
useAnimatedScrollHandler,
useAnimatedStyle,
useSharedValue,
} from 'react-native-reanimated'
import { Card, Text, View } from 'tamagui'
import React from "react";
import { useForm, FormProvider } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
const baseRincianNilaiSchema = z
.object({
name: z.string(),
persenan: z.string(),
child: z.array(z.any()).optional(), // Fine-tune this as needed
@bryanprimus
bryanprimus / country-locale.ts
Last active February 7, 2024 09:25
Country name for libphonenumber-js
import { CountryCode } from 'libphonenumber-js';
import { AppLocale } from './i18n';
export const countriesWithLocale: Record<AppLocale, Record<CountryCode, string>> = {
en: {
AC: 'Ascension Island',
AD: 'Andorra',
AE: 'United Arab Emirates',
AF: 'Afghanistan',
@bryanprimus
bryanprimus / FormatCurrencyForTextInput.ts
Created February 4, 2024 07:19
Currency Formatter for TextInput
enum Currency {
IDR = "IDR",
USD = "USD",
}
const separator: Record<Currency, string> = {
IDR: ".",
USD: ",",
};