- Load up the respective websites.
- Run script in console.
- Click button to run test.
- Results will be printed out to the console.
for day_offset in (seq 0 0) | |
for hour in (seq 16 22) | |
set open_table_url 'https://www.opentable.com/restref/api/availability?lang=en-US' | |
set session_token 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvdGNmcCI6IjQ0MTM2ZmEzNTViMzY3OGExMTQ2YWQxNmY3ZTg2NDllOTRmYjRmYzIxZmU3N2U4MzEwYzA2MGY2MWNhYWZmOGEiLCJpYXQiOjE2NjM4MTAwODAsImV4cCI6MTY2MzgyMDg4MH0.boXS_p4VyIuAGinPb3-DCwBmUIazcckOQnm4itzgAQw' | |
set house_prime_rib_id 1779 | |
set timestamp ( date -d"2022-11-30 +$day_offset days +$hour hour") | |
curl $open_table_url -s -X POST -H 'Content-Type: application/json' -H $session_token --data-raw (printf '{"rid":%s,"dateTime":"%s","partySize":2,"enableFutureAvailability":true,"transformOutdoorToDefault":false}' $house_prime_rib_id $timestamp) | \ | |
jq --color-output --sort-keys '.availability |to_entries[] | [.key, .value.timeSlots]' | |
end | |
end |
(* | |
Applescript to toggle to laptop speakers. | |
Based on code by tetsujin: https://apple.stackexchange.com/a/218223 | |
This is more dynamic, as ordering of items is not guaranteed. Sources exist temporarily, | |
such as bluetooth headsets or headphone jack. | |
Motivation: | |
This script use case is to toggle between the built-in speakers (always exist) and the intended headset. | |
I'd toggle this to temporarily switch to laptop speakers for presentation or to step away from computer | |
but want to continue to receive sound notifications. |
Neovim was taking a long time to start up but only on my laptop. Like 2 seconds long. This didn't happen on a shared aws dev box, which led me to thinking this was maybe hardware or OS filesystem caching issue. Here's what I did to debug and get to the bottom of the mystery.
The first step was to sanity check how slow this was.
A common analysis is counting values, grouped on common attribute. e.g. What are the counts of passing, failing, missing tests.
IN SQL, we can do this:
SELECT name, status, COUNT(*)
FROM tests
WHERE date > NOW() - INTERVAL 30 DAY
AND name IN ('test1', 'test2')
GROUP BY name, status
Fizzbuzz in different languages
Someone once declined to write fizzbuzz because they had recently only been doing shell programming. And, therefore, my request was invalid and unfair since it's not a real language.
So, for funsies, I'm going to demonstrate that you can write fizzbuzz in turing complete languages. Not an incredible feat, more of a refutation of said argument.
This gist demonstrates the difference between threading and asyncio. To be clear, they're both limited by the Global Interpreter Lock and are both single process, multi-threaded. They are both forms of concurrency but not parallelism.
Threading (via Thread, concurrent.futures) employs time-slicing of CPU. All threads are given a slot of CPU time to do work. If the thread is blocking (sleeping or blocked on sockets), then off it goes to the next thread. With many threads that are blocked for long periods, this begins to degrade into polling (polling vs. interrupt)
Imagemagick is hard to use and the documentation/tutorials available are not intuitive. Here is a concise explanation of what needs to be done to edit a gif to add labels.
convert foo.gif \ # Specify the original gif
-gravity center -pointsize 30 -font ComicSans \ # Set font position and styling
-duplicate 1,0-20 \ # Clone frames and append to the end (clone frame once)
'(' -clone 21-40 -fill white -annotate -0-150 'Hello' -set delay 6 ')' \ # Clone frames, add 'Hello', and slow down gif delay for only these frames
-duplicate 1,41-89 \ # Clone frames and append to the end (clone frame once)