Skip to content

Instantly share code, notes, and snippets.

@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active April 18, 2024 11:30
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

@Chengings
Chengings / .editorconfig
Last active April 18, 2024 11:30
Cheatsheets
trim_trailing_whitespace = true
@anthonyjoeseph
anthonyjoeseph / fireblocksCosmos.ts
Last active April 18, 2024 11:28
RAW signing via fireblocks API
import path from "path";
import fs from "fs";
import { coins, pubkeyToAddress } from "@cosmjs/amino";
import { fromHex, toBase64, toHex } from "@cosmjs/encoding";
import { StargateClient } from "@cosmjs/stargate";
import { encodePubkey, makeSignBytes } from "@cosmjs/proto-signing";
import { EncodeObject, Registry, makeAuthInfoBytes, makeSignDoc } from "@cosmjs/proto-signing";
import { sha256 } from "@cosmjs/crypto";
import { FireblocksSDK, TransactionOperation, TransactionStatus } from "fireblocks-sdk";
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
@rafaelp
rafaelp / find_unused_images.rake
Last active April 18, 2024 11:27
Rake task to find unused images on Rails project to deletion.
# It requires ACK - http://betterthangrep.com/
task :find_unused_images do
images = Dir.glob('app/assets/images/**/*')
images_to_delete = []
images.each do |image|
unless File.directory?(image)
# print "\nChecking #{image}..."
print "."
result = `ack -1 -G '(app|public)' --ruby --html --css --js #{File.basename(image)}`
@liviaerxin
liviaerxin / README.md
Last active April 18, 2024 11:26
FastAPI and Uvicorn Logging #python #fastapi #uvicorn #logging

FastAPI and Uvicorn Logging

When running FastAPI app, all the logs in console are from Uvicorn and they do not have timestamp and other useful information. As Uvicorn applies python logging module, we can override Uvicorn logging formatter by applying a new logging configuration.

Meanwhile, it's able to unify the your endpoints logging with the Uvicorn logging by configuring all of them in the config file log_conf.yaml.

Before overriding:

uvicorn main:app --reload
@Athou
Athou / docker-wsl2-setup.sh
Last active April 18, 2024 11:23
install docker in Debian 11/WSL2 without Docker Desktop
# install docker in Debian 11/WSL2
# uses systemd-genie since docker requires systemd but it's not available for WSL
# this is an alternative to Docker Desktop
# prerequisites
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ca-certificates curl wget gnupg lsb-release apt-transport-https
# systemd-genie requires dotnet runtime, add Microsoft repo
@SwitHak
SwitHak / 20211210-TLP-WHITE_LOG4J.md
Last active April 18, 2024 11:20
BlueTeam CheatSheet * Log4Shell* | Last updated: 2021-12-20 2238 UTC

Security Advisories / Bulletins / vendors Responses linked to Log4Shell (CVE-2021-44228)

Errors, typos, something to say ?

  • If you want to add a link, comment or send it to me
  • Feel free to report any mistake directly below in the comment or in DM on Twitter @SwitHak

Other great resources

  • Royce Williams list sorted by vendors responses Royce List
  • Very detailed list NCSC-NL
  • The list maintained by U.S. Cybersecurity and Infrastructure Security Agency: CISA List
@alanwei43
alanwei43 / windows-port-proxy.md
Last active April 18, 2024 11:19
windows powershell port forward
netsh interface portproxy add v4tov4 protocol=tcp connectaddress=192.168.67.128 connectport=9091 listenport=9091
@bradtraversy
bradtraversy / mysql_cheat_sheet.md
Last active April 18, 2024 11:18
MySQL Cheat Sheet

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@Jaykul
Jaykul / Agent Passthru.md
Last active April 18, 2024 11:18
SSH Agent passthru to WSL 2 (working, in Windows 11, in May 2023)

For awhile now, each time I got a new Windows laptop I would dig up strasis gist on how to set up agent forwarding for SSH in WSL2 -- but recently I tried to point someone else at it and they were very confused by it, so this is my attempt at simpler instructions.

Installation

With Chocolatey, you must use an elevated PowerShell session. If there's no choco command found, it will fall back to winget for the npiperelay install. To force using Winget even if you have choco installed, you need to download it, so you can pass parameters to it.

Easy mode: just run this in PowerShell: