Skip to content

Instantly share code, notes, and snippets.

@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
#
@ceving
ceving / Web Component for Copyright Years.md
Last active March 28, 2024 19:44
Web Component for Copyright Years
@OrionReed
OrionReed / DOM3D.js
Last active March 28, 2024 19:43
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@fabiand
fabiand / SimpleHTTPPutServer.py
Created May 22, 2013 14:34
A simple HTTP Server supporting put
# python -m SimpleHTTPPutServer 8080
import SimpleHTTPServer
import BaseHTTPServer
class SputHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_PUT(self):
print self.headers
length = int(self.headers["Content-Length"])
path = self.translate_path(self.path)
with open(path, "wb") as dst: