Skip to content

Instantly share code, notes, and snippets.

View marcomontalbano's full-sized avatar

Marco Montalbano marcomontalbano

View GitHub Profile
@marcomontalbano
marcomontalbano / http-request-logger.md
Last active September 14, 2023 15:23
Log all incoming http requests using Deno.

HTTP Request Logger

Log all incoming http requests.

This is useful when you want to test webhooks locally!

Usage

Run this deno command first:

@marcomontalbano
marcomontalbano / array-methods.js
Last active December 7, 2022 21:17
Javascript array methods visually explained.
['💻', '📺', '💻', '💻'].filter(value => value === '💻'); // => ['💻', '💻', '💻']
['💻', '💻', '📺', '💻'].every(value => value === '💻'); // => false
['💻', '💻', '💻', '💻'].every(value => value === '💻'); // => true
['💻', '📺', '💻', '💻'].some(value => value === '💻'); // => true
['💻', '📺', '📺', '💻'].fill('📱', 1); // => ['💻', '📱', '📱', '📱']

CodePen - POST to Prefill Editors

example here: https://jsfiddle.net/gh/gist/library/pure/03b4395edb4fdc76407c6ab83edcfbe8

To pre-fill a Pen with code and options you choose, you can POST to https://codepen.io/pen/define/ with data, where the value of data is JSON containing all the bits you want pre-filled. Here is a simple example:

<form action="https://codepen.io/pen/define" method="POST" target="_blank">
 
@marcomontalbano
marcomontalbano / css-variables.md
Last active January 16, 2020 13:24
How to create a progress bar that changes its background-color dynamically using css variables. https://jsfiddle.net/gh/gist/library/pure/ad353132ce5f013c84be7c30565f8980
@marcomontalbano
marcomontalbano / bitbucket.js
Last active March 10, 2020 16:00
Bitbucket Helpers :)
function getCommits(includeMerge = false) {
return Array.from(document.querySelectorAll(`.commits-table tbody tr${ includeMerge ? '' : ':not(.merge)' }`)).map(e => ({
...(JSON.parse(e.dataset.commitJson)),
isMerge: e.classList.contains('merge')
}))
}
function getBranches() {
return Array.from(document.querySelectorAll('#branch-list tbody tr:not(.base-branch)')).map(e => ({
name: e.querySelector('.branch-name-column').innerText,

beep.js

Use new Audio() to beep.

@marcomontalbano
marcomontalbano / mysqldump.sh
Created February 24, 2017 21:57
Ignore tables using MySQL Dump
# usage: ./dump.sh
HOST=127.0.0.1
USER=root
DATABASE=database
OUTPUT=dump.sql.zip
EXCLUDED_TABLES=(
table1
table2
tableN
@marcomontalbano
marcomontalbano / .bash_completion_ssh.sh
Last active February 2, 2017 11:47
Bash Completion for SSH
# MIT License
#
# Copyright (c) 2016 Marco Montalbano
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: