Commit graph

16647 commits

Author SHA1 Message Date
Griffin Smith
64ef09c475 feat(whitby): Move wigglydonke.rs to whitby
Mugwump is too unstable for such an important internet service

Change-Id: Ic714200ce5ce51f366777f538b4a6f443f010960
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2124
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 22:55:49 +00:00
Griffin Smith
9a24294b8a feat(tvix): Add a pos field to more expr classes
To aid in both debugging and (eventually) printing stacktraces, add a
Pos member to a few more Expr variants.

Change-Id: Ic1d2a056fc7e6c07bc3e79fa38845cb4a5da5ca5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2133
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 21:59:58 +00:00
Griffin Smith
9f4d37e5df feat(ops/nixos): Give all nixoses a config.depot
Add the depot.nix module and a depot config option to all nixos system
derivations that're build through the `bin/rebuild-system` machinery.
I can't imagine a scenario where we wouldn't want this level of
integration.

Change-Id: Ieeb98db2eee23919256adb4654bc45d540e055ec
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2128
Tested-by: BuildkiteCI
Reviewed-by: lukegb <lukegb@tvl.fyi>
2020-11-22 21:59:58 +00:00
Griffin Smith
58efa6df5b fix(panettone): Prefix all IRC messages with a ZWSP
Prefix all IRC notifications from panettone with a unicode
zero-width-space so that they don't get picked up by other IRC
bots (notably bslsk05).

Change-Id: I350fd1b6d2145e496c22a8f56ba3530fc9f1a978
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2127
Tested-by: BuildkiteCI
Reviewed-by: lukegb <lukegb@tvl.fyi>
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 21:59:58 +00:00
Griffin Smith
92a1f72f41 feat(panettone): Send notifications when issues are closed
Send an irc notification when issues are marked closed, in a similar
format to the notifications sent when new issues are created.

Change-Id: I2fdde33f0dedc223a5c2265eed778161938f8e9a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2126
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-22 21:59:58 +00:00
multi
96eac23250 fix(users/multi/home): re-add overridden htop package to home-manager configuration.
I previously removed my local package set from my HM config while the
latter was being made readTree compatible. Now that both the HM config
and the local package set can be built with readTree, I can re-enable
the locally-overridden htop package.

Change-Id: I77e20248c010bc7027e0b0a3164ec48d6ec29f31
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2132
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 20:29:47 +00:00
multi
a5ee01a827 refactor(user/multi/pkgs): make my local package set readTree-compatible.
This adds readTree configuration for accessing my local package set,
and also adds these packages to the CI configuration.

Change-Id: Icd2d16e85859343902e73a466f3c6ba8d781537f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2131
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 20:29:47 +00:00
multi
ba9fb4e112 fix(users/multi/home): use local depot checkout.
This reverts 1478317d149539d74fa4bad8414658fb7119ea07.

Using depot.depotPath in my home-manager configuration results in my
NIX_PATH and home-manager config file path being pointed at a copy of
the depot in the nix store, which makes building from my local depot
checkout a bit cumbersome.

Change-Id: Ib687d3e8147cb32df071d3c19a5300294ea62c0c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2130
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 20:29:47 +00:00
multi
7ff2142f19 refactor(users/multi): migrate whitby home-manager config to readTree-compatible version.
Add a new home-manager-compatible configuration file which loads the
common config attrset used by the readTree machinery into a structure
which the home-manager command line tool understands.

Garbage-collect the old home-manager configuration file used on whitby,
and update the HOME_MANAGER_CONFIG path to point at the new shim config.

Instead of having a per-environment HM configuration (not that I have
more than one environment), there's now a single configuration which
evaluates to an attrset of configurations, which can be loaded and built
using "home-manager build -A $attr".

Change-Id: Id8b35dc89aabffedf1a4dadfa0d3d4b914e4e2e7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2129
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 20:29:47 +00:00
multi
69244064da refactor(users/multi): make my user directory CI-compatible.
My home-manager config is not currently readTree compatible, which means
that it's not built by CI. This constructs a house of cards around
home-manager to make this buildable in CI.

