Skip to content

Instantly share code, notes, and snippets.

View fabriceleal's full-sized avatar
😫
meh

Fabrice Ferreira Leal fabriceleal

😫
meh
  • Leiria, Portugal
View GitHub Profile
@fabriceleal
fabriceleal / gist:5865950
Created June 26, 2013 09:13
Create file-as-black-hole
ln -s /dev/null php.log
@fabriceleal
fabriceleal / gist:5812580
Created June 19, 2013 08:18
git compare branches
# http://stackoverflow.com/questions/9834689/compare-two-branches-in-git
# https://www.kernel.org/pub/software/scm/git/docs/git-diff.html
# Normal diff
git diff a_branch..master
# Only filenames
git diff --numstat a_branch..master
@fabriceleal
fabriceleal / gist:5776544
Last active December 18, 2015 11:38
Polymorphism in Javascript
Object.prototype.test = function(){ console.log('an object')};
Array.prototype.test = function(){ console.log('an array')};
Number.prototype.test = function(){ console.log('a number')};
var a = {};
a.test(); // prints "an object"
a = [];
a.test(); // prints "an array"
@fabriceleal
fabriceleal / gist:5766186
Created June 12, 2013 15:15
Manage cached network credentials
rundll32.exe keymgr.dll, KRShowKeyMgr
@fabriceleal
fabriceleal / gist:5755525
Created June 11, 2013 09:12
Git: How to remove file from history
# From http://stackoverflow.com/a/8741530
git filter-branch --index-filter 'git rm --cached --ignore-unmatch Smarty/templates_c/*' --tag-name-filter cat -- --all
@fabriceleal
fabriceleal / gist:5755234
Created June 11, 2013 08:16
How to recursively find and list the latest modified files in a directory with subdirectories and times?
# From http://stackoverflow.com/a/7448828/1647507
find . -type f -exec stat --format '%Y :%y %n' {} \; | sort -nr | cut -d: -f2- | head
@fabriceleal
fabriceleal / gist:5669525
Last active February 19, 2016 09:42
mysql - usefull stuff with users
-- http://dba.stackexchange.com/questions/13083/cant-remove-grant-usage
-- in host, use '%' as wildcard
grant usage on *.* to 'user'@'host' identified by 'password';
grant all privileges on database.* to 'user'@'host';
show grants;
show grants for user;
show grants for user@host;
grant super on *.* to 'user'@'host' identified by 'password';
@fabriceleal
fabriceleal / gist:5669132
Created May 29, 2013 09:35
Size of a folder
# for .
du -chs
# for any
du -chs any
@fabriceleal
fabriceleal / gist:5547487
Last active December 17, 2015 03:59
Bookmarklet to import fartscroll.js (imports jquery 1.9.1 if cant find jQuery).
(function(){
var a = function(){
var y = document.createElement('script');
y.onload = function(){ jQuery(document).fartscroll(600) };
y.src="https://raw.github.com/theonion/fartscroll.js/master/fartscroll.js";
document.head.appendChild(y);
};
if(typeof jQuery == 'undefined') {
var x = document.createElement('script');
x.onload = a;