Skip to content

Instantly share code, notes, and snippets.

Ernando Souza ernandojs

Block or report user

Report or block ernandojs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ernandojs
ernandojs / mojave-rubygem-install.md
Last active Oct 2, 2018
Usage of gem package installation without sudo on MacOS Mojave
View mojave-rubygem-install.md
$ brew install rbenv ruby-build
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc
$ source ~/.zshrc

Install Ruby

$ rbenv install 2.5.0
$ rbenv global 2.5.0
$ ruby -v
@ernandojs
ernandojs / ubuntu17.10-afterinstall
Last active Dec 27, 2017
Ubuntu 17.10 afterinstall
View ubuntu17.10-afterinstall
#!/bin/bash
NC='\033[0m'
CO='\033[0;31m'
USER='ernjs'
function display {
echo -e "$CO $1 $NC"
}
@ernandojs
ernandojs / docker-compose-environment.sh
Last active May 3, 2018
Docker compose scaffold with MariaDB + PHP 7 + Composer + Yarn
View docker-compose-environment.sh
# Docker compose environment scaffold using MariaDB and PHP 7, with Data Container for
# the database and without permission issues with mounted volumes (docker -v)
########################
###### Dockerfile ######
########################
```
FROM php:7.0.18-apache
# Basic tools and dependencies
@ernandojs
ernandojs / windows10-uefi-stick.sh
Last active Jul 20, 2017
Make a bootable Windows 10 UEFI USB Stick
View windows10-uefi-stick.sh
# Let the device unmounted
sudo umount /dev/sdb
# Optional: change the content to zeros
sudo dd if=/dev/zero of=THE_DEVICE bs=512 count=1
# Normally this is not nessecary. Then to create a new layout on the drive:
sudo fdisk /dev/THE_DEVICE
# Then:
@ernandojs
ernandojs / strpad-left.js
Created Jun 28, 2017
Pad left a string with a given number of characters
View strpad-left.js
strPadLeft(string, length, char) {
const str = '' + string;
let pad = '';
for (let i = 0; i < length; i++) {
pad += char;
}
return pad.substring(0, pad.length - str.length) + str;
@ernandojs
ernandojs / php-function-singleton.php
Last active Jul 20, 2017
Returns each time called the same instance using functions, not methods in OOP
View php-function-singleton.php
<?php
# Returns each time called the same instance using functions, not methods in OOP
if ( ! function_exists('logger')) {
function logger() {
static $logger;
if ( ! $logger) {
$logger = new Logger('starlight');
@ernandojs
ernandojs / utf8.php
Last active Jun 23, 2017
Recursively encode to UTF-8 a given array
View utf8.php
<?php
# Recursively encode to UTF-8 a given array
public function utf8(array $array)
{
array_walk_recursive($array, function(&$item, $key) {
if(is_string($item) && ! mb_detect_encoding($item, 'utf-8', true)) {
$item = utf8_encode($item);
}
@ernandojs
ernandojs / fedora25-afterinstall.sh
Last active Oct 4, 2017
Fedora 25|26 Afterinstall - Things TODO
View fedora25-afterinstall.sh
#!/bin/bash
NC='\033[0m'
CO='\033[0;31m'
function display {
echo -e "$CO $1 $NC"
}
display "RPM FUSION FREE AND NONFREE"
@ernandojs
ernandojs / gtrack.md
Last active Aug 18, 2017
Alias for automatically setup tracking for origin in new branches and other useful git commands
View gtrack.md
# Automatically setup remote tracking for new branches

$ git config --global push.default current



# Make local repository current branch exactly like remote

$ currentBranch=git rev-parse --abbrev-ref HEAD
@ernandojs
ernandojs / .gitignore
Last active Apr 5, 2017
Useful policies of .gitignore
View .gitignore
# Just add any subfolder in uploads path with a .gitkeep file in it to
# ignore all the files except the directory
# this doesnt work
public_html/uploads/**/*
!/**/.gitkeep
# instead, name it every directory that needs to ignore files
public_html/uploads/moduleSuperCool/*
You can’t perform that action at this time.