Change-Id: I80480f24ff47347f46d708edbbf34d59fa76adac
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2123
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 19:48:15 +00:00
multi
9d6d945f52 refactor(users/multi/whitby): use the depot's own source location attribute.
The depot knows where it is, not because it knows where it isn't, but
because it does an "import ./." at the top level and then makes this
path value available in the attrset passed to the rest of the tree.

My home-manager config on whitby previously involved manual
specification of the depot checkout location on whitby, however this
isn't necessary when the depot can already magically tell us where it
is.

Change-Id: I68577c8ef2cda6ba5bc46cf8f4821aac021c8066
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2122
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
2020-11-22 19:48:15 +00:00
Griffin Smith
1e43982c92 feat(panettone): Bring back + fix irccat issue creation announcement
This reverts commit e1067b1497.

The original issue here was misusing ISSUE-ID instead of ID, but also
the associated username for the message should've been CN instead of DN

Change-Id: I1629c0cb7597ff2ee2867f27870378eecdafe126
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2125
Tested-by: BuildkiteCI
Reviewed-by: eta <eta@theta.eu.org>
2020-11-22 18:57:44 +00:00
multi
7dcd518c35 fix(users/multi/whitby): fix home-manager configuration on whitby.
"let pkgs = import <nixpkgs> {}; in pkgs.home-manager.src" evaluates to
the source derivation for home-manager, however home-manager's configuration
machinery expects to be passed the store path of this derivation instead of the
derivation object itself.

Change-Id: I6b0ba3efaff9d080900349529576443192b058e9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2121
Reviewed-by: multi <depot@in-addr.xyz>
Tested-by: BuildkiteCI
2020-11-21 23:42:34 +00:00
Vincent Ambo
5a00e58904 chore(3p): Bump nixpkgs to nixos-unstable from 2020-11-21
Included fixes for random breakage:

