Skip to content

Instantly share code, notes, and snippets.

View anmarco's full-sized avatar

André Marco Pereira anmarco

View GitHub Profile
#!/bin/bash
changed_files=$(git diff --name-only --diff-filter=d HEAD | grep '\.py$')
for file in $changed_files; do
isort "$file"
black "$file"
done
@anmarco
anmarco / sanitizer.js
Last active March 20, 2023 19:20
A function that takes crappy invalid json and returns a valid one (y)
const sanitizeJSON = function (badJSON) {
return badJSON
.replace(/:\s*"([^"]*)"/g, function(match, p1) {
return ': "' + p1.replace(/:/g, '@colon@') + '"';
})
.replace(/:\s*'([^']*)'/g, function(match, p1) {
return ': "' + p1.replace(/:/g, '@colon@') + '"';
})
.replace(/(['"])?([a-z0-9A-Z_]+)(['"])?\s*:/g, '"$2": ')
.replace(/@colon@/g, ':')
@anmarco
anmarco / cage.js
Created February 10, 2019 02:20
change images to nicolas cage photo
var nr = 0;
function cage() {
var resources = performance.getEntriesByType("resource");
if (resources.length > nr){
nr = resources.length
var imgs = document.getElementsByTagName('img')
Array.from(imgs).forEach((e)=>{e.setAttribute('src', 'https://i.imgur.com/a4CBVXS.png')})
return
}
return