Skip to content

Instantly share code, notes, and snippets.

View heggemsnes's full-sized avatar

Sigurd Heggemsnes heggemsnes

View GitHub Profile
@heggemsnes
heggemsnes / box-office-functions.php
Created September 9, 2020 18:59
Create user for each ticket holder on Woocommerce Box Office.
<?php
// Needs to run when creating order
// Also needs to run when editing a ticket
function create_users_from_ticket($order_id)
{
if (!wc_get_order($order_id)) {
return;
}
@heggemsnes
heggemsnes / pull-db.sh
Created January 20, 2021 14:40
Local WP pull DB and import to site
# Requires WP Cli and access to Local SSH, can be opened through Local GUI
# Need .env file in directory with format:
#SSH_USER=demo
#SSH_SERVER=ssh.url
#LIVE_SITE_URL=https://live.url
#LOCAL_SITE_URL=http://local.local
# get-env.sh
SSH_USER=$(grep SSH_USER .env | xargs)
SSH_USER=${SSH_USER#*=}
import React, { useState, useEffect, useRef } from 'react'
import { urlFor } from '../lib/api'
import useWindowDimensions from '../hooks/useWindowDimensions'
/* TODO: Add fallback image */
function LazyImage({
className,
image,
desktopSizePercent = 100,
@heggemsnes
heggemsnes / next-figure.component.tsx
Created May 25, 2022 14:26
Next Figure / Image – Kult
import { urlFor } from "@lib/sanity"
import { getImageDimensions } from "@sanity/asset-utils"
import {
SanityImageObject,
SanityImageSource,
} from "@sanity/image-url/lib/types/types"
import Image from "next/image"
import {
SanityReference,
SanityImageAsset,
@heggemsnes
heggemsnes / create-fylker-and-kommuner.ts
Created February 7, 2024 13:52
Create counties and municipalities for Norway in Sanity
import { authClient } from "../sanity/sanity-config.auth.server";
type Response = Fylke[];
interface Fylke {
avgrensningsboks: Avgrensningsboks;
fylkesnavn: string;
fylkesnummer: string;
kommuner: Kommuner[];
}