Skip to content

Instantly share code, notes, and snippets.

View domfarolino's full-sized avatar

Dominic Farolino domfarolino

View GitHub Profile
@domfarolino
domfarolino / file-descriptors.md
Last active May 22, 2023 13:12
Sending file descriptors over UNIX sockets

Sending file descriptors over UNIX sockets

When a process executes another process, either by one of the exec() family of functions, fork(), etc., the child process inherits all of the parent's file descriptors. This means if a parent has two file descriptors that are entangled (i.e., a read end and a write end), the parent process can simply write to the write end, and the child process can read from the read end.

 ┌────────────────┐
@domfarolino
domfarolino / format.sh
Last active December 3, 2022 18:53
clang-format on all C++ files in a directory
find . -maxdepth 20 -name \*.cc -not -path "./bazel*" -exec clang-format -i --style=Chromium {} > file \;
find . -maxdepth 20 -name \*.h -not -path "./bazel*" -exec clang-format -i --style=Chromium {} > file \;
# From https://stackoverflow.com/questions/28896909/
# find $PWD/base -type f \( -name "*.h" -o -name "*.cpp" \) -exec clang-format -style=Chromium --dry-run --Werror {} +
diff --git a/third_party/blink/common/loader/throttling_url_loader_unittest.cc b/third_party/blink/common/loader/throttling_url_loader_unittest.cc
index 592695073167..0d0d7b0ea2da 100644
--- a/third_party/blink/common/loader/throttling_url_loader_unittest.cc
+++ b/third_party/blink/common/loader/throttling_url_loader_unittest.cc
@@ -513,10 +513,12 @@ TEST_F(ThrottlingURLLoaderTest, ModifyURLAndDeferRedirect) {
throttle_->set_will_start_request_callback(
base::BindRepeating([](blink::URLLoaderThrottle::Delegate* /* delegate */,
bool* defer) { *defer = true; }));
+ base::RunLoop run_loop;
+ auto quit_closure = run_loop.QuitClosure();

Link rel=stylesheet

Somehow make Link rel=stylesheet's [fetch and process the linked resource] algorithm do the following:

  • If el [contributes a script-blocking style sheet], increment el's [node document]'s [script-blocking style sheet counter by one.

(^Either by passing some custom steps to [default fetch and process the linked resource], or overriding the algorithm)

The [process the linked resource] algorithm for this type of resource is as follows, given el, success, and response:

  1. ...
@domfarolino
domfarolino / 01-Explainer.md
Last active May 16, 2018 08:23
Priority Hints importance=high benefit on HTTP 1.0-1.1

Explainer

Site: http://159.89.227.14/

What happens without priority hints is:

  • All 7 requests are made at low priority
  • When layout is done, all (that aren't finished yet) re-prioritize to high priority (in-viewport).
  • Since a max of 6 connections are allowed to be made, the first 6 are fetched right away. 7th is queued & stalled until one of the previously-made connections is free/done and we can allocate one for the last image.
<h1>Hello</h1>
<script>
fetch("extra.metadata")
fetch("non-important.metadata")
fetch("superfluous.metadata")
// imagine like 20 of these, all "high" in priority
</script>
<!-- This represents some content, making the script
appearing below it "late" which gets "medium" priority
@domfarolino
domfarolino / syncTimer.js
Created April 3, 2018 06:50
Synchronous timer in JavaScript
/**
* I often find myself needing a synchronous timer
* in JavaScript to test various browser things so here
* is a canonical timer that can be used so I don't have to
* keep trying to remember "What was that static function I
* was using on the Date class again?"
*/
end = Date.now() + 3000;
while (Date.now() < end) {}
console.log("3 seconds later :)")
@domfarolino
domfarolino / meta.html
Created June 5, 2017 21:28
The classic meta tag I always forget how to write
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
-- Customer relation (strong entity)
CREATE TABLE domfarolino.customer, FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL
(
custID int NOT NULL,
custName char(25)
)
UNIQUE PRIMARY INDEX(custID);
-- Technician relation (strong entity)
CREATE TABLE domfarolino.technician, FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL
/usr/bin/notify-send --app-name=Ok "Dom Farolino is lit"
/usr/local/bin/terminal-notifier -title Mozilla Build System -group mozbuild -message Build complete