Skip to content

Instantly share code, notes, and snippets.

@bradwestfall
bradwestfall / HoC-vs-RenderProps-vs-Hooks.md
Last active March 28, 2024 19:48
An explanation of why Hooks are a nicer way to abstract re-useable state and functionality vs HoC's and Render Props

HoC (pattern) vs Render Props (pattern) vs Hooks (not pattern, a new API)

Someone was asking me about comparing the HoC and Render Props patterns (and their shortcomings) to hooks. I might leave this up as a public gist for others if it's helpful.


tldr;

Issues with HoC:

@JustinRyanH
JustinRyanH / default.rb
Created March 28, 2024 19:48
MRuby Build
MRuby::Build.new do |conf|
# load specific toolchain settings
conf.toolchain :visualcpp
# Use mrbgems
# conf.gem 'examples/mrbgems/ruby_extension_example'
# conf.gem 'examples/mrbgems/c_extension_example' do |g|
# g.cc.flags << '-g' # append cflags in this gem
# end
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
@erikyuzwa
erikyuzwa / wordpress-6-2-2-docker-compose.yml
Last active March 28, 2024 19:47
Wordpress 6.2.2 Docker Compose for Local Development
# create a local .env file with the following 4 properties:
#
# MYSQL_DATABASE=<something>
# MYSQL_USER=<something>
# MYSQL_PASSWORD=<something>
# MYSQL_ROOT_PASSWORD=<something>
#
# Note: I have had a LOT of issues working with anything newer then Docker Desktop v4.26.1
# If you're on something newer, then double check against this release.
#
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active March 28, 2024 19:45
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@luizomf
luizomf / useState.jsx
Last active March 28, 2024 19:45
Exemplo de useState - Curso React.
import logo from './logo.svg';
import './App.css';
import { useState } from 'react';
function App() {
const [reverse, setReverse] = useState(false);
const [counter, setCounter] = useState(0);
const reverseClass = reverse ? 'reverse' : '';
const handleClick = () => {
@luizomf
luizomf / useEffect.jsx
Created February 15, 2021 20:18
Exemplo de useEffect do Curso de React
import './App.css';
import { useState, useEffect } from 'react';
const eventFn = () => {
console.log('h1 clicado');
};
function App() {
const [counter, setCounter] = useState(0);
const [counter2, setCounter2] = useState(0);
@luizomf
luizomf / useMemo.jsx
Created February 16, 2021 01:11
React Hook useMemo - Curso React
import P from 'prop-types';
import { useEffect, useMemo, useState } from 'react';
import './App.css';
const Post = ({ post }) => {
console.log('Filho renderizou');
return (
<div key={post.id} className="post">
<h1>{post.title}</h1>
<p>{post.body}</p>
@luizomf
luizomf / useRef.jsx
Created February 16, 2021 15:00
React Hook useRef - Curso React
import P from 'prop-types';
import { useEffect, useMemo, useState, useRef } from 'react';
import './App.css';
const Post = ({ post, handleClick }) => {
console.log('Filho renderizou');
return (
<div key={post.id} className="post">
<h1 style={{ fontSize: '14px' }} onClick={() => handleClick(post.title)}>
{post.title}
@luizomf
luizomf / useReducer.jsx
Created February 16, 2021 19:11
React Hook useReducer - Curso React
import { useReducer } from 'react';
import './App.css';
const globalState = {
title: 'O título que contexto',
body: 'O body do contexto',
counter: 0,
};
const reducer = (state, action) => {
@henrik242
henrik242 / airtag-to-gpx-sync.sh
Last active March 28, 2024 19:45
Read AirTag data from the FindMy.app cache and convert to GPX
#!/usr/bin/env bash
#
# Reads AirTag data from the FindMy.app cache and converts it to a daily GPX file
#
# Rsyncs the data to a web accessible folder that can be displayed with e.g.
# https://gist.github.com/henrik242/84ad80dd2170385fe819df1d40224cc4
#
# This should typically be run as a cron job
#