Skip to content

Instantly share code, notes, and snippets.

View matheusfaustino's full-sized avatar
💪
Daily workout: git push, git pull

Matheus Faustino matheusfaustino

💪
Daily workout: git push, git pull
View GitHub Profile
@matheusfaustino
matheusfaustino / steam_deck_install_yay.sh
Created April 4, 2024 20:18
Install YAY on steam deck commands
# Allow to write over file system (steam os block)
sudo steamos-readonly disable
# Ensure we have the keys updated
sudo pacman-key --init
sudo pacman-key --populate archlinux
sudo pacman-key --populate holo
sudo pacman -S glibc linux-api-headers
# Install git and base-devel dependencies
@matheusfaustino
matheusfaustino / nvm_change_by_dir.sh
Created June 16, 2022 09:43
Zsh function to change nodeJS version per project (directory) using NVM
# Add at the end of your .zshrc file
# After every command `cd`, it checks if there is a ".nvmrc" file in the current directory and if it exists it changes the version of nodejs automatically
# Create a .nvmrc file like this: `echo "v16.15.0" > .nvmrc` in the folder you want to use the specific version of nodejs
function nvm_change_by_dir() {
emulate -L zsh
if [ -f ".nvmrc" ]; then
NODEJS_VERSION=$(cat .nvmrc);
COMMAND="nvm use"
@matheusfaustino
matheusfaustino / scripts.sh
Created June 1, 2020 18:39
pre/post script with some tweaks for running better overwatch on linux using lutris (ubuntu 20.04 - gnome)
#overwatch-pre-script.sh
#!/bin/bash
xrandr --output HDMI-1 --primary --left-of eDP-1 # change primary display to monitor, instead of the notebook's display
gsettings set org.gnome.desktop.peripherals.mouse accel-profile 'flat' # remove mouse acceleration from gnome to respect mouse DPI
sleep 3 #just to give "time" for the things
##### Other script/file
#overwatch-post-script.sh
#!/bin/bash
@matheusfaustino
matheusfaustino / phpbrew_change_by_dir.sh
Last active April 29, 2020 19:06
Zsh function to change php version per project (directory) using phpbrew
# Add at the end of your .zshrc file
# After every command `cd`, it will check a ".phpbrew" file in the current directory and if it exists it will change the version of php automatically
# Create a .phpbrew file like this: `echo "7.4.4" > .phpbrew` in the folder you want to use the specific version of php
function phpbrew_change_by_dir() {
emulate -L zsh
if [ -f ".phpbrew" ]; then
PHPBREW_LOCAL_VERSION=$(cat .phpbrew);
COMMAND="phpbrew use ";
@matheusfaustino
matheusfaustino / youtube_audio_video.sh
Created January 27, 2020 02:49
Download youtube video setting a period of time and extract audio from it
#!/bin/bash
function title(){
echo "##########################"
echo "## $1 ##"
echo "##########################"
}
# first param is the CSV file
FILE_CSV=$1
/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@matheusfaustino
matheusfaustino / index.php
Created January 3, 2019 22:42
POC: PHP + RSA + Front JS (JS Encrypt)
<?php
$rsaPriv = __DIR__ . '/priv.pem';
$rsaPub = __DIR__ . '/pub.pem';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$encrypted = $_POST['pass'];
$ok = \openssl_private_decrypt(base64_decode($encrypted), $decrypted, file_get_contents($rsaPriv), OPENSSL_PKCS1_PADDING);
var_dump($decrypted, $ok);
@matheusfaustino
matheusfaustino / install.sh
Created December 10, 2018 00:48
PHPBrew + PHP 7 (PHP 7.0/7.1/7.2/7.3) + Raspberry Pi 3
# How to install phpbrew
# https://github.com/phpbrew/phpbrew
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
chmod +x phpbrew
sudo mv phpbrew /usr/local/bin/phpbrew
# build openssl in your raspberry (it takes some time): https://raspberrypi.stackexchange.com/a/66788
git clone git://git.openssl.org/openssl.git
cd openssl
./config
@matheusfaustino
matheusfaustino / log.php
Created September 27, 2018 13:25
Monolog stdout and file log
<?php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
require './vendor/autoload.php';
// create a log channel
$log = new Logger('name');
$log->pushHandler(new StreamHandler('your.log', Logger::WARNING));
@matheusfaustino
matheusfaustino / share-files.sh
Created September 11, 2018 19:16
Nautilus script that uploads a file to transfer.sh and returns a link to share the file w/ notification (used to share images)
#!/bin/sh
trim() {
local var="$*"
# remove leading whitespace characters
var="${var#"${var%%[![:space:]]*}"}"
# remove trailing whitespace characters
var="${var%"${var##*[![:space:]]}"}"
echo -n "$var"
}