Skip to content

Instantly share code, notes, and snippets.

@bjoerge
bjoerge / recover-schema.md
Last active June 17, 2025 12:58
How to recover lost schema from *.sanity.studio.md

First, go to https://<yourname>.sanity.studio (or to the url of your studio if it's hosted elsewhere). Then open the developer console (usually by one of the keyboard shortcuts Command+Option+I, F12 or Control+Shift+I depending on what browser/platform you are using)

Steps

  1. Open the Sources tab
  2. Find the app.bundle.js file in the sidebar tree view.
  3. Hit the pretty print source button
  4. Locate your schema types by searching (e.g. try searching for one of your custom types) it in the source view.
@paulgrieselhuber
paulgrieselhuber / Schema.js
Last active March 22, 2023 04:20
Adding Schema Data to Next.js Sites
import Head from "next/head";
import { site, siteTitle } from "../../config";
function strip(html) {
var one = html.replace(/<\/?[^>]+(>|$)/gm, "");
var two = one.replace(/[\r\n]\s*[\r\n]/gm, "");
return two;
}
const Schema = ({ post }) => {
@peacefixation
peacefixation / lerp-rgb.js
Last active August 1, 2023 10:01
Linear interpolate RGB colors
// interpolate between colors { r, g, b } where 0 < t < 1
// when assigning a color for a number in a range larger than 0-1, scale the number to the 0-1 range first
function lerpRGB(color1, color2, t) {
let color = {};
color.r = color1.r + ((color2.r - color1.r) * t);
color.g = color1.g + ((color2.g - color1.g) * t);
color.b = color1.b + ((color2.b - color1.b) * t);
return color;
}
@endolith
endolith / DFT_ANN.py
Last active October 6, 2025 09:06
Training neural network to implement discrete Fourier transform (DFT/FFT)
"""
Train a neural network to implement the discrete Fourier transform
"""
import matplotlib.pyplot as plt
import numpy as np
from tensorflow.keras.layers import Dense
from tensorflow.keras.models import Sequential
N = 32
batch = 10000
@benoitguigal
benoitguigal / .block
Last active April 27, 2023 14:07
Force Directed Graph with smooth transitions
license: gpl-3.0
height: 600
@NWCalvank
NWCalvank / fp.js
Created April 29, 2018 15:34
Transducers Explained | JavaScript
module.exports = {
compose,
concat,
};
function apply(x, f) {
return f(x);
}
function compose(...funcs) {
@nikhilkumarsingh
nikhilkumarsingh / paint.py
Created November 3, 2017 16:26
A simple paint application using tkinter in Python 3
from tkinter import *
from tkinter.colorchooser import askcolor
class Paint(object):
DEFAULT_PEN_SIZE = 5.0
DEFAULT_COLOR = 'black'
def __init__(self):
@NigelEarle
NigelEarle / Knex-Setup.md
Last active March 15, 2025 16:49
Setup Knex with Node.js

Knex Setup Guide

Create your project directory

Create and initialize your a directory for your Express application.

$ mkdir node-knex-demo
$ cd node-knex-demo
$ npm init
@RSNara
RSNara / raf-loop.cljs
Created September 1, 2017 16:35
A requestAnimationFrame loop that's useful as a game loop.
(defn raf-loop [func]
(let [stop (atom false)
id (atom nil)]
(reset! id (.requestAnimationFrame js/window
(fn helper [& args]
(when-not @stop
(reset! id (.requestAnimationFrame js/window helper))
(try
(apply func args)
(catch js/Error ex
@EliotAndres
EliotAndres / benchmark.py
Created June 7, 2017 21:12
Tensorflow XLA benchmark
# '''
# A small Tensorflow XLA benchmark
#
# Original Author: Aymeric Damien
# Project: https://github.com/aymericdamien/TensorFlow-Examples/
# '''
import tensorflow as tf