Skip to content

Instantly share code, notes, and snippets.

View OussamaRomdhane's full-sized avatar
🐧
Penguin-ing

Oussama OussamaRomdhane

🐧
Penguin-ing
View GitHub Profile

Cheat sheet: JavaScript Array methods

Deriving a new Array from an existing Array:

['■','●','▲'].slice(1, 3)           ['●','▲']
['■','●','■'].filter(x => x==='■')  ['■','■']
    ['▲','●'].map(x => x+x)         ['▲▲','●●']
    ['▲','●'].flatMap(x => [x,x])   ['▲','▲','●','●']
@marvinhagemeister
marvinhagemeister / little-vdom-decompiled.js
Created March 8, 2020 14:13
Jason little-vdom decompiled
/* eslint-disable no-unused-vars */
/* eslint-disable no-else-return */
// JSX constructor, similar to createElement()
export const h = (type, props, ...children) => {
return {
type,
// Props will be an object for components and DOM nodes, but a string for
// text nodes
props,
@liamnewmarch
liamnewmarch / format-relative.js
Last active November 3, 2023 15:29
Relative time strings using the web platform
/**
* The target language. [Browser support is good][1] but "en-US" is a safe default.
*
* [1]: https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language
*
* @type {string}
*/
const { language = "en-US" } = navigator;
/**
@fnky
fnky / ANSI.md
Last active April 24, 2025 13:43
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@nisrulz
nisrulz / androidDevAliases.sh
Created April 15, 2018 12:18
All of my android development aliases.
# I use ZSH, here is what I added to my .zshrc file (config file)
# at ~/.zshrc
# ------------------ Android ------------------ #
# Have the adb accessible, by including it in the PATH
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:path/to/android_sdk/platform-tools/"
# Setup your Android SDK path in ANDROID_HOME variable
export ANDROID_HOME=~/sdks/android_sdk
@nweldev
nweldev / angular-prompt-zsh.sh
Last active March 30, 2019 00:31 — forked from manekinekko/spaceship-prompt__sections__angular.zsh
Customize your Oh My Zsh SpaceShip theme with Angular and AngularCLI prompt (https://github.com/denysdovhan/spaceship-prompt)
# ANGULAR
SPACESHIP_ANGULAR_SHOW="${SPACESHIP_ANGULAR_SHOW:=true}"
SPACESHIP_ANGULAR_PREFIX="${SPACESHIP_ANGULAR_PREFIX:="with "}"
SPACESHIP_ANGULAR_SUFFIX="${SPACESHIP_ANGULAR_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_ANGULAR_SYMBOL="${SPACESHIP_ANGULAR_SYMBOL:="🅰️ "}"
SPACESHIP_ANGULAR_DEFAULT_VERSION="${SPACESHIP_ANGULAR_DEFAULT_VERSION:=""}"
SPACESHIP_ANGULAR_COLOR="${SPACESHIP_ANGULAR_COLOR:="red"}"
SPACESHIP_ANGULAR_CLI_SHOW="${SPACESHIP_ANGULAR_CLI_SHOW:=true}"
SPACESHIP_ANGULAR_CLI_PREFIX="${SPACESHIP_ANGULAR_CLI_PREFIX:=""}"
@ryanve
ryanve / blacklist.js
Created May 9, 2017 02:11
JavaScript regex to blacklist words
/^(?!(corn|bread)$).+/.test('corn') // false (blacklisted)
/^(?!(corn|bread)$).+/.test('bread') // false (blacklisted)
/^(?!(corn|bread)$).+/.test('cornbread') // true (not blacklisted)
/^(?!(corn|bread)$).+/.test('corndog') // true (not blacklisted)
/^(?!(corn|bread)$).+/.test('read') // true (not blacklisted)
@rafaelrinaldi
rafaelrinaldi / index.js
Created January 19, 2017 16:02
ESLint custom rule to ensure TODO comments to follow a specific format
module.exports = {
meta: {
docs: {
description: 'requires a TODO to be specified either with a task number or URL and a message',
category: 'Best Practices',
recommended: true
},
schema: []
},
@vubon
vubon / ADB.txt
Created January 17, 2017 19:15
Manually adding Android ADB USB driver in Ubuntu 16.04 LTS
Requirements:
Operating System: Ubuntu 16.04 LTS
Android Developer Tools (ADT) installed
Steps:
Make sure that you have connected your Android device in USB Debugging mode
Press Ctrl + Alt + T for Terminal and use the following command:
lsusb
@therightstuff
therightstuff / _end-to-end-enc.js.md
Last active December 19, 2023 02:17
Javascript / Node.js end-to-end encryption