Skip to content

Instantly share code, notes, and snippets.

/*
dado o seguinte cenário, um objeto que pode ter valores aninhados até 2 níveis,
deve-se remover a chave do primeiro nível se alguma das chaves aninhadas
for (undefined ou {} ou '' ou null) - 0 não conta
*/
const isObject = (v) => typeof v === 'object' && !Array.isArray(v)
const isEmptyObject = (obj) => isObject(obj) && (Object.keys(obj).length === 0)
const isNull = (v) => v === '' || v === null || v === undefined;
@supahfunk
supahfunk / background.js
Created June 22, 2021 14:56
GLSL Background size cover - R3F
const Background = () => {
const { viewport } = useThree()
const scale = useMemo(() => ((40 + 15) / viewport.distance), [viewport])
const [bgTexture] = useTexture(['./bg.png'])
const shaderArgs = useMemo(() => ({
uniforms: {
uTexture: { value: bgTexture },
uResolution: { value: { x: viewport.width, y: viewport.height } },
uImageRegsolution: { value: { x: bgTexture.image.width, y: bgTexture.image.height } },
@sibelius
sibelius / apiLog.ts
Created April 13, 2021 15:01
fetch api with log
export const apiWithLog = (init, options) => {
const end = timeSpan();
return fetch(init, options).then(async (response) => {
const durationTime = end();
const text = await response.text();
let json;
try {
@sibelius
sibelius / dockerLearnPath.md
Last active October 31, 2023 00:09
Docker Learn Path - What do you need to know about Docker
  • learn why we need docker
  • learn how to define a Dockerfile
  • learn how to build a docker
  • learn how to list images
  • learn how to run docker with port forward
  • learn how to go inside docker to debug, running /bin/bash
  • learn docker compose
  • learn how to send a docker image to a reqistry (dockerhub or aws ecr)
  • learn how to deploy a docker to kubernetes, aws ecs or another platform
  • learn how to use docker volumes
@sibelius
sibelius / Dockerfile
Last active December 17, 2021 14:23
simple dockerfile using a single .js file generated by webpack
FROM node:12.20.1
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ENV GRAPHQL_PORT=5001
EXPOSE ${GRAPHQL_PORT}
COPY ./build/graphql.js /usr/src/app/
@sibelius
sibelius / awsLamdbaExperience.md
Last active October 31, 2023 00:09
AWS Lamdba Learning Path - What do you need to learn about aws lambdas?
  • learn how to bundle backend using webpack in a single bundle (check this https://gist.github.com/jgcmarins/2860f547f5d785dce24ca0eadbe3abdd)
  • learn how to automate lamdba deploys using serveless or aws cdk (github actions)
  • learn how to configure and automate api gateway
  • learn how to automate tests lambdas using jest
  • learn how to configure, automate and use RDS Proxy to fast database workflow in lamdbas (also cache database connections)
  • how the performance gain using RDS Proxy over normal database usage
  • learn about cold start and lambda statefull (https://www.swyx.io/stateful-serverless/)
  • expose a CRUD api in lamdba
  • put everything on open source (github)
  • write a blog post about each of the topics above

Smooth Scroller for React

It's a port of Sooth Scroller for Svelte for React.

Actually, it requires GSAP, TypeScript & Tailwindcss are optional.

To remove TypeScript, just remove the type marks. To remove Tailwindcss, remove tailwindclasses but don't forget to reproduce the same styles in the elements with pure CSS.

Dependencies:

@andrebrait
andrebrait / keychron_linux.md
Last active May 9, 2025 03:09
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Note: many newer Keychron keyboards use QMK as firmware and most tips here do not apply to them. Maybe the ones related to Bluetooth can be useful, but everything related to Apple's keyboard module (hid_apple) on Linux, won't work. As far as I know, all QMK-based boards use the hid_generic module instead. Examples of QMK-based boards are: Q, Q-Pro, V, K-Pro, etc.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work (NOT FOR QMK-BASED BOARDS)

Older Keychron keyboards (those not based on QMK) use the hid_apple driver on Linux, even in the Windows/Android mode, both in Bluetooth and Wired modes.

@victor3r
victor3r / startup.sh
Last active October 14, 2020 17:34
sudo apt-get update
echo 'installing curl'
sudo apt install curl -y
echo 'installing git'
sudo apt-get install git -y
echo "What name do you want to use in GIT user.name?"
read git_config_user_name
@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