Skip to content

Instantly share code, notes, and snippets.

// Grab all Ruff rule categories from the Ruff docs.
// Run this in the browser console on https://docs.astral.sh/ruff/rules/.
const R = await import("https://esm.sh/ramda@0.29.1");
R.pipe(
R.tail,
R.pluck("innerText"),
R.map(R.match(/\(([A-Z0-9]+(?:, *[A-Z0-9]+)*)\)/)),
R.map(R.last),
R.chain(R.split(", ")),
@heyajulia
heyajulia / How to Update Python using Pyenv.md
Created April 22, 2024 15:30
How to Update Python using Pyenv

Here's what I do:

pyenv install $NEW_VERSION
pyenv uninstall $OLD_VERSION
pyenv global $NEW_VERSION
pyenv rehash # idk if this is needed
pip install pipx
pipx reinstall poetry
gh api graphql --cache 1h --jq '.data.repository.milestone.issues.edges[] | {(.node.number|tostring): [.node.assignees.edges[].node.login] | length}' --paginate -f query='query ($endCursor: String) {
repository(owner: "microsoft", name: "vscode") {
milestone(number: 8) {
issues(first: 1000, states: [OPEN], after: $endCursor) {
edges {
node {
number
title
assignees(first: 10) {
edges {
Given a string, return the shortest "unambiguous abbreviation" of that string.
Assume that your input string is a non-empty string consisting of lowercase letters (a-z) and spaces.
Example:
UnambiguousAbbreviation("peter piper picked a peck of pickled peppers") = "pet pip picke a pec o pi p"
Initially, the word bank looks like:
use rand::distributions::Uniform;
use rand::Rng;
use rayon::prelude::*;
use std::time::Instant;
fn main() {
let dis = Uniform::from(0..=6_u8);
for trials in (1..).map(|x| 10usize.pow(x)) {
let start = Instant::now();
cityNames = {"New York", "Geneva", "Nairobi", "Vienna", "The Hague"}
cities = Interpreter["City"] /@ cityNames
populations = #[EntityProperty["City", "Population"]] & /@ cities
Print[NumberForm[Total[populations], DigitBlock -> 3]] (* 15,376,617 people *)
@heyajulia
heyajulia / generate_pi.raku
Last active January 31, 2023 10:40
Inspired by Matt Parker’s video “Generating π from 1,000 random numbers” (https://youtu.be/RZBhSi_PwHU)
unit sub MAIN(UInt :s(:$sides) = 120, UInt :r(:$rolls) = 1_000);
sub roll-die { (1..$sides).roll }
my $coprimes = 0;
for ^$rolls {
my $a = roll-die();
my $b = roll-die();
unit sub MAIN();
use XML;
use XML::Query;
sub get-urls($file-name) {
my $xml = from-xml-file($file-name);
my $xq = XML::Query.new($xml);
my $urls = $xq('outline[type=rss]').elements.map(*<xmlUrl>);
@heyajulia
heyajulia / output.md
Last active January 15, 2023 12:25
A graph of all/most of the named characters of The Adventure Zone: Steeplechase.

Steeplechase characters

#include <iostream>
#include <utility>
#include <vector>
#include <numeric>
auto SumNumbers(const std::vector<int>& numbers) -> std::pair<int, int> {
int even_sum = 0;
int odd_sum = 0;
for (const int number : numbers) {