Skip to content

Instantly share code, notes, and snippets.

View nirkaufman's full-sized avatar
🎯
Focusing

Nir Kaufman nirkaufman

🎯
Focusing
View GitHub Profile

1) Create an OpenAI API key

  1. Sign in at platform.openai.comSettingsAPI keys.
  2. Click Create new secret key → copy it and store securely (you can set key permissions if needed). ([platform.openai.com][1])

2) Preload $5 credit (prepaid billing)

  1. Go to Settings → Billing → Overview.
  2. Click Add payment details and add a standard credit/debit card.
  3. Choose $5 as the initial credit purchase → Confirm. (Minimum prepaid purchase is $5.) ([OpenAI Help Center][2])
'use client'
import { useState, useRef, useEffect, FormEvent } from 'react'
import {streamChat, streamChatWithPromptTemplate} from "@/server/chat-action";
type Message = {
id: string
role: 'user' | 'ai'
content: string
}

Generative UI

Step 1 - New Project Setup

  1. craete new nextjs project with tailwind as your CSS framework
    npx create-next-app@latest

Personal Blog Project (React) - Part 1

Introduction

You are going to create a personal blog using React. You will be practicing the following concepts:

  • create React project.
  • create React components.
  • JS import/export.
  • Breaking down the UI into components.
import './App.css';
import {Header} from "./components/Header";
import {Main} from "./components/Main";
import {Footer} from "./components/Footer";
function App() {
const appTitle = 'TodosApp';
const todos = [
{title: 'Learn React', completed: false},
import {PreloadingStrategy, Route} from "@angular/router";
import {Observable, of} from "rxjs";
import {Injectable} from "@angular/core";
/**
* Starting point for a CustomPreloading class from our live session!
* You can (and should) customize it further more to meet your needs
*/
@Injectable({providedIn: 'root'})
import { Component, ViewEncapsulation } from '@angular/core';
import { NgxBlocklyConfig, NgxBlocklyGenerator } from 'ngx-blockly';
@Component({
selector: 'app-root',
template: `
<h1>Demo</h1>
<ngx-blockly [config]="config" (javascriptCode)="onCode($event)"></ngx-blockly>
`,
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgxBlocklyModule } from 'ngx-blockly';
import "blockly/blocks";
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
import Reconciler from "react-reconciler";
const hostConfig = {
supportsMutation: true,
supportsPersistence: false,
noTimeout: -1,
isPrimaryRenderer: true,
supportsHydration: false,
createInstance(type, props, rootContainer, hostContext, internalHandle) {
/*******************
warm up
*******************/
function* generateAlphaBet() {
let i = "a".charCodeAt(0);
let end = "z".charCodeAt(0) + 1;
while(i < end) {
yield String.fromCharCode(i);