Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tusamni's full-sized avatar
😀

Erik Olsen tusamni

😀
View GitHub Profile
@tusamni
tusamni / stickyIO.js
Last active August 16, 2023 21:04
Tailwind CSS intersection observer for sticky navigation bar
const banner = document.querySelector("#banner");
const nav = document.querySelector("#navigation");
// Create a new IntersectionObserver object
let observer = new IntersectionObserver(function (entries, observer) {
for (let entry of entries) {
if (entry.isIntersecting) {
nav.classList.remove("bg-stone-200");
nav.classList.add("bg-stone-100");
} else {
@tusamni
tusamni / DOSpaces.js
Created January 17, 2023 17:51
Get all images from a DigitalOcean Space
// create an api connection to digitalocean spaces
export const spacesClient = new S3({
endpoint: "https://nyc3.digitaloceanspaces.com",
region: "us-east-1",
credentials: {
accessKeyId: import.meta.env.SPACES_KEY,
secretAccessKey: import.meta.env.SPACES_SECRET,
},
});
@tusamni
tusamni / Media.js
Created January 17, 2023 17:50
A snippet to extract EXIF and IPTC data for an image function
// return array with image data
export async function getImage(image) {
const pathname = `${path.dirname(image)}/${path.parse(image).name}`;
const extension = path.parse(image).ext;
const source = `${imageConfig.cloudUrl}${pathname}${extension}`; // final image source
let metadata = await exifReader.load(source, { length: 128 * 1024 });
if (typeof metadata["Object Name"] === "undefined" || metadata["Object Name"] === null) {
return {
@tusamni
tusamni / bookmark-today.js
Last active January 15, 2022 22:34
Dynamic Analytics Bookmarks to load comparison date ranges year over year. This example only works as a comparison for the current date, versus the same day of the week last year.
javascript:function url() {
var start_date = new Date();
var start_dd = start_date.getDate();
var start_mm = start_date.getMonth() + 1;
var start_yyyy = start_date.getFullYear();
if (start_dd < 10) { start_dd = '0' + start_dd; }
if (start_mm < 10) { start_mm = '0' + start_mm; }
var start = '' + start_yyyy + start_mm + start_dd;
var end_date = new Date();