Skip to content

Instantly share code, notes, and snippets.

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

Oussama Romdhane 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;
/**
@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: []
},
@therightstuff
therightstuff / _end-to-end-enc.js.md
Last active December 19, 2023 02:17
Javascript / Node.js end-to-end encryption
@laobubu
laobubu / ABOUT.md
Last active May 7, 2024 18:37
A very simple HTTP server in C, for Unix, using fork()

Pico HTTP Server in C

This is a very simple HTTP server for Unix, using fork(). It's very easy to use

How to use

  1. include header httpd.h
  2. write your route method, handling requests.
  3. call serve_forever("12913") to start serving on port 12913
@DrewML
DrewML / slack-slashes.md
Created May 1, 2016 16:36
"Secret" Slack slash commands

"Secret" Slack Slash Commands

Enable Web Inspector

/macgap.app.enabledevelopertools()

Assign a color (using hex code) to any users name

/color andrew #000000

Change Status (Doesn't seem to work)

/status