Skip to content

Instantly share code, notes, and snippets.

View amypellegrini's full-sized avatar
💭
Alive and healthy

Amy Pellegrini amypellegrini

💭
Alive and healthy
View GitHub Profile
@amypellegrini
amypellegrini / 01-directory-structure.md
Created August 30, 2016 13:08 — forked from tracker1/01-directory-structure.md
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@amypellegrini
amypellegrini / distance.js
Last active October 27, 2016 14:38
Distance formula in Node.js
let x1 = process.argv[2],
y1 = process.argv[3],
x2 = process.argv[4],
y2 = process.argv[5];
/**
* Return the distance between two points for the given coordinates.
*
* @param {Number} x1 - x coordinate for the first point.
* @param {Number} y1 - y coordinate for the fisrt point.
@amypellegrini
amypellegrini / findShort.js
Created November 14, 2016 19:19
Shortest string exercise from codewars
// Shortest Word
function findShort(str) {
return str.split(' ').sort((a, b) => {
return a.length < b.length ? -1 : 1;
})[0].length;
}
@amypellegrini
amypellegrini / git-cheatsheet.md
Last active May 20, 2019 09:10
Git cheat sheet

Git cheat sheet

Git rebase, fixup, and autosquash

  1. Copy commit to fix hash
  2. Commit your changes using --fixup [hash] instead of commit message
  3. git rebase -i [base/branch] --autosquash

[Delete multiple branches using a string match pattern][1]

Keybase proof

I hereby claim:

  • I am amypellegrini on github.
  • I am amypellegrini (https://keybase.io/amypellegrini) on keybase.
  • I have a public key ASCj0KljOByEIgUNDMwkfXxa0t2XAI-bAtmY1crdA_eEVgo

To claim this, I am signing this object:

@amypellegrini
amypellegrini / make-file-executable.md
Last active June 20, 2019 22:03
Make file executable in UNIX-style command line

Make file executable in UNIX-style command line

Recently I started to learn Python. My first experiment consisted of a simple script named script.py to print the classic "Hello World!" message. To make the file executable, I added the shebang at the top of the file.

Contents in script.py:

#!/usr/bin/env python3
@amypellegrini
amypellegrini / README.md
Created August 10, 2019 18:20
Save your bash history for learning purposes

Save your bash history for learning purposes

Very often I find myself trying to learn something new which requires from me to run easy-to-forget console/terminal commands.

Sometimes I have to trial-and-error using different commands until I finally get it, which means I may have some difficulty trying to remember what I did next time I want to do it again.

To avoid this I find very useful to save my command line history so I can replay back everything I did step by step.

@amypellegrini
amypellegrini / machine.js
Created January 23, 2020 21:02
Generated by XState Viz: https://xstate.js.org/viz
const scaleChartGeneratorMachine = Machine({
id: 'scale-chart-generator',
initial: 'default',
context: {
musicKey: undefined,
scaleName: undefined,
withKeySignature: false,
},
states: {