Skip to content

Instantly share code, notes, and snippets.

View danilodeveloper's full-sized avatar
🤙
Building things

Danilo Barsotti danilodeveloper

🤙
Building things
View GitHub Profile
@danilodeveloper
danilodeveloper / gist:89f5c62aca0c624958ad
Created August 27, 2015 15:00
Trocar o provedor de serviços do UOL Host (.br) para outro provedor (ou nenhum)
- Acesse https://registro.br/cgi-bin/nicbr/stini
- Digite o Usuário e SENHA
- Clique em ENTRAR
- Clique no aba TITULARIDADE
- Clique em Editar informações
@danilodeveloper
danilodeveloper / gist:784c679216efddd8f08d
Last active August 29, 2015 14:24
Herança no Javascript usando new e Object.create
// http://jsfiddle.net/0s8kzoke/
console.log('----VEHICLE DEFINITION----');
function Vehicle(name, model, speedLimit) {
// prevent the scope error when the programmer forgot the
// 'new' keyword before call the constructor.
if (!(this instanceof Vehicle)){
return new Vehicle(name, model, speedLimit);
}
@danilodeveloper
danilodeveloper / gist:dd2d0b383bc7287d7c32
Created June 24, 2015 18:44
Uso de prototype e new no Javascript
function Pessoa(nome) {
if(!this instanceof Pessoa) {
return new Pessoa(nome);
}
this.nome = nome;
}
Pessoa.prototype.getNome = function() {
return this.nome;
}
// No Node.js é melhor usar o Util.inherits (https://nodejs.org/docs/latest/api/util.html#util_util_inherits_constructor_superconstructor)
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Animal = (function () {
function Animal(name) {
@danilodeveloper
danilodeveloper / gist:82b3f919316c89a3222b
Created May 21, 2015 18:03
Estratégia para Classes e Instâncias no Javascript
var nome = 'creudovaldo';
console.log('--------------');
var Pessoa = (function() {
// Construtor
function Pessoa(nome) {
this.nome = nome;
}
// Metodo de instancia, todos que instanciam Pessoa deveriam ter acesso
var Foo = {
init: function(who) {
this.me = who;
},
identify: function() {
return "I am " + this.me;
}
};
Foo.create = function() {
@danilodeveloper
danilodeveloper / keep_last_4_builds_and_delete_rest.groovy
Last active September 8, 2016 01:46
Groovy script - Jenkins - How to keep the last 4 builds and delete the rest
hudson.model.Hudson.instance.items.findAll{job -> job.isBuildable() && job.name.contains("stb")}.each{
job ->
println("Job : ${job.name}");
builds = jenkins.model.Jenkins.instance.getItem(job.name).getBuilds().reverse();
for(i = 0; i < builds.size() - 4; i++){
builds[i].delete();
println(" Build - ${builds[i]} - Deleted With Success.");
}
println(" Deleted Builds - ${builds.size()}");
}