Skip to content

Instantly share code, notes, and snippets.

View charlesteh's full-sized avatar

Charles Teh charlesteh

View GitHub Profile
@charlesteh
charlesteh / stripe_amount_helpers.php
Created December 7, 2023 13:58
Stripe amount to standard Currency + Amount and vice-versa
<?php
// This function converts a normal currency amount to a Stripe-compatible amount.
// To be used on creating Stripe Checkout Stations
// e.g. USD 10.00 to 1000
if (! function_exists('convert_normal_to_stripe_amount')) {
function convert_normal_to_stripe_amount($currency, $amount)
{
$stripe_amount = $amount;
@charlesteh
charlesteh / cf-workers-ai-bge-small.js
Last active May 11, 2024 22:45
Cloudflare Workers AI baai/bge-small deployment script
// Made by @charlestehio: https://x.com/charlestehio
// Usage: https://abc.workers.dev/?query=your%20embedding%20query
import { Ai } from './vendor/@cloudflare/ai.js';
export default {
async fetch(request, env) {
// Parse the URL to get query parameters
const url = new URL(request.url);
var query = url.searchParams.get('query');