Skip to content

Instantly share code, notes, and snippets.

Petto Martino pettomartino

Block or report user

Report or block pettomartino

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
pettomartino / retry.js
Last active Mar 12, 2019
Retry promise
View retry.js
const retry = (fn, options = {}) => new Promise((resolve, reject) => {
const { retryInterval = 500, retries = 1 } = options;
.catch(err => (
(retries === 0)
? reject(err)
: setTimeout(
() => retry(fn, { retryInterval, retries: retries - 1 }).then(resolve, reject),
pettomartino / script.conf
Created May 22, 2018
execute a command on start up ubuntu
View script.conf
# save it on /etc/init
start on startup
exec /path/to/command
View index.html
function myFunc() {
var email = document.getElementById("email").value
var e = document.getElementById("select")
var selectedOption = e.options[e.selectedIndex].value
var checkBox = document.getElementById('defaultCheck1').checked
if (email == 'foo@bar' && checkBox && selectedOption == "audi") {
View test2.js
.setValue('input[placeholder=E-mail]', email)
.setValue('input[placeholder=Password]', password)
.expect.element("//*[text()='John Doe']")
View test1.js
.setValue('.input-text', email)
.setValue('input.input-text[type=password]', password)
View MockPromise.js
class MockPromise {
then(fn) {
this.thenFn = fn
return this
catch(fn) {
this.catchFn = fn
return this
pettomartino / gist:6425ede3460758b3e54d
Created Sep 25, 2014
Packer log error with parallels
View gist:6425ede3460758b3e54d
petto@mac ~/dev/bento/packer (master●)$ packer build --only=parallels-iso debian-7.6-amd64.json [ruby-2.1.1]
parallels-iso output will be in this color.
==> parallels-iso: Downloading or copying ISO
parallels-iso: Downloading or copying:
==> parallels-iso: Starting HTTP server on port 8081
==> parallels-iso: Creating virtual machine...
==> parallels-iso: Executing: prlctl [create packer-debian-7.6-amd64 --distribution debian --dst packer-debian-7.6-amd64-parallels --vmtype vm]
==> parallels-iso: Executing: prlctl [set packer-debian-7.6-amd64 --cpus 1]
==> parallels-iso: Executing: prlctl [set packer-debian-7.6-amd64 --memsize 512]
View replace-mongo.js
var cursor = db.places.find();
while (cursor.hasNext()) {
var x =;
x['source']['url'].replace('aaa', 'bbb'); // is this correct?{_id : x._id}, x);
View gist:4676702
var allJs = document.getElementsByTagName('script'),
lastJs = allJs[allJs.length-1],
logoJs = document.createElement('script');
logoJs.src = '';
View gist:1227577
{u'noite': [[u'MACRO_CITY:1', u'sao_paulo'], [u'MACRO_CITY:39', u'belo_horizonte'], [u'MACRO_CITY:41', u'porto_alegre'], [u'MACRO_CITY:36', u'rio_de_janeiro']], u'shows': [[u'MACRO_CITY:36', u'rio_de_janeiro'], [u'MACRO_CITY:1', u'sao_paulo'], [u'MACRO_CITY:41', u'porto_alegre'], [u'MACRO_CITY:39', u'belo_horizonte']], u'turismo': [[u'MACRO_CITY:1', u'sao_paulo'], [u'MACRO_CITY:39', u'belo_horizonte'], [u'MACRO_CITY:41', u'porto_alegre'], [u'MACRO_CITY:36', u'rio_de_janeiro']], u'cinema': [[u'MACRO_CITY:39', u'belo_horizonte'], [u'MACRO_CITY:41', u'porto_alegre'], [u'MACRO_CITY:36', u'rio_de_janeiro'], [u'MACRO_CITY:1', u'sao_paulo']]}
You can’t perform that action at this time.