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 |
<?php | |
/** | |
* @param string $regex | |
* @return bool | |
*/ | |
function isValidRegularExpression($regex) { | |
set_error_handler(function() {}, E_WARNING); | |
$valid = preg_match($regex, null) !== FALSE; | |
restore_error_handler(); |
[*] | |
charset = utf-8 | |
end_of_line = crlf | |
indent_size = 4 | |
indent_style = space | |
insert_final_newline = false | |
max_line_length = 120 | |
tab_width = 4 | |
ij_continuation_indent_size = 8 | |
ij_formatter_off_tag = @formatter:off |
Translations: Korean (by Yongwoo Lee)
Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.
I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).
# git psh(hh) | |
git config --global alias.psh '!git pull --rebase=merges; git push'; | |
git config --global alias.pshhh '!git stash; git pull --rebase=merges; git push; git stash pop'; |
<?php // ~/.config/psysh/config.php | |
// Anything not Laravel - let's try to autoload something likely to exist | |
if (!defined('LARAVEL_START')) { | |
return [ | |
'defaultIncludes' => [ | |
getcwd().'/vendor/autoload.php', | |
getcwd().'/bootstrap/autoload.php', | |
], | |
]; |
# The command finds the most recent tag that is reachable from a commit. | |
# If the tag points to the commit, then only the tag is shown. | |
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object | |
# and the abbreviated object name of the most recent commit. | |
git describe | |
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix: | |
git describe --abbrev=0 | |
# other examples |
#!/bin/bash | |
# This is a very naive script, it doesn't do grouping and returns all branches | |
# I only really care about branches that have not seen commits in two months | |
# | |
# I am hoping to find some time to write a tool that can output these reports for me | |
# In the meantime, I am using this | |
echo "Merged branches" | |
for branch in `git branch -r --merged | grep -v HEAD`;do echo -e `git log --no-merges -n 1 --format="%ci, %cr, %an, %ae, " $branch | head -n 1` \\t$branch; done | sort -r |