Skip to content

Instantly share code, notes, and snippets.

View ChenCodes's full-sized avatar
:electron:
writing that react code

Jack Chen ChenCodes

:electron:
writing that react code
  • East Palo Alto, CA
View GitHub Profile
@ChenCodes
ChenCodes / common-react-script-with-stubs
Created January 14, 2025 22:31
This script represents the shared logic between the three other scripts. Stubs are used in places where the LLM needs to fill in the information.
import React from "react";
import { <stub> } from "react-chartjs-2";
import "chart.js/auto";
const data = <stub>;
const Dashboard = () => {
// Prepare data for the chart
const chartData = {
labels: <stub>,
@ChenCodes
ChenCodes / react-script-stacked-bar-chart-of-human-to-ai-messages-for-the-last-two-weeks
Created January 14, 2025 22:24
stacked bar chart of HUMAN_TO_AI and AI_TO_HUMAN messages for the last 2 weeks
import React from "react";
import { Bar } from "react-chartjs-2";
import "chart.js/auto";
const data = [
{ WEEK_START: "2024-12-30", TYPE: "AI_TO_HUMAN", TOTAL_MESSAGES: 5055261 },
{ WEEK_START: "2024-12-30", TYPE: "HUMAN_TO_AI", TOTAL_MESSAGES: 5000859 },
{ WEEK_START: "2025-01-06", TYPE: "AI_TO_HUMAN", TOTAL_MESSAGES: 6102716 },
{ WEEK_START: "2025-01-06", TYPE: "HUMAN_TO_AI", TOTAL_MESSAGES: 6048182 },
{ WEEK_START: "2025-01-13", TYPE: "AI_TO_HUMAN", TOTAL_MESSAGES: 1256256 },
@ChenCodes
ChenCodes / react-script-weekly-messages-last-12-weeks
Created January 14, 2025 22:21
React script that represents the weekly messages for the last 12 weeks
import React from "react";
import { Line } from "react-chartjs-2";
import "chart.js/auto";
const data = [
{ WEEK_START: "2024-10-21", TOTAL_MESSAGES: 14369219 },
{ WEEK_START: "2024-10-28", TOTAL_MESSAGES: 16087327 },
{ WEEK_START: "2024-11-04", TOTAL_MESSAGES: 16607384 },
{ WEEK_START: "2024-11-11", TOTAL_MESSAGES: 15846486 },
{ WEEK_START: "2024-11-18", TOTAL_MESSAGES: 15901369 },
@ChenCodes
ChenCodes / react-script-dau-last-seven-days
Created January 14, 2025 22:17
react script that represents the DAU for the last 7 days
import React from "react";
import { Line } from "react-chartjs-2";
import "chart.js/auto";
const data = [
{ DATE: "2025-01-07", DAILY_ACTIVE_USERS: 13311 },
{ DATE: "2025-01-08", DAILY_ACTIVE_USERS: 13423 },
{ DATE: "2025-01-09", DAILY_ACTIVE_USERS: 12361 },
{ DATE: "2025-01-10", DAILY_ACTIVE_USERS: 12165 },
{ DATE: "2025-01-11", DAILY_ACTIVE_USERS: 13206 },
@ChenCodes
ChenCodes / sendgrid-modules.md
Last active May 2, 2024 18:47
jelled sendgrid code modules

Social icons:

<div style="
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center"
>
    <a href="https://twitter.com/jelledio">
/*Algorithm spec:
Given a long list of numbers:
let numbers = 1...1000000
Write a function that transforms the list of numbers to strings with the following mapping and put it into a variable called results.
1->A, 2->B, 3->C ... 10->A0, 11->AA, 12->AB etc.
With the results from the last part, write a function that adds the following elements.
@ChenCodes
ChenCodes / SumAll.swift
Last active June 1, 2017 21:18
Sum All parameters (can be of different type)
func sumAll(objs: Any...) -> Int {
var sum = 0
for obj in objs {
if obj is Int {
sum += obj as! Int
} else if obj is String {
if let variable = Int(obj as! String) {
sum += variable
}
}
@ChenCodes
ChenCodes / Swap.swift
Last active June 1, 2017 18:41
Swap Function that swaps the values of two variables of any type
//When it says Any type, this means that we're dealing with generics
func swap<G>(item_1: inout G, item_2: inout G) {
let temp = item_1
item_1 = item_2
item_2 = temp
}
var one = "1"
var two = "2"
let events: [String] = ["7:00 AM Hit the gym with Alex", "8:30 AM Coffee with Sarah", "11:00 AM Team Meeting", "3:30 PM Budget review"]
// Do any additional setup after loading the view, typically from a nib.
let offset = 20
var counter = 0
for value in events {
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 300, height: 21))
func minimumMaximum<T: Comparable>(_ array: [T]) -> (minimum: T, maximum: T)? {
var array = array
guard !array.isEmpty else {
return nil
}
var minimum = array.first!
var maximum = array.first!
let hasOddNumberOfItems = array.count % 2 != 0