This file contains 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
defmodule WeatherWeb.WeatherLive do | |
use WeatherWeb, :live_view | |
@owm_url "https://api.openweathermap.org/data/2.5/weather?units=metric&lat=43.8999464&lon=-78.9408778&appid=XXX" | |
defmodule WeatherWeb.WeatherLive.WeatherSummary do | |
defstruct [:temperature, :name, :description, :icon] | |
end | |
alias WeatherWeb.WeatherLive.WeatherSummary |
This file contains 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
takahe-takahe-stator-1 | Traceback (most recent call last): | |
takahe-takahe-stator-1 | File "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", line 486, in thread_handler | |
takahe-takahe-stator-1 | raise exc_info[1] | |
takahe-takahe-stator-1 | File "/takahe/stator/models.py", line 172, in atransition_attempt | |
takahe-takahe-stator-1 | next_state = await current_state.handler(self) # type: ignore | |
takahe-takahe-stator-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
takahe-takahe-stator-1 | File "/takahe/users/models/password_reset.py", line 41, in handle_new | |
takahe-takahe-stator-1 | await sync_to_async(send_mail)( | |
takahe-takahe-stator-1 | File "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", line 448, in __call__ | |
takahe-takahe-stator-1 | ret = await asyncio.wait_for(future, timeout=None) |
This file contains 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 python3 | |
import requests | |
if __name__ == "__main__": | |
r = requests.get("https://testflight.apple.com/join/2bauS53v") | |
r.raise_for_status() | |
if "This beta is full" not in r.text: | |
r = requests.post("https://api.pushover.net/1/messages.json", data={ | |
"token": "PUSHOVER_TOKEN_HERE", |
This file contains 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
char*I="zcncrcnrrlccmhchssgqsqrsstfffnqfnfsswgwjjcmcnnvjvwjvwvfvnvwwhvv" | |
"wmwhmwwwhbhhldhdmhhdfdbdfbdblllnfllgslllqhlhfhlhqllncnfnsffwmwzzlglzlw" | |
"lhwwmvmddpvvbrvrdvrdvdhhzdhdpdzzbgbsssrpsrshrshhbqbgbmmtwwcbcrbbvnvhnn" | |
"cscwcwlcwlwnwswbbnwntthzzdlzdzffvqvdqvvtptdptphpddzzvhzvzwwqgqjjjvsspv" | |
"spsbsffvpvcvjcvjvrvjjgmjjhrrdhhdvhvttjttzptpssnlnjjlnnhmnndjnjwwtjjtbb" | |
"fflwfwgwvvpjpwpcwcgglmgmdmnmbbqtqctcwcmwwvmvlmvmdvdvhvlhlzhzttghttnvnj" | |
"ntnqqtmtwwhvhrhfhchqchhdrdllnwnfwfjjmsmmnhhshnhpptstjjpnpzzhmmpssgrsrz" | |
"srrffzjjhvjhjcjcpcvpccfnfjnfjfllssrdsdnnmffldldppcctcmtctffprpsrrrfhfm" | |
"flldccnpppvsswppdgpgjpgpqgpqpjppclcjczcnzzzqvzzwlzzqfzffsqqphqhvqqbccc" | |
"stsdttwcwcvvmjjhqqmllpglgtgwgnnbnrbnnjdndhhbrbvrvwwwblwwwppmdmttztqzqr" |
This file contains 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
class _NoPadding: pass | |
_Chunk_T = TypeVar("_Chunk_T") | |
def _windowed(iterable: Iterable[_Chunk_T], size: int, step: int = 1, padding: _NoPadding|Any = _NoPadding()) -> Iterable[Iterable[_Chunk_T|None]]: | |
it = iter(iterable) | |
chunk: List[_Chunk_T|Any] = [] | |
while True: | |
# Pop step items from the buffer | |
if chunk: |
This file contains 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
#[cfg(test)] | |
mod tests { | |
use std::convert::TryInto; | |
use std::num::TryFromIntError; | |
#[test] | |
fn it_works() { | |
let a = 1i16; | |
let b: Result<i8, TryFromIntError> = a.try_into(); | |
assert!(b.is_ok()); |
This file contains 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
// Random code from https://docs.microsoft.com/en-ca/learn/paths/rust-first-steps/ | |
use std::fmt; | |
trait Distance<T> { | |
fn distance(&self) -> T; | |
} | |
#[derive(Debug, PartialEq)] | |
struct Point<T> { |
This file contains 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
/* Advent of Code - 2015 Day 20 */ | |
#include <stdio.h> | |
#include <dispatch/dispatch.h> | |
int number_of_presents(int house) { | |
int n = 0; | |
for (int elf = 1; elf <= house; elf++) { | |
if ((house % elf) == 0) { | |
n += (10 * elf); |
NewerOlder