Skip to content

Instantly share code, notes, and snippets.

View simone-sanfratello's full-sized avatar

Simone Sanfratello simone-sanfratello

View GitHub Profile
@oliverjumpertz
oliverjumpertz / simple-linear-regression.js
Created January 5, 2021 19:49
Simple linear regression implemented in JavaScript
const inputArray = [
{
squareMeters: 200,
priceInDollars: 190000
},
{
squareMeters: 100,
priceInDollars: 90000
},
{
@kentcdodds
kentcdodds / README.md
Last active March 30, 2024 11:39
user-package-stats

user-package-stats

I was poking around trying to figure out all the packages I have access to publish and got curious. So I write this little script to determine the download stats for all the packages I have publish access to.

Feel free to try it yourself. Just change the username passed to getUserDownloadStats.

By default, the stats are sorted by their average daily downloads (descending). That should give you an idea of the most "popular" package of a given user relative to how long that package has been around.

You can use it with npx like so:

@aelbore
aelbore / esm-cjs-modules.md
Last active May 5, 2024 03:07
Publish your npm package as ES Module, and backward compatibility CommonJS

Create your library

  • Initialize project npm init -y
  • Create esm module ./src/esm/my-lib.js
    function addNumber(value, value2) {
      return value + value2;
    }
    
    export { addNumber };
@StevenACoffman
StevenACoffman / git-auto-sign-commits.sh
Last active October 5, 2023 08:13 — forked from mort3za/git-auto-sign-commits.sh
Auto sign your git commits
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C gears@umich.edu -N ''
# -o : Save the private-key using the new OpenSSH format rather than the PEM format. Actually, this option is implied when you specify the key type as ed25519.
# -a: It’s the numbers of KDF (Key Derivation Function) rounds. Higher numbers result in slower passphrase verification, increasing the resistance to brute-force password cracking should the private-key be stolen.
# -t: Specifies the type of key to create, in our case the Ed25519.
# -f: Specify the filename of the generated key file. If you want it to be discovered automatically by the SSH agent, it must be stored in the default `.ssh` directory within your home directory.
# -C: An option to specify a comment. It’s purely informational and can be anything. But it’s usually filled with <login>@<hostname> who generated the key.
# -N: Provides the new passphrase.
eval "$(ssh-agent -s)"
ssh-add -K ~/.ssh/id_ed25519
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@simone-sanfratello
simone-sanfratello / git.md
Last active June 18, 2020 05:10
git quick
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active July 21, 2024 05:06
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@firatkucuk
firatkucuk / delete-slack-messages.js
Last active July 1, 2024 15:26
Deletes slack public/private channel messages, private chat messages and channel thread replies.
#!/usr/bin/env node
// Channel ID is on the the browser URL.: https://mycompany.slack.com/messages/MYCHANNELID/
// Pass it as a parameter: node ./delete-slack-messages.js CHANNEL_ID
// CONFIGURATION #######################################################################################################
const token = 'SLACK TOKEN';
// Legacy tokens are no more supported.
// Please create an app or use an existing Slack App