* 3p/awscli: pick from the stable channel; it is broken on unstable
* 3p/googletest: bumped version & removed patches that nixpkgs applies
* 3p/lisp/cffi: bumped library version for SBCL compat
* 3p/nix: fix libsystemd attribute
* 3p/nix: reformatted (clang-format handling of ternaries changed)
* glittershark/home: Use home-manager from nixkpgs
* glittershark/kernel: bumped linux-ck patch hash
* glittershark/kernel: removed "patch patch"
* multi/whitby: Use home-manager from nixpkgs
* tazjin/frog: drop Sourcetrail (it doesn't build currently)

Note that in addition to these changes, some previous CLs updated the
versions of git and cgit which was necessary for this channel bump,
but which could not be done in the same commit due to the nature of
the subtree merges.

Change-Id: If2563e8a68e2750c4b913a976ff7b93b42e8b7f3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2110
Tested-by: BuildkiteCI
Reviewed-by: multi <depot@in-addr.xyz>
Reviewed-by: glittershark <grfn@gws.fyi>
2020-11-21 23:18:27 +00:00
Vincent Ambo
e908882610 fix(glittershark/kernel): Ensure kernel changes cachebust linux-ck
Previously changed kernel versions would not cachebust the patch
download, because it would still be using the same SHA hash.

Forcing a different store path (by adding the version to the name)
also forces a redownload of the patch (and in turn cause the hash to
mismatch), avoiding this as a silent cause of failures in channel
updates.

Change-Id: I81a136ee2401126795cf042b0aadf2a1e7a707b4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2114
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
2020-11-21 23:18:27 +00:00
Vincent Ambo
cd652b3b22 fix(3p/cgit): Rename remaining 'sha1' references to 'oid'
This changed upstream & upstream-upstream, but was still used in our
patches.

Change-Id: Id33f868a4f188deb3348425276bc5b4c4b36aff9
2020-11-21 20:09:42 +01:00
Vincent Ambo
1e81ce6622 merge(3p/cgit): subtree merge at adcc4f82
Change-Id: I16941629a17a2f39b9324cb85dc0cec6b104dfe4
2020-11-21 20:09:33 +01:00
Vincent Ambo
f4609b896f merge(3p/git): Merge git subtree at v2.29.2
This also bumps the stable nixpkgs to 20.09 as of 2020-11-21, because
there is some breakage in the git build related to the netrc
credentials helper which someone has taken care of in nixpkgs.

The stable channel is not used for anything other than git, so this
should be fine.

Change-Id: I3575a19dab09e1e9556cf8231d717de9890484fb
2020-11-21 19:45:56 +01:00
William Carroll
c00eed469c Solve "cafe order checker" (again)
Perhaps my fifth iteration of solving this problem.
2020-11-21 16:31:53 +00:00
William Carroll
6ccdb06717 Solve "permutation palindrome" (again)
Python's `collections` library really shines for this problem.
2020-11-21 16:24:14 +00:00
William Carroll
60d7ea5b91 Implement a queue using two stacks
The space cost is O(n). The runtime cost of enqueue is O(1); the runtime cost of
dequeue is O(n). Using the "accounting method", the cost of an item in the
system is O(1). Here's why:

+------------+----------------------------+------+
| enqueue    | push onto lhs              | O(1) |
+------------+----------------------------+------+
| lhs -> rhs | pop off lhs; push onto rhs | O(1) |
+------------+----------------------------+------+
| dequeue    | pop off rhs                | O(1) |
+------------+----------------------------+------+
2020-11-21 16:15:43 +00:00
Vincent Ambo
082c006c04 merge(3p/absl): subtree merge of Abseil up to e19260f
... notably, this includes Abseil's own StatusOr type, which
conflicted with our implementation (that was taken from TensorFlow).

Change-Id: Ie7d6764b64055caaeb8dc7b6b9d066291e6b538f
2020-11-21 15:48:57 +01:00
William Carroll
417d3b5fff Implement a bottom-up fibonacci
The bottom-up solution run in O(n) time instead of O(2^n) time, which the
recursive solution runs as:

```
def fib(n):
    return fib(n - 2) + fib(n - 1)
```

Remember that exponential algorithms are usually recursive algorithms with
multiple sibling calls to itself.
2020-11-21 14:48:12 +00:00
William Carroll
70e74a4027 Solve "linked-list-cycles"
Write a predicate for checking if a linked-list contains a cycle. For additional
practice, I also implemented a function that accepts a linked-list containing a
cycle and returns the first element of that cycle.
2020-11-21 14:47:18 +00:00
Vincent Ambo
cc27324d02 chore(tvix): Use StatusOr API available in Abseil's version
The Abseil version of `StatusOr` does not come with the status macros
or the `Consume*` family of functions.

This change modifies the existing code to use the common denominator
of the API that is available between Abseil's own implementation of
`StatusOr` and the one from Tensorflow that we are currently using.

Change-Id: I5c37f68636a1fd54d153f95d7303ab8644abb774
2020-11-21 15:26:02 +01:00
William Carroll
cbdac30643 Reimplement bst-checker
Practice makes perfect. See the previous commit for a more details about this
solution.
2020-11-21 14:21:05 +00:00
William Carroll
2b5bbb98ca Refactor existing bst-checker implementation
I believe the previous solution is invalid. This solution works and it should be
more time and space efficient.

Space-wise our stack grows proportionate to the depth of our tree, which for a
"balanced" BST should be log(n). Doing a BFT on a BST results in memory usage of
n because when we encounter the leaf nodes at the final level in the tree, they
will be 1/2 * n for a balanced BST.
2020-11-21 14:14:50 +00:00
William Carroll
1dc6695a47 Solve merge-sorted-arrays (again)
InterviewCake.com has a section on Facebook's interview, so I'm attempting to
solve all of the problems on there even if that means I'm resolving
problems. The more practice, the better. Right?

URL: interviewcake.com/facebook-interview-questions
2020-11-21 13:41:33 +00:00
William Carroll
0ccaa22032 Solve "find duplicate" using a graph
This problem is unusually difficult, but the solution is elegant.
2020-11-21 13:35:05 +00:00
Vincent Ambo
cce0ad1bcd chore(tazjin/emacs): Minor cleanup of unused modes and config
Change-Id: I38c6a32339bf7606b733a938b4e55df2506a13a7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2107
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-11-21 13:27:20 +00:00
William Carroll
847aad2a14 Implement the Levenstein "edit distance" algorithm
This is the mother of dynamic programming algorithms in my opinion. It computes
the minimal "edit distance" between two input strings where an edit is
considered one of:
  - inserting a character into `a`
  - deleting a character from `a`
  - substituting a character in `a` with a character from `b`

It took me awhile to grok the algorithm, but I implemented this from my
understanding of something that I read ~3 nights prior, so I must've understood
what I read. Good news!
2020-11-20 21:59:18 +00:00
William Carroll
f652ea0be6 Solve "count islands" problem
This morning, I attended the "Interview Club" and was asked this question by the
interviewer in front of ~20 FTEs. While I struggled to fully solve it during the
abridged (i.e. 20 minute) timeslot, I completed the problem afterwards.

Here is my solution.
2020-11-20 21:32:22 +00:00
William Carroll
fa717e8a6f Re-implement suffix_tree function
Create a suffix tree from an input string. This implementation uses a stack to
control the flow of the program.

I expected this attempt to be easier than my first attempt, but surprisingly, it
was similarly difficult. It took me ~30-45 minutes to successfully implement
this function, and I'm still not pleased with the final result.
2020-11-19 21:12:36 +00:00
William Carroll
1088e4143d Implement a suffix tree
While it took me awhile to implement, this exercise was definitely worth
doing. I think there should be a more elegant way to construct the tree using
maybe a stack, but I couldn't find it.

All of this was part of a larger effort to search a string for a variety of
patterns. The solution is to compile the string into a suffix tree and then
search the suffix tree for each of the patterns.

I'm glad I didn't gloss over this exercise.
2020-11-19 00:35:23 +00:00
Griffin Smith
8d24a975f1 fix(tvix): Use copy constructor to add strings to protos
Passing a string directly to add_paths like this causes the proto class
to take ownership over the string, meaning when it is destructed it
will *explicitly* free the string. When the string's actual owner (the
derivation struct) then goes out of scope it'll get freed again, causing
a double-free. This fixes that to instead use the copy constructor to
assign to a pointer to a new path, and covers the whole to_proto method
with a rapidcheck test.

