Skip to content

Instantly share code, notes, and snippets.

View waptik's full-sized avatar
💻
Learning JavaScript and ReactJS...

Stephane Mensah waptik

💻
Learning JavaScript and ReactJS...
View GitHub Profile
@nimeshkasun
nimeshkasun / OpenAI-into-Spreadsheets.js
Last active December 27, 2023 22:48
This scripts allows to integrate OpenAI GPT-3 into Google Spreadsheets.
const SECRET_KEY = "ENTER YOUR SECRET KEY HERE TAKEN FROM OPEN_AI";
// Follow on LinkedIn: https://www.linkedin.com/in/nimeshkasun
/**
* Completes your prompt with GPT-3
*
* @param {string} prompt Your prompt for OpenAI
* @param {number} precision (Optional) Precision. 1 is super creative while 0 is very exact and precise. Defaults to 0.4.
* @param {string} model (Optional) GPT-3 Model to use. Defaults to "text-ada-001".
const SECRET_KEY = ENTER YOUR SECRET KEY HERE;
const MAX_TOKENS = 200;
// For more cool AI snippets and demos, follow me on Twitter: https://twitter.com/_abi_
/**
* Completes your prompt with GPT-3
*
* @param {string} prompt Prompt
* @param {number} temperature (Optional) Temperature. 1 is super creative while 0 is very exact and precise. Defaults to 0.4.
@stonking
stonking / cf-worker-email.md
Created May 13, 2022 19:31
Send email from Cloudflare Workers via MailChannels

Send email from Cloudflare Workers via MailChannels

Cloudflare announced a partnership with MailChannels that allows you to send free email via workers.

The example code that MailChannels supplied wasn't working so I fixed it here to make testing easy.

  1. Add include:relay.mailchannels.net to your domain's SPF record.
  2. Update the code below with your email addresses
  3. Create worker, paste code, save and deploy and test
@Evavic44
Evavic44 / Buymeacoffee.md
Last active January 19, 2024 18:53
Buymeacoffee widget React
import React, { useEffect } from "react";

export default function Buymeacoffee() {
	useEffect(() => {
		const script = document.createElement("script");
		const div = document.getElementById("supportByBMC");
		script.setAttribute("data-name", "BMC-Widget");
		script.src = "https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js";
		script.setAttribute("data-id", "evavic44");
@lzjluzijie
lzjluzijie / how-to.md
Last active July 28, 2023 04:36
Access Private BackBlaze B2 Bucket from Cloudflare Transform Rules

Access Private BackBlaze B2 Bucket from Cloudflare Transform Rules

Original post from my Blog.

Cloudflare now offers free Transform Rules, so BackBlaze B2 users can use URL Rewrite rules to hide bucket name and provide access to private bucket.

TLDR: Create a URL Rewrite Rule and hide your bucket name. If your bucket is private, you also need to create a Cloudflare Worker, copy the code and fill in the config.

Hide Bucket Name

@timfish
timfish / README.md
Last active January 30, 2024 18:43
Sentry Cloudflare Workers Proxy - Makes JavaScript and event submission first-party!
  • Add the worker.js code to a new Cloudflare Worker
  • Set up a worker for your domain than responds to /tunnel/* and point it to your new worker
  • Add the Sentry script to your html but replace https://browser.sentry-cdn.com/ with ./tunnel/
    • Eg. <script src="./tunnel/6.9.0/bundle.min.js"></script>
  • init Sentry with the tunnel option set to /tunnel/
    • Eg. Sentry.init({ dsn: "__DSN__", tunnel: "/tunnel/" })
  • Rejoice at how everything now works with ad blockers
<?
//
// AUTO KEYWORD-BASED FOLLOWER CURATION BOT (by @levelsio)
//
// File: twitterFollowerCuratorBot.php
//
// Created: May 2021
// License: MIT
//
@steveruizok
steveruizok / getRelativeTransformedBoundingBox.ts
Last active June 20, 2021 17:07
Transform a rotated bounding box.
export function getRelativeTransformedBoundingBox(
bounds: Bounds,
initialBounds: Bounds,
initialShapeBounds: Bounds,
isFlippedX: boolean,
isFlippedY: boolean
) {
const minX =
bounds.minX +
@Sqvall
Sqvall / file-upload.tsx
Last active June 11, 2023 05:35
File Upload with Chakra UI and react-hook-form
import { ReactNode, useRef } from 'react'
import { Button, FormControl, FormErrorMessage, FormLabel, Icon, InputGroup } from '@chakra-ui/react'
import { useForm, UseFormRegisterReturn } from 'react-hook-form'
import { FiFile } from 'react-icons/fi'
type FileUploadProps = {
register: UseFormRegisterReturn
accept?: string
multiple?: boolean
children?: ReactNode
@csandman
csandman / README.md
Last active October 11, 2023 10:23
Chakra UI React Select

Chakra React Select

UPDATE: I finally made an NPM package for this component! It is made with TypeScript, and now has a fully customizable styling system. It is also far ahead of this wrapper at this point. Check it out here if you'd like: https://github.com/csandman/chakra-react-select

In order to use this component, you can implement it and use it like you would normally use react-select. It should accept all of the props that the original takes, however customizing the theme or the components could break this implementation. There are also a few extra things you can do with this wrapper that pull from the chakra library.

  • You can pass the size prop with either sm, md, or lg. These will reflect the sizes available on the Chakra <Input /> component (with the exception of xs because it's too small to work).
  • In your options objects, you can add the key isFixed to emulate the exa