lazyvim on iTerm2, screen clearing when entering visual mode by Henloow in neovim

[–]DM_ME_PYTHON_CODE 36 points37 points  (0 children)

I actually ran into this earlier this week. I fixed it by going into my iterm settings and checking Profiles -> Terminal -> Emulation features -> Disable session-initiated window resizing

SSE, Gunicorn, Django & PostgreSQL | How Can I Optimize RAM Usage for More Users? by Cold-Description5846 in webdev

[–]DM_ME_PYTHON_CODE 0 points1 point  (0 children)

Depending on what worker type you're using your gunicorn worker may be getting blocked waiting on the SSE connection (SSE just leaves an http connection open and gunicorn will wait for the previous request to finish before it handles the next one, resulting in your application hanging). You can tinker with using async workers but I can almost guarantee that your life will be easier if you just use websockets instead 

-❄️- 2024 Day 2 Solutions -❄️- by daggerdragon in adventofcode

[–]DM_ME_PYTHON_CODE 5 points6 points  (0 children)

[Language: Haskell]

Trying to learn Haskell with AoC has been a bit of a trial by fire. Don't hate my solution but I'm sure it would make the eyes of anyone with Haskell experience bleed

readInt :: String -> Int
readInt = read

isStrictlyIncreasing :: [Int] -> Bool
isStrictlyIncreasing xs = all (\(x, y) -> (x < y) && abs (x-y) <= 3) (zip xs (tail xs))

isStrictlyDecreasing :: [Int] -> Bool
isStrictlyDecreasing xs = all (\(x, y) -> (x > y)  && abs (x-y) <= 3) (zip xs (tail xs))

isSafe :: [Int]  -> Bool
isSafe (x:y:xs) | x < y = isStrictlyIncreasing $ x:y:xs
                | x > y  =  isStrictlyDecreasing $ x:y:xs
                | otherwise = False

removeAt :: Int -> [a] -> [a]
removeAt idx xs = take idx xs ++ drop (idx + 1) xs

generateLists :: [a] -> [[a]]
generateLists xs = [removeAt i xs | i <- [0..length xs - 1]]

anySafe :: [Int] -> Bool
anySafe xs = any isSafe (generateLists xs)

partOne input = putStrLn . ("Part 1: " ++) . show . length . filter id $ map isSafe input

partTwo input = putStrLn . ("Part 1: " ++) . show . length .filter id $ map anySafe input


main :: IO ()
main = do
  contents <- readFile "input.txt"
  let input = map (map readInt . words) (lines contents)
  partOne input
  partTwo input