Skip to content

Instantly share code, notes, and snippets.

@agmm
agmm / merge-without-history.sh
Created February 17, 2020 17:29
Merge without commit history
git checkout master
git merge --squash branch_to_merge_without_history
@agmm
agmm / imperative-messages.md
Last active February 19, 2020 19:19
Imperative Commit Messages

To remove any confusion, here’s a simple rule to get it right every time:

"If applied, this commit will your subject line here"

Examples

  • If applied, this commit will refactor subsystem X for readability
  • If applied, this commit will update getting started documentation
  • If applied, this commit will remove deprecated methods
  • If applied, this commit will release version 1.0.0
  • If applied, this commit will merge pull request #123 from user/branch
@agmm
agmm / debian-install-node.sh
Last active March 10, 2020 18:56
Script to install N, Node and NPM in a Debian machine
# To run this script execute:
# curl -L https://gist.githubusercontent.com/agmm/80c58ca8114abd5d16259488a601fd4f/raw/1a016ca9e6e9281a57a931c6209ba41dc7ea27d7/debian-install-node.sh -o setup && sudo bash setup
echo -e "\n\nRemember to run with sudo"
# Exit if one of the commands fails
set -e
set -o pipefail
# Install Git
@agmm
agmm / gcloud-ssh.sh
Last active March 12, 2020 15:19
Google Cloud SSH Configuration
# Generate a new key
ssh-keygen -t rsa -f ~/.ssh/sometest -C someTest
# Go to ~/.ssh and copy the contents of your .pub file
# Then enter the contents in the metadata section of gcloud
# Connect using the key created above
ssh -i sometest someTest@ip
# Then you can login without specifying the key
machine="machine-name"
echo "Starting gcloud VM"
OUTPUT="$(gcloud compute instances start "${machine}" --format="json")"
ip="$(echo "$OUTPUT" | grep natIP | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}")"
echo "----------"
echo "VM Name: ${machine}"
echo "VM External IP: ${ip}"
echo "----------"
@agmm
agmm / expo-error-fix.sh
Created April 23, 2020 17:34
Expo Error Fix
rm -rf .expo && rm -rf node_modules && yarn add native-base@2.13.8 && yarn && yarn start
@agmm
agmm / pkg-basics.md
Last active May 27, 2020 19:42
Stand-alone executable using pkg

To create an stand-alone executable from a NodeJS project the process is as follows:

  1. Install pkg using npm i -g pkg

  2. If the project does not have dynamic requires use pkg entryPoint.js

  3. If the project has dynamic imports add the following code to your package.json

"pkg": {
@agmm
agmm / pnpm.md
Created May 28, 2020 16:04
Fast Package Manager – pnpm

Basics

  • pnpm init
  • pnpm add <pkg>
  • pnpm install
  • pnpm link
  • pnpm list
  • pnpm store prune
  • pnpx <command>
@agmm
agmm / gclud-basics.md
Last active May 31, 2020 07:05
Google Cloud Basics

Start an existing instance

gcloud compute instances start <instance name>

Start an SSH session

gcloud compute ssh [user@]<instance name>
@agmm
agmm / firestore-admin-quickstart.js
Created July 1, 2020 00:46
Firestore Admin NodeJS
const { Firestore } = require('@google-cloud/firestore');
// Create a new client
const firestore = new Firestore({ projectId: id, keyFilename: pathToServiceAccountJsonKey });
async function quickstart() {
// Obtain a document reference.
const document = firestore.doc('posts/intro-to-firestore');