Skip to content

Instantly share code, notes, and snippets.

View galvao's full-sized avatar
😎
Rocking to the rythm of the sure shot beat

Er Galvão Abbott galvao

😎
Rocking to the rythm of the sure shot beat
View GitHub Profile
@galvao
galvao / devssh.sh
Last active November 9, 2023 18:48
Enables using a hardcoded password with ssh
#!/usr/bin/expect -f
# Requires: expect, spawn
spawn ssh-add
expect "Enter passphrase for /home/zaphod/.ssh/id_rsa:"
send "my_password"
interact
@galvao
galvao / convolutedCount.php
Created August 13, 2022 19:37
The most convoluted way of counting the entries in a collection?
<?php
/**
* Given a collection that implements the Iterator interface:
* @see https://www.php.net/manual/en/class.iterator
*/
return (int)!empty($collection->entries) * ($collection->key() + 1);
@galvao
galvao / factorialFactorial.php
Created May 26, 2022 02:34
Finding the factorial of a number, recursively
<?php
declare(strict_types = 1);
/**
* factorialFactorial
* Finding the factorial of a $number by recursion
*
* @author Er Galvão Abbott <galvao@php.net>
*/
@galvao
galvao / sshKeyCopy.sh
Created August 27, 2021 01:17
Copiando a chave ssh via terminal
sudo dnf -y update && sudo dnf -y install xclip && xclip -selection clipboard < ~/.ssh/NOME_DA_CHAVE.pub
@galvao
galvao / installVsCode.sh
Created August 18, 2021 14:27
Installing VsCode on Fedora
#! /usr/bin/bash
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
cat <<EOF | sudo tee /etc/yum.repos.d/vscode.repo
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
@galvao
galvao / lampInstall.sh
Created August 16, 2021 21:47
Installing a LAMP stack on Fedora
sudo dnf -y install httpd mariadb mariadb-server php-cli php-intl php-mbstring php-pdo php-sodium php-xml php-gd php-mysqlnd php-devel php-ffi php-fpm php-pear php-mbstring php-bcmath
@galvao
galvao / laravel54InstallWin.sh
Created May 11, 2021 16:25
Creating an older (5.4) Laravel on Windows' PowerShell, using one of php's version inside Laragon
C:\laragon\bin\php\php-7.2.19-Win32-VC15-x64\php C:\composer\composer.phar create-project --prefer-dist laravel/laravel C:\laragon\www\laravel54_example "5.4.*"
@galvao
galvao / ignoreChmod.sh
Created March 3, 2021 11:26
Git|: Ignoring chmod-changes on files
# Add the -c flag and set the core.fileMode option to false, e.g.:
git -c core.fileMode=false status
@galvao
galvao / datetimeimmutable.php
Created December 11, 2020 12:56
DateTimeImmutable example
<?php
$now = new DateTime();
$freeze = new DateTimeImmutable();
$now->setTimeZone(new DateTimeZone('UTC'));
$freeze->setTimeZone(new DateTimeZone('UTC'));
echo $now->format('Y-m-d H:i:s P');
// 2020-12-11 12:50:48 +00:00
$freeze->format('Y-m-d H:i:s P');
// 2020-12-11 09:50:51 -03:00
@galvao
galvao / promise.js
Created November 11, 2020 23:31
A simple example of Promises in JavaScript
console.clear();
function oddOrEven(n)
{
return new Promise((resolve, reject) => {
if (typeof(n) != 'number') {
reject(new TypeError('n must be a number'));
}
if ((n % 2) == 0) {