Skip to content

Instantly share code, notes, and snippets.

@nrdobie
nrdobie / README.md
Last active May 5, 2024 18:08
Use CUID2 with Prisma

This will automatically use CUID2 for all id fields when creating elements in Prisma.

You'll need to add the following libraries to make this work

npm install --save @paralleldrive/cuid2 immer
yarn add @paralleldrive/cuid2 immer
pnpm add @paralleldrive/cuid2 immer
@nrdobie
nrdobie / Drag-and-Drop.md
Last active December 22, 2020 19:50
Custom Leadbox Links

Drag & Drop Leadbox

Start with the Plain Text Link and copy the code from the box.

<script src="//static.leadpages.net/leadboxes/current/embed.js" async defer></script> <a href="" data-leadbox-popup="1410f2073f72a2:1165b2d55f46dc">Click here to subscribe</a> 

You'll need to include the script tag somewhere on your page. When creating the Leadbox link you can use any HTML element by adding the data-leadbox-popup attribute from the generated code, if you need to use an href on an <a> tag you can convert the data-leadbox-popup to an href by adding //{{YOUR LP SUBDOMAIN}}.leadpages.co/leadboxes/{{DATA ATTRIBUTE VALUE}}. For example data-leadbox-popup="1410f2073f72a2:1165b2d55f46dc" becomes href="//nickdobie.leadpages.co/leadboxes/1410f2073f72a2:1165b2d55f46dc".

@nrdobie
nrdobie / dom_benchmark.html
Last active August 23, 2016 22:35
document#createElement vs Node#cloneElement
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Benchmark</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.15.0/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.1/benchmark.min.js"></script>
<script>
@nrdobie
nrdobie / dev-server.js
Last active September 29, 2019 14:17
Node.js Server with webpack and auto reload
const { fork } = require('child_process');
const webpack = require('webpack');
const webpackServerConfig = require('./webpack.server.js');
let bundler = webpack(webpackServerConfig);
let child;
bundler.watch({}, (err, status) => {
#include <SPI.h>
void setup() {
// We will need to control the Load/CS pin so
// make a pin an output, for this example I'll
// use pin 7.
pinMode(7, OUTPUT);
// The Maxim chip need the most siginifcant
#include <SPI.h>
uint8_t animation [22] = {
0b01000000,
0b01100000,
0b01100001,
0b01100101,
0b01101101,
0b01111101,
0b01111101,
#include <AccelStepper.h>
//AccelStepper stepper
#define BUTTON_PIN 8
#define MOTOR_DIRECTION_PIN 2
#define MOTOR_STEPPER_PIN 3
#define MOTOR_ACCELERATION 80000
#define SENSOR_1 A0
#define SENSOR_2 A5
//set up the accelStepper intance
@nrdobie
nrdobie / max7219_max7221.ino
Last active July 1, 2023 20:29
Basic code for using Maxim MAX7219/MAX7221 with Arduino.
/*
Basic code for using Maxim MAX7219/MAX7221 with Arduino.
Wire the Arduino and the MAX7219/MAX7221 together as follows:
| Arduino | MAX7219/MAX7221 |
| --------- | --------------- |
| MOSI (11) | DIN (1) |
| SCK (13) | CLK (13) |
| I/O (7)* | LOAD/CS (12) |
@nrdobie
nrdobie / install-sublime-text-3.sh
Created October 28, 2013 22:12
Installs Sublime Text 3 on Linux. Make sure to mark as executable.
#!/bin/sh
SHORTCUT="[Desktop Entry]
Version=1.0
Type=Application
Name=Sublime Text 3
GenericName=Text Editor
Comment=Sophisticated text editor for code, markup and prose
Exec=/usr/local/sublime-text-3/sublime_text %F
Terminal=false
MimeType=text/plain;
#!/bin/sh
SHORTCUT="[Desktop Entry]
Name=Sublime Text 2
Comment=Edit text files
Exec=/usr/local/sublime-text-2/sublime_text
Icon=/usr/local/sublime-text-2/Icon/128x128/sublime_text.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Utility;TextEditor;"