Skip to content

Instantly share code, notes, and snippets.

View Seigiard's full-sized avatar

Borisenko Andrew Seigiard

View GitHub Profile
@Seigiard
Seigiard / sitemap.test.ts
Last active October 24, 2025 15:39
Next.JS sitemap example
import { describe, expect, it } from 'vitest'
import { setDynamicVariables } from './sitemap'
describe('setDynamicVariables', () => {
it('should replace single dynamic segment', () => {
const result = setDynamicVariables('/shop/category/[slug]/reviews', {
slug: 'electronics',
})
@Seigiard
Seigiard / online-offline.js
Created August 1, 2017 15:38
Checking for Offline
let isOffline = false;
window.addEventListener('load', checkConnectivity);
// when the page has finished loading,
// listen for future changes in connection
function checkConnectivity() {
updateStatus();
window.addEventListener('online', updateStatus);
window.addEventListener('offline', updateStatus);
}
var self = this;
self.count = 0;
self.intervalCounterId = setInterval(function () {
if (isNaN(self.count)) {
clearInterval(self.intervalCounterId);
self.count = 0;
return;
}
self.remaining = 100 - self.count;
self.count = self.count + (0.15 * Math.pow(1 - Math.sqrt(self.remaining), 2));