Fixes: b/64
Change-Id: I84235bed9104ff430a0acf686d4a96f1e2e9a897
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2106
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-11-19 00:29:42 +00:00
Griffin Smith
20e206a3f6 fix(tvix): Use mutable field for assigning proto fields
This was accidentally using the proto arena API to assign the derivation
field of a BuildDerivationRequest. We *thought* this was causing a
double free, but even with this change that's still happening. That
said, this change is probably still a good idea since it's using the
proto API as intended.

References: b/64
Change-Id: I950a4eafb214e9113639ea54d2dfd4659b7be931
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2104
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-19 00:29:42 +00:00
glittershark
e1067b1497 revert(panettone): announce newly created issues using irccat
This reverts commit 2e2bdf9c6c.

Reason for revert: this is not working, and is resulting in newly created issues just showing a blank page (b/74)

Change-Id: I3f06afc52d6c5289269402fc75bb32ad9c376bf4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2082
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-11-19 00:29:28 +00:00
multi
4331bc8da7 chore(users/multi): Update htop derivation for new upstream.
- htop has moved upstreams, which has been producing new releases, so
  update the derivation to pull from the new repository on GitHub.

- All of the patches I have locally have been merged upstream, so drop
  them from the depot.

- Pull from a reasonably recent git commit instead of from a numbered
  release, as the ZFS ARC stats and CPU meter columnation patches
  haven't made it into a release yet.

