Skip to content

Instantly share code, notes, and snippets.

View bitttttten's full-sized avatar
👻
hello

bitttttten

👻
hello
View GitHub Profile
@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':[
@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)
@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);
}
@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
@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>";