Skip to content

Instantly share code, notes, and snippets.

View gmachado-nextreason's full-sized avatar

Gabriel Machado Santos gmachado-nextreason

View GitHub Profile
@carolosf
carolosf / ExplodeNestedArrayPhp
Last active April 12, 2023 09:06
Explode To Nested Array - Converts a string with a delimiter into a nested associative array and assigns the value to the final key
<?php
/**
* Converts a string with a delimiter into a nested associative array and assigns the value to the final key
* by Carolos Foscolos - I call this little algorithm bubble wrap - because it's like wrapping bubbles around each other
* explodeToNestedArray('.', 'abc.def', 'XYZ') becomes ['abc' => ['def' => 'XYZ']]
*
* @param string $delimiter
* @param string $key
* @param $value
*
@stmswitcher
stmswitcher / codecept.random.option.select.php
Last active February 11, 2023 05:40
Select random option for Codeception
$options = $I->grabMultiple('#selectID option', 'value');
$I->selectOption('select', $options[array_rand($options)]);
@rponte
rponte / get-latest-tag-on-git.sh
Last active July 4, 2024 10:55
Getting latest tag on git repository
# 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
@rdeavila
rdeavila / git-update-fork.sh
Last active September 6, 2024 14:00
Git: como atualizar um fork com as mudanças do original?
#!/bin/bash
# Adicione um novo remote; pode chamá-lo de "upstream":
git remote add upstream https://github.com/usuario/projeto.git
# Obtenha todos os branches deste novo remote,
# como o upstream/master por exemplo:
git fetch upstream