Skip to content

Instantly share code, notes, and snippets.

View mulhoon's full-sized avatar
💻
building withcabin.com

Nic Mulvaney mulhoon

💻
building withcabin.com
View GitHub Profile
@mulhoon
mulhoon / last-modified-demo-server.js
Last active December 28, 2022 12:23
Counting unique visitors and bounces without cookies.
const express = require('express')
const app = express()
app.get('/ping', (req, res) => {
const now = Date.now(),
day = 8.64e7
// calculate midnight today and tomorrow
const midnight = Math.floor(now / day) * day
const midnightDate = new Date(midnight)
@mulhoon
mulhoon / index.js
Last active July 12, 2023 13:24
Calendars
const fs = require('fs')
const readline = require('readline')
const { google } = require('googleapis')
const client_secret = require('./client_secret.json')
// If modifying these scopes, delete token.json.
const SCOPES = ['https://www.googleapis.com/auth/calendar.readonly']
// The file token.json stores the user's access and refresh tokens, and is
// created automatically when the authorization flow completes for the first
// time.
@mulhoon
mulhoon / complete.post.js
Last active September 27, 2023 17:40
Streaming OpenAI GPT Completions in to Nuxt 3
// server/complete.post.js
import { Configuration, OpenAIApi } from 'openai-edge'
import { OpenAIStream } from 'ai'
import type { H3Event } from 'h3'
const { OPENAI_API_KEY } = useRuntimeConfig()
let openai