Skip to content

Instantly share code, notes, and snippets.

View jherax's full-sized avatar
👾
Performance focused

David Rivera jherax

👾
Performance focused
View GitHub Profile
@jherax
jherax / sortBy.js
Last active May 31, 2021 07:50
Sorts an array with multiple ordering criteria (Schwartzian transform)
/**
* Sorts an array and allows multiple sorting criteria.
*
* It applies the Schwartzian transform:
* https://en.wikipedia.org/wiki/Schwartzian_transform
*
* Author: David Rivera
* Github: https://github.com/jherax
*
* You can fork this project on github:
@bsara
bsara / git-ssh-auth-win-setup.md
Last active April 22, 2024 13:49
Setup SSH Authentication for Git Bash on Windows

Setup SSH Authentication for Git Bash on Windows

Prepararation

  1. Create a folder at the root of your user home folder (Example: C:/Users/uname/) called .ssh.
  2. Create the following files if they do not already exist (paths begin from the root of your user home folder):
  • .ssh/config
@jherax
jherax / filterArray.js
Last active February 23, 2024 12:59
Filters an array of objects with multiple match-criteria.
/**
* Filters an array of objects using custom predicates.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria
* @return {Array}
*/
function filterArray(array, filters) {
const filterKeys = Object.keys(filters);
return array.filter(item => {
@cmalard
cmalard / subl
Last active February 13, 2019 20:23 — forked from versedi/.sh
Cygwin + Sublime Text 3 : works with files and Git
#!/bin/bash
# To create in [.babun/]cygwin/usr/local/bin/subl with chmod +x
ARGS=""
while test $# -gt 0
do
ARGS="$ARGS ${1#/cygdrive/[a-zA-Z]}"; # Remove /cygdrive and disk letter from the path
shift
done
@jherax
jherax / is-private-mode.js
Last active March 19, 2024 18:29
Detect if the browser is running in Private mode - Promise based (last update: Feb 2020)
/**
* Lightweight script to detect whether the browser is running in Private mode.
* @returns {Promise<boolean>}
*
* Live demo:
* @see https://output.jsbin.com/tazuwif
*
* This snippet uses Promises. If you want to run it in old browsers, polyfill it:
* @see https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.min.js
*
@jherax
jherax / memoize.js
Last active July 5, 2022 21:03
High-order function that memoizes a function
/**
* @summary
* High-order function that memoizes a function, by creating a scope
* to store the result of each function call, returning the cached
* result when the same inputs is given.
*
* @description
* Memoization is an optimization technique used primarily to speed up
* functions by storing the results of expensive function calls, and returning
* the cached result when the same inputs occur again.
/**
* range()
*
* Returns an array of numbers between a start number and an end number incremented
* sequentially by a fixed number(step), beginning with either the start number or
* the end number depending on which is greater.
*
* @param {number} start (Required: The start number.)
* @param {number} end (Required: The end number. If end is less than start,
* then the range begins with end instead of start and decrements instead of increment.)
@jherax
jherax / README.md
Last active February 12, 2024 14:53
Git Alias and Rebase

Git Alias and Git Rebase

WHEN TO DO REBASE

After each commit in our branch, in order to be up-to-date with the integration branch.

@jherax
jherax / git-ssh-auth-win-setup.md
Last active February 12, 2024 19:37 — forked from bsara/git-ssh-auth-win-setup.md
Setup SSH Authentication for Git Bash on Windows

Setup SSH Authentication for Git Bash on Windows

Prepararation

  1. Create a folder at the root of your user home folder (Example: C:/Users/username/) called .ssh.
    You can run something like: mkdir -p ~/.ssh
  2. Create the following files if they do not already exist (paths begin from the root of your user home folder):