sanity login
(login with GitHub)sanity dataset export develop
(accept default output, it will backupdevelop
in a tar file)sanity dataset export schema
(accept default output, it will backupschema
in a tar file)sanity dataset delete develop
(on prompt, type the name of the dataset to confirm delete)sanity dataset import ./schema.tar.gz develop --replace
sanity graphql deploy
sanity deploy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes | |
function sieveOfEratosthenes(n) { | |
// Create a boolean array "prime[0..n]" and | |
// initialize all entries it as true. | |
// A value in prime[i] will finally be false | |
// if i is Not a prime, else true. | |
let prime = new Array(n + 1).fill(true); | |
// Create the Sieve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "./ucrainize-c.css"; | |
const colorizeText = ({ tagName, colorValues }) => { | |
const els = document.getElementsByTagName(tagName); | |
for (let el of els) { | |
const elText = el.innerHTML; | |
const elChars = elText.split(""); | |
let newText = ""; | |
let colorNumber = 0; | |
elChars.map(char => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scenario: | |
// You have a javascript array that likely has some duplicate values and you would like a count of those values. | |
const compressArray = arr => { | |
const compressed = []; | |
// make a copy of the input array | |
const copy = arr.slice(0); | |
// first loop goes over every element | |
for (let i = 0; i < arr.length; i++) { | |
let myCount = 0; |
1. Identify all headings in a page, on page load
2. Generate a string out of each heading text
- Should be URL-friendly as it will be part of a URL.
- Should not start with a number as it would be an invalid
id
. - Should be sanitized with unique values at the end (
-1
,-2
) in case there are one or more headings with the same text. To keep it as clean as possible we should do this only when duplicates are detected. (We cannot use random string generators likeuuid
as the links would not be the same when visiting the page again). - Should be generated by a function that's properly tested with normal and edge-case scenarios, which always gives us what we expect. The generated
id/fragment
should always be the same given we give it the same input.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUrlParam(param, url) { | |
let theUrl = url; | |
if (!url) { | |
theUrl = location.href; | |
} | |
const theParam = param.replace(/[[]/, '\\[').replace(/[\]]/, '\\]'); | |
const regexLogic = `[\\?&]${theParam}=([^&#]*)`; | |
const regex = new RegExp(regexLogic); | |
const results = regex.exec(theUrl); | |
return results === null ? null : results[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sides: (top, bottom, left, right); | |
$space-values: (2, 5, 10, 15, 20, 30, 40, 50, 60); | |
@each $side in $sides { | |
@for $i from 1 through length($space-values) { | |
$value: nth($space-values, $i); | |
$valuePx: #{$value}px; | |
.m-#{str-slice($side, 0, 1)}-#{$value} { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sides: (top, bottom, left, right); | |
$space-values: (2, 5, 10, 15, 20, 30, 40, 50, 60); | |
@each $side in $sides { | |
@for $i from 1 through length($space-values) { | |
$value: nth($space-values, $i); | |
$valuePx: #{$value}px; | |
.m-#{str-slice($side, 0, 1)}-#{$value} { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1 class="m-b-40">This is important!</h1> | |
<p>Did you know…</p> | |
<p class="m-t-10 m-b-20">You might not need jQuery.</p> | |
<p class="">"Just" saying.</p> |
NewerOlder