Skip to content

Instantly share code, notes, and snippets.

View twysto's full-sized avatar
😀
Enthusiastic

Loïc Liné twysto

😀
Enthusiastic
View GitHub Profile
@twysto
twysto / README.md
Last active October 29, 2024 15:07
Install Apache Cassandra 5.0.2 as a Tarball binary file + Quickstart
@twysto
twysto / index.php
Last active October 29, 2024 15:07
Example usage of the "Null Coalescing Assignment Operator"
<?php
$arr = [
'a' => 'xyz',
'b' => null,
'c' => 0,
];
// Rather than writing:
//
@twysto
twysto / HOWTO.md
Last active March 13, 2024 11:05
Homestead - Regenerate SSL Certificates
  1. If the folder /etc/ssl/.old-certs doesn't exists, create it:
sudo mkdir /etc/ssl/.old-certs
  1. Move old certs files into it:
sudo mv /etc/ssl/certs/phpmyadmin.local.{cnf,crt,csr,key} /etc/ssl/.old-certs
@twysto
twysto / gist:23790adc965e5c9c278f19e7ab702bb8
Created November 15, 2023 10:02
Ubuntu default browser from Firefox (default) to Brave
First, check if the `brave.desktop` file is present in `/usr/share/applications`.
If not, just create a symlink like that:
```
ln -s /snap/brave/current/meta/gui/brave.desktop /usr/share/applications/brave.desktop
```
Then edit the `default.list` file:
```
sudo nano /usr/share/applications/defaults.list
```
@twysto
twysto / array_weave.php
Last active February 22, 2024 15:57
PHP | Array Weaving
<?php
if (! function_exists('array_weave')) {
function array_weave(...$args) {
/**
* @todo
* 1. Check that each argument is the same size. If they're not, return false.
* 2. Add the type declarations and corresponding DocBlock.
*/
return array_map(fn (...$args) => func_get_args(), ...$args);
@twysto
twysto / spreg_match.php
Last active March 31, 2023 10:08
PHP: Safe PCRE Regex Match `spreg_match(...)`
<?php
if (! function_exists('spreg_match')) {
function spreg_match(
string $pattern,
string $subject,
array &$matches = null,
int $flags = 0,
int $offset = 0
): ?string {
@twysto
twysto / gist:a9c8caf7a9a727814ec7bd3e3c4113b7
Last active November 10, 2022 09:54
Time spent (Hours minutes seconds) using Carbon
<?php // Run it at: https://web.tinkerwell.app
use Carbon\Carbon;
$datetime_start = Carbon::now()->subHours(1)->subMinutes(05)->subSeconds(42);
echo $datetime_start->format('Y-m-d H:i:s') . "\r\n";
$datetime_end = Carbon::now();
$timestamp_ms_end = $datetime_end->getTimestamp();
echo $datetime_end->format('Y-m-d H:i:s') . "\r\n";
@twysto
twysto / devsslcert.sh
Created October 7, 2021 06:27
Generate Local Development SSL Certificates
#/usr/bin/env bash
cat <<"HEREDOC"
____ __________ __ ______ __
/ __ \___ _ __ / ___/ ___// / / ____/__ _____/ /_
/ / / / _ \ | / / \__ \\__ \/ / / / / _ \/ ___/ __/
/ /_/ / __/ |/ / ___/ /__/ / /___ / /___/ __/ / / /_
/_____/\___/|___/ /____/____/_____/ \____/\___/_/ \__/
HEREDOC
var isSupportingTouchEvents = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
> "%USERPROFILE%\AppData\Local\atom\app-1.17.2\atom.exe" -cur_console:f:d:"C:\server\www":C:"%USERPROFILE%\AppData\Local\atom\app.ico"
cmd /k "%ConEmuDir%\..\init.bat" -cur_console:bs1T25V:d:"C:\server\www":C:"C:\cmder\icons\cmder.ico"
cmd /k "%ConEmuDir%\..\init.bat" -cur_console:bs2T50H:d:"C:\server\www":C:"C:\cmder\icons\cmder.ico"