Skip to content

Instantly share code, notes, and snippets.

View lnfnunes's full-sized avatar
👽

Leandro Nunes lnfnunes

👽
View GitHub Profile
@lnfnunes
lnfnunes / unusedimages.js
Last active August 29, 2015 14:10
Grunt task to find unused images (cleanup image folder)
// Find unused images
grunt.registerTask('unusedimages', function() {
var arrImages = [],
arrImageReference = [],
destDir = '../htdocs/';
// Populate image list on folder
grunt.file.expand({
filter: 'isFile',
@lnfnunes
lnfnunes / gmail-no-proxy
Last active August 29, 2015 14:17
[bookmarklet] Remove gmail proxy from images
/**
* @author: doug2k1
**/
javascript:(function(){
var img = document.getElementsByTagName('img');
for(var i = 0, l = img.length; i < l; i++) {
var s = img[i].src;
if(s.indexOf('googleusercontent.com/proxy') !== -1) {
s = s.split('#')[1];
@lnfnunes
lnfnunes / jquery-removeClassSimilar
Last active August 29, 2015 14:17
[jQuery] Remove similar classes by wildcard " * "
/**
* @author: ThiefMaster
* @source: https://stackoverflow.com/a/8899812/1946632
**/
(function($) {
$.fn.removeClassSimilar = function(mask) {
return this.removeClass(function(index, cls) {
var re = mask.replace(/\*/g, '\\S+');
return (cls.match(new RegExp('\\b' + re + '', 'g')) || []).join(' ');
@lnfnunes
lnfnunes / sublime-icon.reg
Created May 13, 2015 18:55
Add Sublime Text icon to windows Context Menu
reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "C:\Program Files\Sublime Text 3\sublime_text.exe,0"
@lnfnunes
lnfnunes / dojo-js-jogo-pin.js
Created July 29, 2015 17:29
[dojo-js] Jogo do "PIN"
for (var i = 1; i<=40; i++) {
str = (i % 4 == 0) ? 'PIN<br />' : str = i;
document.querySelector('body').innerHTML += str + '<br />';
}
@lnfnunes
lnfnunes / git-commands.md
Last active March 24, 2018 20:00
Git commands

Temove all local branches not on remote

git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -D

Configure merge tool (meld)

git config --global merge.tool meld git config --global mergetool.meld.trustExitCode false // Fix git mergetool meld --help error git config mergetool.meld.hasOutput true

@lnfnunes
lnfnunes / linux-cmds
Last active March 15, 2018 13:28
Linux commands
// --------------------------------------------------
// Files and folders
-------------------------------------------------- //
// Copy specific file type keeping the folder structure
rsync -a --prune-empty-dirs --include '*/' --include '*.txt' --exclude '*' source/. dest
Ref: http://unix.stackexchange.com/a/83596
// Single line loop for repeated tasks with some variations on the command
arr=('jhon' 'jane' 'mike'); for name in "${arr[@]}"; do echo "$name"; done
@lnfnunes
lnfnunes / linux-setup
Last active May 21, 2016 04:04
Linux setup commands/programs
// --------------------------------------------------
// Install Node via NVM
-------------------------------------------------- //
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps
// --------------------------------------------------
// Install Atom via apt-get
-------------------------------------------------- //
sudo add-apt-repository ppa:webupd8team/atom -y && sudo apt-get update && sudo apt-get install atom -y
@lnfnunes
lnfnunes / Subset, all possible combinations
Last active June 7, 2017 05:00
HackerRank JS default snippet
function combinations(str) {
var fn = function(active, rest, a) {
if (!active && !rest) return;
if (!rest) {
a.push(active);
} else {
fn(active + rest[0], rest.slice(1), a);
fn(active, rest.slice(1), a);
}
return a;
@lnfnunes
lnfnunes / HackerRank - Helpers
Last active January 23, 2017 22:15
HackerRank helper (math) functions
/**
* Fast modular exponentiation for i ^ n % modulus
* Used when exp is a extremely large number, ie: Math.pow(2, 400);
* @returns {number}
*/
function fastModularExponentiation(i, n, modulus) {
if (modulus == 1) return 0;
var c = 1;
for (var e = 1; e <= n; e++) {