Change-Id: I66ad4c035df07709abf4f75a9d4e1486920091d0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2105
Reviewed-by: multi <depot@in-addr.xyz>
Tested-by: BuildkiteCI
2020-11-18 00:29:58 +00:00
William Carroll
c0268ed31a Refactor random-choice
Prefer initializing `result` to an empty array of size `m`, which makes the
algorithm a bit more elegant.
2020-11-17 23:54:54 +00:00
Vincent Ambo
73c862279a feat(ops/pipelines): Check in the static pipeline
This file represents the static pipeline which is configured in the
Buildkite web UI. Updates to this file should be applied in the admin
interface.

These steps are responsible for launching the dynamic pipeline
evaluation, or falling back to the fallback pipeline if evaluation fails.

Change-Id: I6d7dd623cde65e8c69faea729f737c9bba00c2fb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2103
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
2020-11-17 22:33:11 +00:00
Vincent Ambo
1857334d37 feat(ops/pipelines): Add a fallback Buildkite configuration
This adds a simple fallback Buildkite pipeline configuration which
always fails the pipeline, but correctly reports back the failure
status.

Note that this also requires changes in the Buildkite configuration
that is not in version-control.

Relates to b/66.

Change-Id: I6802a6f76448c3893798a06d514e6ccba0f50dd2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2102
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
2020-11-17 22:33:11 +00:00
William Carroll
751b5327a9 Solve algorithms dealing with randomness
Tonight I learned that random sample where each element in the sampling corpus
has an equal likelihood of being chosen is a brand of algorithms known as
"reservoir sampling".

- Implement random.shuffle(..)
- Implement random.choice(..)

Surprisingly, candidates are expected to encounter problems like this during
interviews.
2020-11-17 22:28:24 +00:00
Vincent Ambo
77097f8056 feat(ops/panettone): Add configuration for irccat
Adds configuration options for the (inconsistently named) environment
variables that configure irccat integration with Panettone.

The defaults match the irccat setup on whitby.

Change-Id: I6857512a2e3f29f16777493eb981cc69ce3c045f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2080
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-11-17 22:00:52 +00:00
William Carroll
572fb0fe5f Solve "nearby words" function
Given an input like "gello" suggest an correction like "hello".

This is a proof-of-concept problem for writing a simplistic auto-correction
algorithm for a mobile device.
2020-11-16 17:17:28 +00:00
William Carroll
6989c3a91a Implement the Rabin Karp string matching algorithm
This algorithm is pretty interesting because it runs in linear time with respect
to the length of the `corpus` string. It does this by using a sliding window
hash. This hash -- because it's a sliding window -- runs in constant time for
each iteration; we're only adding and subtracting one character each time and
not re-hashing the whole "window".

When our hashes match, only then do we compare the "window" to the
`pattern`. String comparisons are linear because they compare each character to
each character one at a time. But because we only compare strings when are
hashes match (a check which runs in constant time), this spares us the
performance hit.
2020-11-16 17:14:08 +00:00
William Carroll
a2fa88f561 Prefer mutative variant of delete for HashTable
Instead of calling `filter(..)`.
2020-11-16 17:13:39 +00:00
William Carroll
a457a81bbb Add another solution to the "move zeroes to end" problem
Support the optimally performance solution of which I'm aware.
2020-11-16 17:13:03 +00:00
William Carroll
ff08b723db Solve "find pairs for sum"
I have encountered this problem 3x in the wild thus far:
  1. www.InterviewCake.com
  2. Cracking the Coding Interview
  3. www.Pramp.com
2020-11-16 17:12:05 +00:00
William Carroll
92ab94943e Start working on the "Hard" problems
Firstly, implement a function that adds two arguments together... without using
the `+` operator. I need to drill this problem. Thankfully I took a Coursera
course that taught me how to make a half-adder and a full-adder, but the
recommended solution for this is a bit more difficult.
2020-11-16 17:10:57 +00:00
Griffin Smith
b1f2c2f48e feat(glittershark): Add resume + deploy it to gws.fyi
Change-Id: If9cf64c97621313af86074752d0959506059888a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2079
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
2020-11-16 16:10:43 +00:00