Skip to content

Instantly share code, notes, and snippets.

@Dennis960
Dennis960 / cq_serialize.py
Created March 9, 2025 09:45
register function to be able to pickle cadquery (OCP) objects
"""
MIT License
Copyright (c) 2022 Simon Dibbern
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@Dennis960
Dennis960 / VigenereCipher.hs
Created December 6, 2023 23:16
Haskell vigenereCipher
import Data.Char (chr, ord, toLower, isLetter)
-- | Vigenere Cipher
vigenereCipher2 :: String -> String -> String
vigenereCipher2 message key = zipWith (curry shiftCharByKey) message (prepareKey message key) where
-- | Prepares the key to skip foreign chars by setting the key to 'a' at these positions and repeats the key so it matches the messages length
prepareKey :: String -> String -> String
prepareKey [] _ = []
prepareKey (m:message) (k:key) = if isLetter m then k : prepareKey message (key ++ [k]) else 'a' : prepareKey message (k : key)
-- | Shifts a character depending on the position of the key's character in the alphabet