Skip to content

Instantly share code, notes, and snippets.

View deleteman's full-sized avatar

Fernando Doglio deleteman

View GitHub Profile
function getCookie(name) {
const nameEQ = name + "=";
const ca = document.cookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function setCookie(name, value, days) {
let expires = "";
if (days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
import React, { useState } from 'react';
import Sentiment from 'sentiment';
import 'bootstrap/dist/css/bootstrap.min.css';
const sentiment = new Sentiment();
function TodoApp() {
const [todos, setTodos] = useState([]);
const [input, setInput] = useState('');
function addNumbers(numbers) {
let sum = 0;
for (let i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
return sum;
}
let numbers = [1, 2, 3, 4, 5];
console.log(addNumbers(numbers)); // Output: 15
`Write an informal email to ${destination}, ${topic}, my name is ${name}`
`Write an email to ${destination}, ${topic}, make sure they understand it's important and that my name is ${name}`
`Write a corporate-sounding email to ${destination}, ${topic}, my name is ${name}`
`Write a formal email to my boss, ${destination}, about ${topic}, and sign it as ${name}`
const { Configuration, OpenAIApi } = require("openai");
require('dotenv').config()
const readline = require('node:readline/promises').createInterface({
input: process.stdin,
output: process.stdout
});
const configuration = new Configuration({
async function getActivity() {
let result = await fetch("https://www.boredapi.com/api/activity?type=recreational")
const obj = await result.json()
return { activity: obj.activity }
}
export default async function Bored () {
let activity = await getActivity();
<script >
import { getVersionFromURL } from "~/util";
//code to update the links inside the documents to make sure they link to the right
//version
let links = document.getElementsByTagName("a")
let version = getVersionFromURL(window.location.href)
const host = import.meta.env.PUBLIC_SITE_URL ? import.meta.env.PUBLIC_SITE_URL : ""
let urlParts = ["docs"]
---
const VERSIONS = [
{title: "2.6.0", url: "/v2.6.0"},
{title: "2.7.0", url: "/v2.7.0"},
{title: "3.0.0", url: "/v3.0.0"},
{title: "3.1.1", url: ""}
]
---