Skip to content

Instantly share code, notes, and snippets.

View vunguyentuan's full-sized avatar

Vu Nguyen vunguyentuan

  • 2359 Media
  • Singapore
View GitHub Profile
import { Button } from "components/ui/button";
import { useState } from "react";
import { z } from "zod";
const FormSchema = z.object({
name: z.string().min(1, "Name is required"),
email: z.string().email().min(1, "Email is required"),
});
type FormState = {
@vunguyentuan
vunguyentuan / scheduleNotification.ts
Created December 28, 2021 15:14
Create cloud tasks to send notification
const pages = []
const batchSize = 2000;
let currentIndex = 0;
while (currentIndex < totalUsers) {
pages.push({ fromIndex: currentIndex, toIndex: currentIndex + batchSize });
currentIndex += batchSize;
}
await PromisePool.for(pages)
.withConcurrency(10)
.process(async (page) => {
@vunguyentuan
vunguyentuan / sendNotification.ts
Created December 28, 2021 15:07
Firebase batch send notification
export const sendNotifications = functions
.runWith({
timeoutSeconds: 540,
memory: '1GB',
})
.https.onRequest(async (req, res): Promise<void> => {
const { fromIndex, toIndex } = req.body;
const usersDataResponse = await db.users.orderBy('userIndex').startAt(fromIndex).endAt(toIndex).get();
const userToSendNotifications = usersDataResponse.docs.filter(onlyUserAtTimezone)
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@vunguyentuan
vunguyentuan / machine.js
Created October 18, 2020 12:05
Generated by XState Viz: https://xstate.js.org/viz
const taskMachine = Machine({
id: 'toggle',
initial: 'todo',
context: {
deleted: false,
},
states: {
todo: {
export function getVideoSourceByBrowser(sources) {
const isTaiwan =
getCookiesItem('foxplus_default_locale') &&
getCookiesItem('foxplus_default_locale').country === 'tw'
if (isChrome() || isFirefox()) {
const isTaiwanSource = [
'SCM Clean Mandarin Dash WM',
'Clean Mandarin Dash WM',
'Burnt-In Mandarin Dash WM'
@vunguyentuan
vunguyentuan / 00_nginx.config
Created April 20, 2018 08:16 — forked from devops-1/00_nginx.config
00_nginx.config
container_commands:
01-nginx:
command: /opt/elasticbeanstalk/hooks/configdeploy/enact/35_nginx.sh
files:
"/home/ec2-user/nginx.conf":
mode: "000644"
owner: root
group: root
content : |
@vunguyentuan
vunguyentuan / dabblet.css
Last active April 20, 2018 07:58 — forked from csssecrets/dabblet.css
Custom underlines
/**
* Custom underlines
*/
body {
font: 250%/1.6 Baskerville, Palatino, serif;
text-align: center;
}
a {
<Tab defaultActiveIndex={1}>
<div>
<h2>header title</h2>
<TabHeader>
<TabHeaderItem>
<button>Header 1</button>
</TabHeaderItem>
<TabHeaderItem>
<button>Header 2</button>
</TabHeaderItem>
<Tab
defaultActiveIndex={1}
>
<TabHeader>
<TabHeaderItem disable>
header 1
icon
</TabHeaderItem>
<TabHeaderItem>
header 2