mirror of
https://github.com/Brandon-Rozek/website.git
synced 2025-06-19 21:05:44 +00:00
Compare commits
4 commits
5e536ef9c3
...
65d1a4dec0
Author | SHA1 | Date | |
---|---|---|---|
65d1a4dec0 | |||
f8e8f107de | |||
1c217d702a | |||
cdb2d30ecd |
6 changed files with 166 additions and 2 deletions
29
content/blog/hunter-gathering-apple-picking.md
Normal file
29
content/blog/hunter-gathering-apple-picking.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
title: "Hunter-Gatherer Traditions: Apple Picking"
|
||||
date: 2024-09-28T12:03:47-04:00
|
||||
draft: false
|
||||
tags: []
|
||||
math: false
|
||||
medium_enabled: false
|
||||
---
|
||||
|
||||
One of the fun yearly traditions that Clare and I have is to go apple picking. After all, we live in a state that produces [a lot of apples](https://www.ers.usda.gov/data-products/chart-gallery/gallery/chart-detail/?chartId=75112). Apple picking season always happen earlier than we expect, with peak season happening in September and October.
|
||||
|
||||
We went to [Windy Hill Orchard](https://www.windyhillorchardnye.com) and they have the following apples available: Cortland, Empire, Fuji, Gala, Golden Delicious, Janogold, Macoun, McIntosh, and Red Delicious.
|
||||
|
||||

|
||||
|
||||
From previous years, we decided that we like Empire apples and Fuji apples the best. We like to snack on the Empire apples, where we typically bake more with Fuji Apples.
|
||||
|
||||

|
||||
|
||||
Did you know that Apples are picked during peak season and preserved year-round to keep availability in grocery stores? In fact, only [5% of apples in the US are imported](PXL_20240922_164955826.jpg).
|
||||
|
||||
Unfortunately, we don't have the equipment at home to keep apples for the entire year. That doesn't stop us from collecting an entire bag of apples regardless and sticking it in the fridge.
|
||||
|
||||
Not all apples peak at the same time. Empire apples start peaking in September while Fuji apples start peaking in October. Since we went last week, this meant that sadly the Fuji apples weren't quite ripe yet.
|
||||
|
||||
Apple trees aren't particularly tall. There were plenty of apples within reaching distance. However, some came extra prepared with long poles with baskets in the end called a *fruit picker*. ([Example](https://www.homedepot.com/p/Corona-12-ft-L-Reach-Extendable-Aluminum-Handle-Fruit-Picker-FP-2312/318284444))
|
||||
|
||||
Leave it to humans, to come prepared with tools when hunting and gathering.
|
||||
|
56
content/blog/jq.md
Normal file
56
content/blog/jq.md
Normal file
|
@ -0,0 +1,56 @@
|
|||
---
|
||||
title: "Process JSON in the terminal with jq"
|
||||
date: 2024-10-05T15:59:10-07:00
|
||||
draft: false
|
||||
tags: []
|
||||
math: false
|
||||
medium_enabled: false
|
||||
---
|
||||
|
||||
The `jq` command is great for quickly viewing and manipulating JSON data. By default, the output is formatted is a human-readable way, and they provide an easy way to "filter" or access elements within the JSON data.
|
||||
|
||||
For example
|
||||
|
||||
```bash
|
||||
echo "{\"firstName\": \"Brandon\", \"lastName\": \"Rozek\"}" | jq
|
||||
```
|
||||
|
||||
Outputs
|
||||
|
||||
```json
|
||||
{
|
||||
"firstName": "Brandon",
|
||||
"lastName": "Rozek"
|
||||
}
|
||||
```
|
||||
|
||||
To see what's in the field `firstName`
|
||||
|
||||
```bash
|
||||
echo "{\"firstName\": \"Brandon\", \"lastName\": \"Rozek\"}" | jq .firstName
|
||||
```
|
||||
|
||||
Other than quickly viewing JSON objects in the terminal. I have two other use cases for it.
|
||||
|
||||
**1: Sanitizing Strings**
|
||||
|
||||
```bash
|
||||
echo $OUTPUT | jq -Rsa .
|
||||
```
|
||||
|
||||
| Flag | Description |
|
||||
| ---- | ------------------------------------------------------------ |
|
||||
| `-R` | Don´t parse the input as JSON. Instead, each line of text is passed to the filter as a string. |
|
||||
| `-s` | Pass the entire input to the filter as a single long string |
|
||||
| `-a` | Produce pure ASCII output with every non-ASCII character replaced with the equivalent escape sequence. |
|
||||
|
||||
**2: Stringifying JSON**
|
||||
|
||||
```bash
|
||||
jq ".|tojson"
|
||||
```
|
||||
|
||||
From the man pages
|
||||
|
||||
> The `tojson` and `fromjson` builtins dump values as JSON texts or parse JSON texts into values, respectively.
|
||||
|
78
content/blog/prost-import-external-schemas.md
Normal file
78
content/blog/prost-import-external-schemas.md
Normal file
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
title: "Importing External Schemas in Prost"
|
||||
date: 2024-10-05T11:19:37-07:00
|
||||
draft: false
|
||||
tags: []
|
||||
math: false
|
||||
medium_enabled: false
|
||||
---
|
||||
|
||||
[Prost](https://github.com/tokio-rs/prost) is a popular Protocol Buffers implementation written in Rust. The `protoc` command is commonly used to generate serializers and de-serializers for many different languages. However, the Prost team instead recommends compiling the Protocol Buffers schema directly within `build.rs`.
|
||||
|
||||
In this post, I'll give a quick tutorial on how I compiled my Protocol Buffers schema when I needed to depend on another package with its own PB messages.
|
||||
|
||||
Let's say I have a Rust package called `people`. It contains a file called `Person.proto` with the following contents:
|
||||
|
||||
```protobuf
|
||||
syntax = "proto3";
|
||||
package people;
|
||||
|
||||
message Employee {
|
||||
string name = 1;
|
||||
string position = 2;
|
||||
}
|
||||
```
|
||||
|
||||
For sake of our example, we'll assume they exposed the data structures via a `proto` submodule. However, you can check what the module name actually is by looking at the package's codebase for something like
|
||||
|
||||
```rust
|
||||
pub mod namespace_name_goes_here {
|
||||
#![allow(missing_docs)]
|
||||
include!(concat!(env!("OUT_DIR"), "/people.rs"));
|
||||
}
|
||||
```
|
||||
|
||||
Now to the package we're creating (which I'll call `company`), First, make sure that you added the `people` package to the Cargo.toml.
|
||||
|
||||
Then say that we have the following file `schemas/Team.proto`
|
||||
|
||||
```protobuf
|
||||
syntax = "proto3";
|
||||
package company;
|
||||
|
||||
import "Person.proto"
|
||||
|
||||
message Team {
|
||||
repeated people.Employee members = 1;
|
||||
}
|
||||
```
|
||||
|
||||
To compile our new message, we need to tell `build.rs` where it can find both the `Person.proto` and the `Team.proto` schema files, as well as how to reference the messages in the `people` namespace.
|
||||
|
||||
```rust
|
||||
fn main() {
|
||||
// Other awesome build stuff
|
||||
generate_schemas();
|
||||
}
|
||||
fn generate_schemas() {
|
||||
let mut config = prost_build::Config::new();
|
||||
// Map the people protocol buffer namespace to the people::proto Rust module
|
||||
config.extern_path(".people", "people::proto");
|
||||
config
|
||||
.compile_protos(
|
||||
// Files we want to compile
|
||||
&["./schema/Team.proto"],
|
||||
// Folders where we can find our imports
|
||||
&["./schema"],
|
||||
)
|
||||
.expect("Prost protobuf compilation error;");
|
||||
}
|
||||
```
|
||||
|
||||
The function `extern_path` takes two arguments, the first one is the name of the namespace within the Protocol Buffers schema, and the second argument is the namespace within Rust.
|
||||
|
||||
The first argument of `compile_protos` is the files that we want to compile, the second argument is the directories in which we can find our schemas.
|
||||
|
||||
Note that we import `People.proto` in our new Protocol Buffers schema. Currently the only way that I know to get this to work, is to manually copy the `.proto` file in the other package into your own application.
|
||||
|
||||
There you have it! Next you can include the generated output into your Rust application. If you know of a better way to include external schemas without copying the schemas, please reach out.
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: "Fettuccine Alfredo"
|
||||
title: "Alfredo"
|
||||
date: 2023-03-09
|
||||
hideDate: true
|
||||
draft: false
|
||||
|
@ -12,7 +12,7 @@ Total Time: 15 minutes
|
|||
- 1/4 Cup Butter
|
||||
- 1 Tablespoon Garlic Powder
|
||||
- 1 1/2 Cup Heavy Whipping Cream[^1]
|
||||
- 2 Cups Shredded Parmesan Cheese
|
||||
- 2 Cups Shredded Parmesan Cheese[^2]
|
||||
- Salt & Pepper to Taste
|
||||
- Egg Noodles
|
||||
|
||||
|
@ -34,3 +34,4 @@ Total Time: 15 minutes
|
|||
- Mix and serve
|
||||
|
||||
[^1]: Alternatively, you can substitute with equal parts of evaporated milk for a lower calorie alternative.
|
||||
[^2]: Shredded cheeses typically contain extra starch to help preserve it. This recipe relies on the starch to thicken the sauce.
|
BIN
static/files/images/blog/PXL_20240922_163519846.MP.jpg
Normal file
BIN
static/files/images/blog/PXL_20240922_163519846.MP.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 283 KiB |
BIN
static/files/images/blog/PXL_20240922_164955826.jpg
Normal file
BIN
static/files/images/blog/PXL_20240922_164955826.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 135 KiB |
Loading…
Add table
Reference in a new issue