This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function colorBy(calId, colorRules) { | |
| const cal = CalendarApp.getCalendarById(calId); | |
| const startDate = new Date(); // now | |
| const endDate = new Date(); | |
| endDate.setMonth(endDate.getMonth()+1); | |
| const events = cal.getEvents(startDate, endDate); | |
| for (const [ftype, param, color] of colorRules) { | |
| let filtered = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # A CLI replacement for GitHub code search. | |
| # Requires: ripgrep, skim (sk), and bat. | |
| github_remote_url=$(gh repo view --json url --jq '.url') | |
| if [[ -z "$github_remote_url" ]]; then | |
| echo "error: no github url for current repository." | |
| exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # `gcloud auth application-default print-access-token` can also serve as a check | |
| # but takes a few seconds to run. POSTing directly to Google's oauth endpoint is | |
| # much faster. | |
| function check_adc { | |
| ADC_FILE="$HOME/.config/gcloud/application_default_credentials.json" | |
| [ ! -f "$ADC_FILE" ] && return 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Read JSON input from stdin | |
| input=$(cat) | |
| # Uncomment to debug what fields are available: | |
| #echo "$input" | jq '.' > /tmp/statusline-debug.json | |
| # Initialize status parts array | |
| status_parts=("$(echo "$input" | jq -r '.model.display_name')") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| gh run ls --all --workflow $1 --json databaseId -q ".[].databaseId" | xargs -n1 gh run delete |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defmacro -> (form &rest forms) | |
| (reduce | |
| (lambda (acc next) | |
| (if (listp next) | |
| (list* (car next) acc (cdr next)) | |
| (list next acc))) | |
| forms | |
| :initial-value form)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; AoC 2020 Day 4. Solve by generating a huge regex. | |
| (require '[clojure.string :as s]) | |
| (def sample-passports | |
| "ecl:gry pid:860033327 eyr:2020 hcl:#fffffd | |
| byr:1937 iyr:2017 cid:147 hgt:183cm | |
| iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Four methods to test if an integer is a power of two. | |
| * Compile with `-march=haswell`. | |
| */ | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <immintrin.h> | |
| #include <time.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python2 | |
| """ | |
| Soduko solver. Everybody writes one. | |
| """ | |
| sample = "003020600900305001001806400008102900700000008006708200002609500800203009005010300" | |
| all_bits = int('1'*9,2) | |
| def load_puzzle(s): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; https://twitter.com/sartanbegavhaum/status/1066051737650429952 | |
| (defn non-trivial-factors [n] | |
| (filter #(zero? (mod n %)) (range 2 n))) | |
| (def prime? (comp empty? non-trivial-factors)) | |
| (defn tomer-number? [n] | |
| (when-let [facts (seq (non-trivial-factors n))] | |
| (every? prime? facts))) |
NewerOlder