Skip to content

Instantly share code, notes, and snippets.

View atayahmet's full-sized avatar
🎯
Focusing

Ahmet atayahmet

🎯
Focusing
View GitHub Profile
@jfet97
jfet97 / DFS.js
Last active August 26, 2023 10:02
Simple Depth First Search in JavaScript
function isObject(entity) {
return typeof entity === "object" && entity !== null;
}
function getAdjacentNodes(obj) {
return (
Object.entries(obj)
.filter(([, v]) => isObject(v))
)
}
// https://www.typescriptlang.org/docs/handbook/advanced-types.html
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
/**
* Enlève les clés K de T (plus précis que le Omit natif).
*/
type OmitStrict<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
/**
* Récupère la version promisifiée d'une fonction.

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).

@ziluvatar
ziluvatar / token-generator.js
Last active October 24, 2024 04:26
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@bisubus
bisubus / ES5-ES6-ES2017-ES2019 omit & pick
Last active April 13, 2024 21:03
ES5/ES6/ES2017/ES2019 omit & pick
@btroncone
btroncone / rxjs_operators_by_example.md
Last active June 15, 2024 07:17
RxJS 5 Operators By Example
@subfuzion
subfuzion / curl.md
Last active November 2, 2024 04:27
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@peterhurford
peterhurford / programming-checklist.md
Last active August 8, 2024 18:52
A programming checklist for you to fill out every time you make a pull request to make sure you end up with good code
  • Did you write tests? Are they mutually exclusive and collectively exhaustive? Do they pass?
  • Did you get a code review?
  • Have you verified that your code works, outside of tests?
  • Is your code DRY?
  • Did you follow the single responsibility principle at different levels of detail throughout all your functions, objects, files, folders, repositories, etc.?
  • Is your code readable? Can someone else tell you what it does?
  • Is your code self-documenting? Did you explain strange choices? Did you write documentation about how it works?
  • Do all your variables have self-explaining names?
  • Did you avoid writing overly long functions?
  • Do you document what your function inputs are? Are you explicit about what preconditions must be true about your function inputs? Are you explicit about what postconditions will hold about your function outputs, if the preconditions hold?
@MohammadYounes
MohammadYounes / squash-commits.sh
Created December 13, 2015 14:14 — forked from jbub/squash-commits.sh
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c