Skip to content

Instantly share code, notes, and snippets.

@favio41
favio41 / regex
Last active August 29, 2015 13:57
Regex usefull
Sublime regex for remove _id from export
, "_id" : \{ "\$oid" : ".*?" \}
Regex not greedy
* - zero or more
*? - zero or more (non-greedy)
+ - one or more
@favio41
favio41 / Javascript loggin
Created July 10, 2014 15:33
client log substitution
var log = Function.prototype.call.bind(console.log, console);
var error = Function.prototype.call.bind(console.error, console);
var info = Function.prototype.call.bind(console.info, console);
//Syntatic sugar to add methods to any function faster
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
//Example
//for any class...
function HelloClass(){
var oldObj = {
first: function() {},
second: function() {}
};
var newObj = Object.create(oldObj);
newObj.third = function() {};
//In this way we prevent 2 things:
// 1- Polute the global scope
// 2- The creation of the array name each time digitToName is called
var digitToName = (function(digit){
var names = ['one', 'two', 'tree']
return function(){
return names[digit];
}
}());
@favio41
favio41 / handy.sh
Created March 23, 2016 11:47
Linux handy commands
Show the filename without line breaking, and wait for changes.
less -S +F filename
console.table({
"01 - moment('2016-04-14T00:00:00+00:00').format()": moment('2016-04-14T00:00:00+00:00').format(),
"02 - moment.utc('2016-04-14T00:00:00+00:00').format()": moment.utc('2016-04-14T00:00:00+00:00').format(),
"03 - moment('2016-04-14T00:00:00+01:00').format()": moment('2016-04-14T00:00:00+01:00').format(),
"05 - new Date('2016-04-14T00:00:00+00:00')": new Date('2016-04-14T00:00:00+00:00'),
"04 - new Date(Date.parse('2016-04-14T00:00:00+00:00'))": new Date(Date.parse('2016-04-14T00:00:00+00:00')),
"09 - moment('2016-04-14T00:00:00+00:00').tz('Europe/London').format()": moment('2016-04-14T00:00:00+00:00').tz('Europe/London').format(),
"10 - moment.utc('2016-04-14T00:00:00+00:00').tz('Europe/London').format()": moment.utc('2016-04-14T00:00:00+00:00').tz('Europe/London').format(),
});
@favio41
favio41 / cloudformation.yml
Created September 19, 2018 11:00
AWS cloudformation user creation with programmatic access and s3 policy
AWSTemplateFormatVersion: '2010-09-09'
Resources:
# Setup an user
user:
Type: AWS::IAM::User
Properties:
UserName: !Join
- '-'
- - 'changeme'
@favio41
favio41 / .gitconfig
Last active March 14, 2023 08:36
Alias for .gitconfig
[alias]
ready = !"git fetch --all && git checkout develop && git pull --rebase && git fetch-main && git branch --no-color | grep -v main | grep -v develop | xargs -r git branch -D"
graph1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
graph2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
graph = !"git graph1"
fetch-develop = fetch origin develop:develop
fetch-master = fetch origin master:master
fetch-main = fetch origin main:main
amend = commit -a --amend
undo = reset --soft HEAD~1
@favio41
favio41 / brew-java-and-jenv.md
Created February 14, 2019 17:00 — forked from tomysmile/brew-java-and-jenv.md
How To Install Java 8 on Mac

Install HomeBrew first

brew update
brew tap caskroom/cask
brew install brew-cask

If you get the error "already installed", follow the instructions to unlink it, then install again: