Skip to content

Instantly share code, notes, and snippets.

View kenny-io's full-sized avatar
😀
Always available

Ekene Eze kenny-io

😀
Always available
View GitHub Profile
export default async (event, context) => {
return new Response(JSON.stringify({ message: 'Hello World' }), {
headers: {
'content-type': 'application/json',
'Netlify-Cache-ID': 'productID-1,products'// Set your custom cache IDs here
}
});
};
import { lazy, Suspense } from 'react';
const ProductDetails = lazy(() => import('./ProductDetails'));
function ProductListing({ products }) {
return (
<Suspense fallback={<div>Loading...</div>}>
<ul>
{products.map((product) => (
<li key={product.id}>
import React, { useState, useEffect } from 'react';
const ImageLoader = ({ src, alt, placeholder }) => {
const [imageSrc, setImageSrc] = useState(placeholder || src);
useEffect(() => {
const img = new Image();
img.src = src;
img.onload = () => setImageSrc(src);
}, [src]);
export default async (req) => {
const { next_run } = await req.json()
// Fetch the latest blog posts
const response = await fetch(`https://mysite.com/api/blog-posts`);
const blogPosts = await response.json();
// Compile email content
for (const blogPost of blogPosts) {
emailContent += `
<h2>${blogPost.title}</h2>
@kenny-io
kenny-io / search.sql
Created January 8, 2024 21:07
vector-search sql
-- Supabase AI is experimental and may produce incorrect answers
-- Always verify the output before executing
create
or replace function vector_search (
query_embedding vector (1536),
similarity_threshold float,
match_count int
) returns table (
@kenny-io
kenny-io / celebrities.json
Created January 8, 2024 21:04
Celebrities data
[
{
first_name: 'Elon',
last_name: 'Musk',
image:
'https://c4.wallpaperflare.com/wallpaper/1012/124/930/men-elon-musk-wallpaper-preview.jpg',
age: 50,
email: 'elon.musk@example.com',
address: {
street: 'SpaceX Blvd',
import { builder } from '@netlify/functions';
import { fetch } from 'node-fetch';
async function handler(event, context) {
// Get the product ID from URL path
const segments = event.path.split('/');
const productId = segments[segments.length - 1];
// Fetch the product price from the API
const response = await fetch(`https://api.example.com/products/${productId}`);
const price = await response.json();
// Generate the pricing table
import { builder } from "@netlify/functions";
const myHandler = async (event, context) => {
const segments = event.path.split('/');
const name = segments[segments.length - 1];
console.log(name);
const greeting = name ? `Hello ${name}` : 'Hello World';
const state = {
currentPage: window.location.pathname,
search: {
term: '',
type: '',
page: 1,
totalPages: 1,
totalResults: 0,
},
api: {
.container {
font-family: "Poppins", sans-serif;
display: flex;
padding: 2rem 5rem;
align-items: center;
justify-content: space-between;
@media screen and (max-width: 1000px) {
padding: 2rem 3rem;
}