Skip to content

Instantly share code, notes, and snippets.

View RobinBastiaan's full-sized avatar

Robin Bastiaan RobinBastiaan

View GitHub Profile
@ameenross
ameenross / check_regex.php
Last active June 17, 2024 07:31 — forked from smichaelsen/check_regex.php
PHP: Check if string is valid regular expression
<?php
/**
* @param string $regex
* @return bool
*/
function isValidRegularExpression($regex) {
set_error_handler(function() {}, E_WARNING);
$valid = preg_match($regex, null) !== FALSE;
restore_error_handler();

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])   ['▲','▲','●','●']
#!/usr/bin/env bash
sudo apt update
sudo apt -y install curl
# Set up PHP 8.0
sudo apt update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update