Skip to content

Instantly share code, notes, and snippets.

@gasparportik
gasparportik / on_console.js
Created February 9, 2022 09:43
Expand all 'Load diff' sections in a GitHub PR
$x(`//button[contains(., 'Load diff')]`).forEach(btn => btn.click())
@gasparportik
gasparportik / gh_diff_commit_messages.js
Last active August 8, 2022 10:33
One-liner to get a list of all commit messages for a branch compare
// for use in devtools console
console.log([...document.querySelectorAll('#commits_bucket .Details > p:first-child')].map(x => x.innerText).join("\n").replace(/…/g,''))
// for use in bookmark(prepend `javascript:`)
prompt('copy this:', [...document.querySelectorAll('#commits_bucket .Details > p:first-child')].map(x => x.innerText).join("\n").replace(/…/g,''))
@gasparportik
gasparportik / pr_diff_sort.js
Created May 4, 2020 16:04
Sort PR files by changes
(() => {
const diffCount = (elem) => Number((elem.querySelector('.diffstat').attributes['aria-label']?.value||'0').split(' ')[0]);
const files = document.getElementById('files');
Array.from(files.querySelectorAll('.file')).sort((a,b) => (a = diffCount(a),b=diffCount(b),a - b))
.forEach((item) => (item.remove(),files.appendChild(item)));
})()
window.xpathStringEscape = (s) => (s.includes('"') && `'${s}'`) || (s.includes("'") && `"${s}"`) || `concat("${s.replace(/"/g, `",'"',"`)}")`;
ActiveRecord::Base.connection.execute("UPDATE ...")
ActiveRecord::Base.connection.execute("SELECT ...").each {|r| puts r.inspect}
Rails.logger.debug(ActiveSupport::LogSubscriber.new.send(:color, "D:#{var}", :red))