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
| module Scratch where | |
| -- This impl. is incomplete. I'm sketching out a basic working proof-of-concept to help | |
| -- me better understand the Vigenere cipher. | |
| -- | |
| -- Conceptually, a faster, more complete version exists; this isn't it. | |
| import Data.Function ((&)) | |
| import Data.Map (Map) | |
| import qualified Data.Map as Map |
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
| { pkgs, ... }: | |
| { | |
| # Build a Haskell executable. This assumes a project directory with a | |
| # top-level Main.hs. It also applies a few commonly used language extensions. | |
| # Here is an overview of the arguments: | |
| # - `name`: You can find the result at ./result/$name | |
| # - `srcs`: Will be passed to `srcs` field of `pkgs.stdenv.mkDerivation`. | |
| # - `deps`: A function that accepts `hpkgs` and returns a list of Haskell | |
| # dependencies. |
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
| # As an exercise to stress-test my understanding of recursive descent parsers, | |
| # I'm attempting to write a JSON parser without referencing any existing BNF | |
| # descriptions of JSON or existing JSON parser implementations. | |
| # | |
| # I'm only parsing a subset of JSON: enough to parse `sample`. Here is the BNF | |
| # that I wrote to describe my expected input: | |
| # | |
| # expression -> object | |
| # object -> '{' ( STRING ':' expression ) ( ',' STRING ':' expression )* '}' | |
| # | array |
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
| def compute_hash(x): | |
| """ | |
| Compute a unique fingerprint for the string input, `x`, as an integer using | |
| the following equation: | |
| x[0] * P^0 + x[1] * P^1 + ... x[n-1] * P^(n-1) % M | |
| P and M are constants where P represents the next available prime number | |
| that's GTE the number of unique characters you'll be hashing. In the case of | |
| all lowercase characters, of which there are 26, the next available prime |
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
| def substring_exists(corpus, pattern): | |
| """ | |
| Return True if `pattern` appears in `corpus`. | |
| This function runs in O(m) time where n is equal to the length of | |
| `corpus`. To improve the efficiency of this algorithm, use a hashing | |
| function the reduces the number of collisions, which will consequently | |
| reduce the number of string-to-string, linear comparisons. | |
| """ | |
| m, n = len(corpus), len(pattern) |
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
| Declare @T Table ( | |
| task_id int, | |
| task_type VARCHAR(250), | |
| database_name VARCHAR(250), | |
| "% complete" INT, | |
| "duration(mins)" INT, | |
| lifecycle VARCHAR(250), | |
| task_info VARCHAR(1000), | |
| last_updated DATETIME, | |
| created_at DATETIME, |
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
| { pkgs, depot, ... }: | |
| let | |
| al = pkgs.callPackage | |
| ({ emacsPackages }: | |
| emacsPackages.trivialBuild { | |
| pname = "al"; | |
| version = "1.0.0"; | |
| src = ./al.el; | |
| packageRequires = |
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
| (* 1/n experiments in replacing Python with OCaml for some tasks. *) | |
| let n = ref 0 in | |
| while !n < 10 do | |
| print_string ".\n"; | |
| n += !n + 1; | |
| done;; |
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
| # pinned-release exposes a function that creates CI steps to release Terraform | |
| # changes at a particular git commit. | |
| # | |
| # CI should react to the following events: | |
| # - Changes to the Terraform source code. | |
| # - PR branch: terraform validate # @branch | |
| # - Changes to the revision at which we're pinning our Terraform releases. | |
| # - PR branch: terraform plan # @rev | |
| # - origin/main: terraform apply # @rev | |
| # |
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
| [("fname", "John"); ("lname", "Cleese"), ("age", 82)] | |
| |> List.remove_assoc "fname" | |
| |> List.cons ("fname", "Bill") |