Skip to content

Instantly share code, notes, and snippets.

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

TheVirginBrokey waptik

💻
Learning JavaScript and ReactJS...
View GitHub Profile
@TheThirdRace
TheThirdRace / Image.tsx
Last active February 6, 2024 15:20
Image component: merge Chakra-ui `2.8.0` with NextJs `13.4.13` and remove most pain points
/**
* # `<Image>`
*
* This component is a merge between `next/image` and `Chakra-ui`.
* - last updated on 2023-08-08 with `next/image` 13.4.13 and `chakra-ui/react` 2.8.0
* - https://github.com/vercel/next.js/blob/v13.4.13/packages/next/src/client/image-component.tsx
* - https://github.com/vercel/next.js/blob/canary/packages/next/src/client/image-component.tsx
* - https://github.com/vercel/next.js/commits/canary/packages/next/src/client/image-component.tsx
* - https://github.com/vercel/next.js/compare/v13.4.4...canary
*
@1isten
1isten / compress-base64-imgs.js
Last active June 16, 2024 18:48
js compress image (base64) using canvas api
const toBase64 = (file) => new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = (e) => resolve(e.target.result);
reader.onerror = (err) => reject(err);
});
const compressBase64 = (src, quality = 0.5) => new Promise((resolve) => {
const img = new Image();
img.src = src;
@beaucarnes
beaucarnes / keep_alive.py
Created December 10, 2020 15:42
Python Server for Discord Bot
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return "Hello. I am alive!"
def run():
<?
# MIT license, do whatever you want with it
#
# This is my invoice.php page which I use to make invoices that customers want,
# with their address on it and which are easily printable. I love Stripe but
# their invoices and receipts were too wild for my customers on Remote OK
#
require_once(__DIR__.'/../vendor/autoload.php');
// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// by @levelsio
// HOW TO
// 1) Make a Google Sheet, we'll pull the first cell e.g. A1
// 2) Publish your Google Sheet, File -> Publish To Web
// 3) Copy the SHEET_ID in the URL, put it in here below:
const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"
// 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
// 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)
@s-kris
s-kris / fauna-adapter.js
Last active September 14, 2024 01:22
faunadb adapter for next-auth for next.js
// followed from next-auth repo: https://github.com/nextauthjs/next-auth
// create faunadb server key
// create collections: users, accounts, sessions, verificationRequests
// create required indexes
import faunadb, { query as q } from 'faunadb';
import { v4 as uuidv4 } from 'uuid';
import { createHash, randomBytes } from 'crypto';
const got = require('got');
exports.handler = function(context, event, callback) {
let message = "";
let twiml = new Twilio.twiml.MessagingResponse();
const prompt = event.Body !== undefined ? event.Body.trim() : event["prompt"]
got.post('https://api.openai.com/v1/engines/davinci/completions', {
json: {
"prompt": prompt,
@flybayer
flybayer / Link.tsx
Last active July 1, 2021 07:40
Much nicer and more intuitive Next.js Link abstraction
@domitriusclark
domitriusclark / useSearch.js
Created June 25, 2020 14:47
useSearch describes a way to handle piping options to a serverless endpoint that actually handles the search
import { useMutation } from 'react-query';
import fetch from 'isomorphic-unfetch';
export default function useSearch({ endpoint } = {}) {
if (!endpoint) {
throw new Error("Must provide an endpoint to search");
}
let expressionConfig = "";
@manuelbieh
manuelbieh / README.md
Last active November 18, 2024 15:12
Deno File Download

Use Deno to download files from the internet.

Usage

deno run --allow-net --allow-write download.ts [url] [filename]

Example