Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Murawsky dmurawsky

View GitHub Profile
@dmurawsky
dmurawsky / index.js
Last active May 9, 2023 07:07
How to make a page full height in Next.js
View index.js
const FullHeightPage = () => (
<div>
Hello World!
<style global jsx>{`
html,
body,
body > div:first-child,
div#__next,
div#__next > div {
height: 100%;
@dmurawsky
dmurawsky / tsconfig.json
Created March 3, 2023 03:15
Node Script TS Config File
View tsconfig.json
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"allowJs": false,
"alwaysStrict": true,
"baseUrl": ".",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"isolatedModules": true,
@dmurawsky
dmurawsky / package-purchase.json
Created April 5, 2022 16:13
Examples of Zenoti Packages
View package-purchase.json
{
"user_package_id": "a12802db-834f-48c4-89f2-e4a1558e8bc2",
"user_package_state": 0,
"redeemable": null,
"invoice": {
"status": 4,
"receipt_no": "II9947171",
"id": "8bf6c016-b107-41b9-8218-2c6b90c4aba7",
"no": "II9947171"
},
@dmurawsky
dmurawsky / Header.module.css
Last active October 10, 2021 02:01
Next.js Lavalamp Header
View Header.module.css
.nav {
--link-one: 160px;
--link-two: 160px;
--link-three: 160px;
--link-four: 160px;
--link-five: 160px;
--menu-width: calc(var(--link-one) + var(--link-two) + var(--link-three) + var(--link-four) + var(--link-five));
--link-two-left: var(--link-one);
@dmurawsky
dmurawsky / firebase8.ts
Last active October 9, 2021 02:34
Example of Firebase v9 database functions vs Firebase v8
View firebase8.ts
import firebase from "firebase/app";
import "firebase/database";
export const onceValue = <T>(path: string): Promise<Nullable<T>> =>
firebase
.database()
.ref(path)
.once("value")
.then((snap) => snap.val());
export const firebaseUpdate = (path: string, updateObj: Object) => firebase.database().ref(path).update(updateObj);
View saveLiveSwitchRecording.ts
export const saveLiveSwitchRecording = async (
recordingId: string,
channelId: string,
fileName: string,
type: "video" | "audio"
) => {
const file = makeLiveSwitchRecordingFile(recordingId, channelId, fileName);
const format = fileName.substring(fileName.indexOf(".") + 1);
const writeStream = file.createWriteStream({
metadata: {
@dmurawsky
dmurawsky / getChromeVersion.js
Created September 30, 2021 18:34
Get Chrome/Chromium version and alert
View getChromeVersion.js
const getChromeVersion = () => {
const raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)
return raw ? parseInt(raw[2], 10) : false
}
if (getChromeVersion() < 93) {
alert('We recommend you use a Chrome browser version 93 or greater otherwise you may experience degraded service.')
}
@dmurawsky
dmurawsky / pattern.js
Created May 27, 2020 16:23
The pattern of the universe
View pattern.js
// Usage: Run the below code in your termainal by either running node and copying the code into the REPL or by saving the code to a file and running node pattern.js
// It will output a consistent pattern no matter how high you count.
// Change 1000 to a higher number to test it
let number = 1;
while (number < 1000) {
next = number + 1;
let reduce = number * next + "";
while (reduce.length > 1) {
@dmurawsky
dmurawsky / printful.js
Created July 2, 2020 16:14
Place an order for a printful item
View printful.js
const Axios = require('axios')
Axios({
method: 'POST',
headers: {
Authorization: 'Basic thisisyourbase64authtoken',
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
},
data: JSON.stringify({
recipient: {
@dmurawsky
dmurawsky / firebaseTwilioLambda.js
Last active June 13, 2020 20:42
Helper functions for Firebase and Twilio on Lambda
View firebaseTwilioLambda.js
const axios = require("axios");
const client = require("twilio")(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
const getDateObj = () => {
const date = new Date();
const hour = date.getHours();
const d = date.getDate();
const m = date.getMonth() + 1;
const y = date.getFullYear();
return { hour, date: `${y}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d}` };