This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Form Validation</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Load Bootstrap's CSS --> | |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> <!-- Our stylesheet --> | |
<!-- Bootstrap Icons --> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.2/font/bootstrap-icons.min.css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets JSON citation data from the CrossRef API for a DOI or DOI URL | |
* @param doi A DOI or DOI URL | |
*/ | |
export async function doi2json(doiOrUrl: string) { | |
// Extract the DOI from the URL | |
const doi = doiOrUrl.replace('https://doi.org/', ''); | |
// Fetch data from the CrossRef API | |
const response = await fetch(`https://api.crossref.org/works/${doi}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const name = "runJS"; | |
export const description = "Runs arbitrary JavaScript code in a browser context (no node.js)"; | |
export const parameters = { | |
type: "object", | |
properties: { | |
"code": { | |
type: "string", | |
description: "JavaScript code to run in browser", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example Function Module. Each function needs you to define 4 things: | |
*/ | |
/* 1. Name of your function */ | |
export const name = "sum"; | |
/* 2. Description of function, used to describe what it does to an LLM */ | |
export const description = "Adds all numbers passed to it, returning the total."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_NeoPixel.h> | |
#include <HTTPClient.h> | |
#include <WiFi.h> | |
// Define a pixel strip of 1 pixel | |
Adafruit_NeoPixel pixels(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800); | |
// Wifi | |
char ssid[] = "..."; | |
char password[] = "..."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Elastic } = require(...) | |
const { mock } = Elastic(); | |
beforeEach(() => mock.clearAll()) | |
test('..', async () => { | |
mock.add('.....'); | |
await request.get('/serach?...') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
import ClickCounter from './ClickCounter'; | |
import ClickHeading from './ClickHeading'; | |
function App() { | |
// State: held by the parent | |
const [numClicks, setNumClicks] = useState(0); | |
const onClickHandler = (e) => setNumClicks(numClicks + 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require("mongoose"); | |
const Schema = mongoose.Schema; | |
const restaurantSchema = new Schema({ | |
address: { | |
building: String, | |
coord: [Number], | |
street: String, | |
zipcode: String | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple module that uses fetch to do a HEAD request | |
const fetch = require('node-fetch'); | |
module.exports.fn = async (url) => { | |
try { | |
const response = await fetch(url, { method: "HEAD" }); | |
return response.ok; | |
} catch(err) { | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use it like this | |
import usePageLifecycle from './lib/use-page-lifecycle'; | |
App() { | |
const isVisible = usePageLifecycle(); | |
} |
NewerOlder