Skip to content

Instantly share code, notes, and snippets.

View andersonmadeira's full-sized avatar
⚔️
waging war against boredom, semicolons, and long code statements

Anderson Madeira andersonmadeira

⚔️
waging war against boredom, semicolons, and long code statements
View GitHub Profile
@andersonmadeira
andersonmadeira / get_changed_files_in_commit.sh
Created October 31, 2018 20:59
Exibir todos os arquivos que foram alterados em um determinado commit
# trocar hash pelo começo ou todo o hash do commit
git show --pretty="" --name-only hash
# Exemplo:
git show --pretty="" --name-only 8f9831a35767
# Pra exibir a quantidade de arquivos que foram alterados basta adicionar o wc com a opção -l
git show --pretty="" --name-only 8f9831a35767 | wc -l
@andersonmadeira
andersonmadeira / commit_tree.sh
Created October 31, 2018 20:58
Ver a árvore de commits e branches no console
git log --all --decorate --oneline --graph
@andersonmadeira
andersonmadeira / remover_acentos.js
Created October 31, 2018 20:57
Retirar acentos
(function removerAcentos( string ) {
var mapaAcentosHex = {
a : /[\xE0-\xE6]/g,
A : /[\xC0-\xC6]/g,
e : /[\xE8-\xEB]/g,
E : /[\xC8-\xCB]/g,
i : /[\xEC-\xEF]/g,
I : /[\xCC-\xCF]/g,
o : /[\xF2-\xF6]/g,
O : /[\xD2-\xD6]/g,
@andersonmadeira
andersonmadeira / settings.json
Created May 2, 2018 11:14
My visual studio code settings
{
"explorer.openEditors.visible": 0,
"editor.fontSize": 13,
"workbench.colorTheme": "Zeus-Sublime-Text",
"editor.renderLineHighlight": "none"
}
@andersonmadeira
andersonmadeira / make_random_array.js
Created April 19, 2017 13:31
Make Random Array of Numbers
(function(numberOfElements, digits) { return new Array(numberOfElements).fill(0).map(function f(v) { return Math.floor( Math.random() * (digits == 1 ? 10 : Math.pow(10, digits)) + (digits == 1 ? 0 : Math.pow(10, digits)) ); } ); })(10,1);
@andersonmadeira
andersonmadeira / local_ip.sh
Last active August 29, 2015 14:23
Find local IP
# In a Linux System, it will print your local IP address:
/sbin/ifconfig|grep inet|head -1|sed 's/\:/ /'|awk '{print $3}'
@andersonmadeira
andersonmadeira / convert_svg_to_png.sh
Created February 26, 2015 19:51
Convert many png to svg files
for i in `find .`; do rsvg-convert $i -o `echo $i | sed -e 's/svg$/png/'`; done
@andersonmadeira
andersonmadeira / wp_custom_media_uploader_change_author.php
Last active August 29, 2015 14:05
A very simple custom media uploader that enables the uploader to change the author
<?php
/**
* Media Library administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once( './admin.php' );
@andersonmadeira
andersonmadeira / wp_change_author.php
Last active August 29, 2015 14:05
Programmatically change media author on upload
<?php
/**
* Add this chunk of code to your functions.php (your theme)
* This hook will called when an attachment created.
* http://codex.wordpress.org/Plugin_API/Action_Reference/add_attachment
**/
add_filter( 'add_attachment', 'f77_change_author_attachment_author' );
@andersonmadeira
andersonmadeira / green_prompt.sh
Created May 23, 2014 16:43
Cool green prompt for Debian
# add these lines to your ~/.bashrc file
fortune | cowsay
PS1="\[\033[01;32m\][\w]\[\033[01;34m\]:\$\[\033[00m\] "