Skip to content

Instantly share code, notes, and snippets.

View bitttttten's full-sized avatar
👻
hello

bitttttten

👻
hello
View GitHub Profile
@wildseansy
wildseansy / sanity-face-hotspots.ts
Last active October 14, 2021 17:18
Sanity Hotspot Generation based on face
import {
RekognitionClient,
DetectFacesCommand,
DetectFacesCommandInput,
} from "@aws-sdk/client-rekognition";
import imageUrlBuilder from "@sanity/image-url";
import client, { SanityImageAssetDocument, Transaction } from "@sanity/client";
import { default as nodeFetch } from "node-fetch";
const SANITY_DATASET = "<my project dataset>";
@kentcdodds
kentcdodds / add-discord-role.js
Last active August 21, 2021 16:29
An example of how you can add a role to a user with discord.js
const Discord = require('discord.js')
// your bot token
const token = 'NzM4MDk2NjA4NDQwNDgzODcw.XyG8CA.RbwIBFnAbrRDYOlTdLYgG_T4CMk'
const discordUsername = 'example#1234'
const roleToAdd = 'Cool Person'
const guildName = 'Your Guild Name'
function deferred() {
let resolve, reject
@bpas247
bpas247 / state-updates-are-async.md
Last active March 17, 2023 17:12
State Updates Are Asynchronous

State Updates Are Asynchronous

The gist of it

You do this.

const handleEvent = e => {
  setState(e.target.value);
  console.log(state);
}
@zephraph
zephraph / clean_node_modules.sh
Last active December 14, 2024 08:04
A shell script to clean up all node_modules in projects that haven't been touched in a couple weeks.
#!/bin/bash
DAYS_SINCE_LAST_CHANGE=14 # If a project hasn't been touched in this long its node_modules will be deleted
SEARCH_PATH="./Git" # Update this to the path where your code is stored
TOTAL_BYTES_REMOVED=0
Mb=1000000
Kb=1000
node_modules=$(find $SEARCH_PATH -name "node_modules" -type d -prune)
@acewf
acewf / gatsby-node.js
Last active September 2, 2019 11:22
gatsby i18next localisation for static pages
// load your translations
// add whatever number namespaces you need
const localesNSContent = {
'en':[
{
content:fs.readFileSync(`src/locales/en/translations.json`, 'utf8'),
ns:'translations'
}
],
'pt':[
@Jessidhia
Jessidhia / react-scheduler.md
Last active June 11, 2024 10:48
Implementation notes on react's scheduling model as of (shortly before) 16.8.0

Implementation notes on react's scheduling model as of (shortly before) 16.8.0

While the public API intended for users to use is the scheduler package, the reconciler currently does not use scheduler's priority classes internally.

ReactFiberScheduler has its own internal "mini-scheduler" that uses the scheduler package indirectly for its deadline-capable scheduleCallback.

This is kind of a documentation of implementation details that I suppose will be gone by the end of the year, but what can you do.

Algorithmic layouts

You are looking at the most important, and most abundant thing on the web. You can't see it, unfortunately, because it's very small… aaaaand it's invisible — so having a magnifying glass doesn't really help here. But still.

I'm talking, of course, about U+0020; not to be confused with the band U2, who are just as ubiquitous, but far less useful.

This unicode point, representing the humble space character, is between every word, in every run of text, on every page of the web. And it has a very special characteristic: it's not sticky like glue. If two words are neighbors but there's not enough room for both of them, the space will free the second word to wrap around and start a new line.

Before getting into flexible containers, viewport meta tags, and @media breakpoints this humble character is what makes the web fundamentally 'responsive'. That is: able to change the layout of its content to suit different devices, contexts, and settings. Browser text does this automa

import React from "react";
import ReactDOM from "react-dom";
import PropTypes from "prop-types";
document.body.style.background = `
linear-gradient(135deg,
#1e5799 0%,
#2989d8 50%,
#207cca 51%,
#7db9e8 100%
@MarcoWorms
MarcoWorms / mini-redux.js
Last active June 3, 2024 04:42
Redux in a nutshell
function createStore (reducers) {
var state = reducers()
const store = {
dispatch: (action) => {
state = reducers(state, action)
},
getState: () => {
return state
}
}
@bisubus
bisubus / ES5-ES6-ES2017-ES2019 omit & pick
Last active April 13, 2024 21:03
ES5/ES6/ES2017/ES2019 omit & pick