Skip to content

Instantly share code, notes, and snippets.

View fregante's full-sized avatar

Federico Brigante fregante

View GitHub Profile
@fregante
fregante / github-open-project-fields.user.js
Last active December 9, 2023 09:00
GitHub Open project fields
// ==UserScript==
// @name GitHub Open project fields
// @version 1.0.0
// @match https://github.com/*/issues/
// @match https://github.com/*/pull/
// @run-at document-end
// ==/UserScript==
function open() {
for (const button of document.querySelectorAll('collapsible-sidebar-widget:not([open]) [aria-label^="See more fields"]')) {
@fregante
fregante / for-osx.sh
Created March 24, 2023 05:28
Delete all the workflow runs for a specific workflow in GitHub Actions (gh-cli)
# Install gh-cli https://cli.github.com
# cd to the repo folder
# Replace "ci.yml" with the workflow name you want to delete
# Run this to delete them all (500 runs at a time)
gh run list --json databaseId -q '.[].databaseId' -w ci.yml --limit 500 |
xargs -IID -P 15 gh api \
"repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)/actions/runs/ID" \
-X DELETE
@fregante
fregante / devtools_page.html
Created October 22, 2022 18:46
Request permissions from devtool panel
<!DOCTYPE html>
<meta charset="utf-8" />
<script src="devtools_page.js"></script>
@fregante
fregante / background.worker.js
Last active September 30, 2022 07:09
MV3 lifetime test
// Respond to CS
const startTime = Date.now()
const delay = 13000;
chrome.runtime.onMessage.addListener( (message, sender, respond) => {
setTimeout(respond, delay, Math.round((Date.now() - startTime + delay) / 1000));
return true
})
// Overlapping fetch requests
console.log('will req');

title

Promise.reject(1).catch(err => {
if (err instanceof Error) {
throw err; // Exception
}
// Rejection
}).catch(exitProcess)
@fregante
fregante / README.md
Created February 9, 2017 07:47
Copy saved password bookmarklet

work-cli

Personal launcher to start working in whatever directory you're into. Customize it as needed

$ work
# tries launching GitHub.app
# tries launching Sublime Text
# tries launching the build tool (npm run watch, gulp, grump in this order)
@fregante
fregante / bookmarklet.js
Last active June 7, 2016 05:25
Play videos inline on the iPhone (bookmarklet)
// to be flattened with http://chriszarate.github.io/bookmarkleter/
var s = document.createElement('script');
s.onload = function () {
[].forEach.call(document.querySelectorAll('video'), makeVideoPlayableInline);
};
s.src='https://rawgit.com/bfred-it/ffd71c642d2fcf4649b230bd71bc9a93/raw/fb39a59c458aeb49d882d81c9d4be2b3ae0b3b93/enabler.js';
document.head.appendChild(s);
@fregante
fregante / show-reddit-posts.js
Last active February 25, 2016 06:38
Bookmarklet: show current url posted on Reddit
// Create bookmarklet with: https://ted.mielczarek.org/code/mozilla/bookmarklet.html
var getPermalink = post => 'https://www.reddit.com'+post.data.permalink;
var getPermalinks = r => r.data.children.map(getPermalink);
var buildLink = url => {
var a = document.createElement('a');
a.href = url;
a.textContent = url.match(/\/r\/[^/]+/) && url.match(/\/r\/[^/]+/)[0] || url;
a.style.display = 'block';
return a;
};