Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View guiliredu's full-sized avatar
🚀
Working

Guilherme Dias Redü guiliredu

🚀
Working
View GitHub Profile

progrium/bashstyle

Bash is the JavaScript of systems programming. Although in some cases it's better to use a systems language like C or Go, Bash is an ideal systems language for smaller POSIX-oriented or command line tasks. Here's three quick reasons why:

  • It's everywhere. Like JavaScript for the web, Bash is already there ready for systems programming.
  • It's neutral. Unlike Ruby, Python, JavaScript, or PHP, Bash offends equally across all communities. ;)
  • It's made to be glue. Write complex parts in C or Go (or whatever!), and glue them together with Bash.

This document is how I write Bash and how I'd like collaborators to write Bash with me in my open source projects. It's based on a lot of experience and time collecting best practices. Most of them come from these two articles, but here integrated, slightly modified, and focusing on the most bang for buck items. Plus some ne

@guiliredu
guiliredu / update-git.sh
Created October 4, 2021 23:03 — forked from YuMS/update-git.sh
Update git to latest version on Ubuntu
#!/bin/bash
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git -y
@guiliredu
guiliredu / apache-template
Created September 25, 2019 19:16 — forked from lavoiesl/apache-template
Apache VirtualHost Template with variable replacement
<VirtualHost *:80>
ServerAdmin {USER}@cslavoie.com
ServerName {DOMAIN}
ServerAlias www.{DOMAIN}
ServerAlias {USER}.localhost
ServerAlias {USER}.static.cslavoie.com
DocumentRoot {DOC_ROOT}
<Directory {DOC_ROOT}>
@guiliredu
guiliredu / headers.php
Created May 21, 2018 20:03 — forked from irazasyed/headers.php
PHP HTTP Headers (Examples)
<?php
# Source: http://www.jonasjohn.de/snippets/php/headers.htm
// Use this header instruction to fix 404 headers
// produced by url rewriting...
header('HTTP/1.1 200 OK');
// Page was not found:
header('HTTP/1.1 404 Not Found');
@guiliredu
guiliredu / zsh-on-windows.md
Created May 16, 2018 22:03 — forked from aviaryan/zsh-on-windows.md
Installing zsh and oh-my-zsh on Windows
  1. Install zsh from cygwin
  2. Install oh-my-zsh from https://github.com/robbyrussell/oh-my-zsh . Follow the manual instructions
  3. To make zsh default on ConEmu, create a task with C:\cygwin64\bin\mintty.exe /usr/bin/zsh - . Make it the defaut shell.
  4. To start a zsh shell on demand, add this batch script to your path or start menu or wherever.
start C:\cygwin64\bin\mintty.exe /usr/bin/zsh -
@guiliredu
guiliredu / README.md
Created November 23, 2017 13:23
PSR-2 Build System using Sublime Text

PSR-2 Build System using Sublime Text

Installation

Open a new terminal and install Composer:

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

Once that has finished installing and moved, install the PHP-CS-Fixer Composer package globally:

@guiliredu
guiliredu / php-storm-tips.md
Last active November 20, 2017 17:28 — forked from kurorido/gist:d8197e49434bf53e37cb
PHP Storm Tips

PHP Storm - Tips

Shortcuts

  • Ctrl+Alt+V (Refactor | Extract Variable)
  • Ctrl+D in the editor duplicates the selected block or the current line when no block is selected.
  • If the cursor is between the parentheses of a method call, pressing Ctrl+P brings up a list of valid parameters.
  • Ctrl+Shift+Backspace (Navigate | Last Edit Location)
  • Use Ctrl+Shift+F7 (Edit | Find | Highlight Usages in File) to quickly highlight usages of some variable in the current file.
  • Use F3 and Shift+F3 keys to navigate through highlighted usages.
@guiliredu
guiliredu / urlBase64ToUint8Array.js
Created August 21, 2017 17:33 — forked from malko/urlBase64ToUint8Array.js
used in pushManager.Subscribe to correctly encode the key to a Uint8Array
function urlBase64ToUint8Array(base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4);
const base64 = (base64String + padding)
.replace(/\-/g, '+')
.replace(/_/g, '/')
;
const rawData = window.atob(base64);
return Uint8Array.from([...rawData].map((char) => char.charCodeAt(0)));
}
@guiliredu
guiliredu / gist:7927b907c87a56c900f259189fbe92c5
Created August 7, 2017 18:47 — forked from johanmeiring/gist:3002458
"git lg" alias for pretty git log
# From http://garmoncheg.blogspot.com/2012/06/pretty-git-log.html
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
@guiliredu
guiliredu / gist:549ad23a5ecf1950265e502f3e7e8be6
Created June 6, 2017 12:53 — forked from plasticbrain/gist:3887245
PHP: mime types (array format)
<?php
$mime_types = array(
'.3dm' => 'x-world/x-3dmf',
'.3dmf' => 'x-world/x-3dmf',
'.a' => 'application/octet-stream',
'.aab' => 'application/x-authorware-bin',
'.aam' => 'application/x-authorware-map',
'.aas' => 'application/x-authorware-seg',
'.abc' => 'text/vnd.abc',
'.acgi' => 'text/html',