Skip to content

Instantly share code, notes, and snippets.

View benjaffe's full-sized avatar

Ben Jaffe benjaffe

View GitHub Profile
- Ingredients:
- 1 pound of dry Royal Corona beans (or other big beans)
- 1 whole onion - diced
- 1 whole preserved lemon - seeded and diced
- 8(ish) cloves of garlic
- 1 tsp salt
- 1/4 tsp thyme (optional)
- 1/2 to 1 (ish) cup of olive oil
- Instructions:
@benjaffe
benjaffe / add-github-buttons-to-graphite
Last active February 21, 2024 18:41
JS to add Github buttons to Graphite (especially great with Arc Browser Boosts)
function isGraphitePr() {
return window.location.hostname === 'app.graphite.dev' && window.location.pathname.includes('/github/pr/')
}
function makeGithubPrUrl() {
const pieces = window.location.pathname.replace('/github/pr/', '').split('/');
return `https://github.com/${pieces[0]}/${pieces[1]}/pull/${pieces[2].split('/')[0]}/`;
}
// fn determines whether the element should hide itself
@benjaffe
benjaffe / open-on-github.js
Last active January 6, 2023 23:43
Bookmarklet code for opening a github link from a graphite page
(()=>{
if (window.location.hostname === 'app.graphite.dev' && window.location.pathname.includes('/github/pr/')) {
const pathname = window.location.pathname;
const pieces = pathname.replace('/github/pr/', '').split('/');
const githubUrl = `https://github.com/${pieces[0]}/${pieces[1]}/pull/${pieces[2].split('/')[0]}/`;
window.open(githubUrl);
}
}
)();
@benjaffe
benjaffe / .js
Created February 20, 2022 15:53
Custom JS for displaying emoji before page names that have a given prefix
// =============================================================================
// v0.0.1 2022_0220_0749 by Ben Jaffe
// The following custom JS allows you to put an emoji before any page with a given prefix
// You can define as many customizations as you want.
// title (optional): makes the generated css prettier, but you won't see it anyway
// prefix (required): the prefix it matches against
// prefixChar (required): it must be a single character/emoji
// color (optional): will change the color of the matched text
// =============================================================================
const customizations = [
/**
* This calculator tries to distribute however many strings you want over whatever
* range you want using the same approximate distribution of gauges on Ernie Ball
* strings. Replace the following three numbers (16, 9, 42) with your preferences.
* To run this code, open any window in Google Chrome and open the JavaScript Console
* (View => Developer => JavaScript Console), then paste all of this code in and
* press enter. It should print your answer in the console. Tweak numbers and re-run
* as much as you want
*/
@benjaffe
benjaffe / get-GMT-date.js
Created November 21, 2019 19:53
gets a GMT date object, regardless of your timezone.
const thisMoment = new Date();
const gmtDate = new Date(thisMoment.getTime() + thisMoment.getTimezoneOffset() * 1000 * 60);
console.log(gmtDate);
html {
filter: brightness(0.8) contrast(130%) invert(100%) brightness(1.5) hue-rotate(180deg);
}
@benjaffe
benjaffe / skip-mono-profiles.js
Last active February 14, 2020 05:26
On OkCupid DoubleTake: Skips users who have their profile set to Monogamous, and alerts "OMG" when it finds users who are set to Non-Monogamous
let alerted = false;
setInterval(() => {
const elem = document.getElementsByClassName('matchprofile-details-text')[0];
if (elem && elem.textContent && elem.textContent.includes('Non-monogamous')) {
if (!alerted) {
alert('omg')
alerted = true;
}
} else if (elem && elem.textContent && elem.textContent.includes('Monogamous')) {
alerted = false;
// Run this on https://www.musicgenreslist.com/ to select a random genre and search spotify for it
let genres, chooseGenre;
genres = genres || Array.from(document.getElementsByTagName('li'))
.filter(elem => elem.innerHTML === elem.textContent);
chooseGenre = chooseGenre || (() => {
const choice = genres[Math.floor(Math.random() * genres.length)];
const parenIndex = choice.textContent.indexOf(' (');
const text = parenIndex < 0 ? choice.textContent : choice.textContent.slice(0, parenIndex);
/*
Copyright (c) 2011 Andrei Mackenzie
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE