Skip to content

Commit 68ded6d

Browse files
committed
Modify styling. Add github-paint post.
1 parent 6e74bb8 commit 68ded6d

File tree

7 files changed

+90
-34
lines changed

7 files changed

+90
-34
lines changed

_posts/2024-01-29-content-script-messaging.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: message passing and `MAIN` world content scripts ✉️
44
date: 2024-01-29 09:32:00 -0400
55
author: Theodore Brockman
66
categories: chrome extensions content-scripts message-passing
7-
excerpt: Making up for a lack of browser extension documentation... again.
7+
excerpt: Making up for a lack of browser extension documentation (again!).
88
thumbnail: /assets/img/hello_world_thumbnail.png
99
---
1010

@@ -14,7 +14,7 @@ You would need the ability to intercept the request before it happens, modify th
1414

1515
There's a few ways you could go about doing this, but one of the more straight-forward ones is by using a [content script](https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts).
1616

17-
# content scripts
17+
## content scripts
1818

1919
Depending on the browser (Firefox is a bit [more security conscious](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts)), content scripts can directly interact with existing webpage Javascript objects (with the converse being true as well), and modify them as desired.
2020

@@ -118,7 +118,7 @@ Pretty neat, right? But what if we were feeling bad and wanted to extend our lit
118118

119119
This is where [message passing](https://developer.chrome.com/docs/extensions/develop/concepts/messaging) comes in.
120120

121-
# message passing
121+
## message passing
122122

123123
If you've worked in browser extensions before, you're likely already familiar with sending messages between the background script and the popup, maybe even communicating with content scripts injected into the default [`ISOLATED`](https://developer.chrome.com/docs/extensions/reference/api/scripting#type-ExecutionWorld) world, but it turns out that once your code exists in the same realm as other webpage Javascript, you can't send messages as easily.
124124

@@ -198,7 +198,7 @@ _oh poop._
198198

199199
This is because the content script only has access to a limited subset of the `chrome.runtime` API as a result of being injected into the `MAIN` world. While at first frustrating, if you stop to think about it, it makes sense: Content scripts injected into the `MAIN` world are now running in the same context as the webpage, and the webpage (or other content scripts) can't be trusted. Naturally the browser requires a few more precautions to help make sure you understand [the full implications of what you're doing](https://developer.chrome.com/docs/extensions/develop/concepts/messaging#content-scripts-are-less-trustworthy).
200200

201-
# externally connectable
201+
## externally connectable
202202

203203
Instead, we need to treat our own content script as an [*external webpage*](https://developer.chrome.com/docs/extensions/develop/concepts/messaging#external-webpage), since it can no longer be considered a trusted part of the extension. This means that we need to allow connections from external webpages in our `manifest.json`:
204204

@@ -260,7 +260,7 @@ _it's toggled_
260260

261261
Note that after making your extension externally connectable, you should be *very* careful about how you process information you receive, and what information you send, to untrusted external connections--even *if* the recipient is trusted, there's no guarantee other code won't be spying.
262262

263-
# bonus: using [`func`](https://developer.chrome.com/docs/extensions/reference/api/scripting#method-ScriptInjection-func)
263+
## bonus: using [`func`](https://developer.chrome.com/docs/extensions/reference/api/scripting#method-ScriptInjection-func)
264264

265265
You may have noticed earlier that we had to hardcode our extension ID in our content script, which isn't very portable (it'll be different each time someone develops locally *and* when it's published in production) and will need to be manually updated. You may find other reasons that you want to provide context directly to your content script from your background script.
266266

_posts/2024-06-28-github-paint.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
layout: post
3+
title: github paint 🎨
4+
date: 2024-06-28
5+
author: Theodore Brockman
6+
categories: project github action python cli
7+
excerpt: A GitHub Action to help your GitHub profile *really* stand out.
8+
---
9+
10+
A few years ago I encountered the GitHub profile of someone who created a fake commit history in GitHub in order to write their username in their GitHub contribution graph:
11+
12+
> &lt;imagine a cool picture of it here&gt; <sup>because <sup>i <sup>lost<sup>it🥺</sup></sup></sup></sup>
13+
14+
Since then, I've always had it in the back of my mind as something I'd like to take a stab at. Primarily for the sake of solving an interesting problem, but also to fuck with recruiters who believe contribution activity strongly correlates programming ability (*said with chip on shoulder as someone required to use a separate GitHub account for work*).
15+
16+
Since taking a burnout-induced leave-of-absence, I've had some time to explore the problem, which has led to the creation of...
17+
18+
## [`tbrockman/github-paint`](https://github.com/tbrockman/github-paint)
19+
20+
which is a GitHub Action which\-\-given a string, a GitHub API token, and any optional parameters\-\-performs the necessary calculations to create the right number of commits on the right dates to render something like the following in your GitHub profile:
21+
22+
![the text "theo.lol" written in tbrockman's contribution graph](/assets/img/github-paint/example.png)
23+
24+
Since it's a GitHub Action, you can also configure it to run periodically such that your contribution graph always shows the same text as time goes on.
25+
26+
## how it works
27+
28+
The whole thing is a Python [Typer-CLI](https://typer.tiangolo.com/) that primarily makes calls to [`gh`](https://cli.github.com/) and [`git`](https://git-scm.com/), orchestrating the following:
29+
30+
1. First, we create a window where `x = number_of_weeks_in_timeframe` and `y = 7`.
31+
1. Then, we take our (potentially repeated) text, determine its size given the font (and the dimensions of each glyph used), and position it within the window (given specified padding and alignment).
32+
1. Then, we map each pixel in the window to its corresponding date.
33+
1. Then, retrieving the users existing contribution activity for each date, we determine (given [some secret sauce](https://stackoverflow.com/a/78686095/23271846) on how commit activity correlates to pixel color) how many additional commits we need on that day.
34+
* If we actually need *fewer*, we can handle this by adding more commits to *other* days\-\-assuming our target isn't zero commits.
35+
1. Then, after initializing a fresh `git` repository, for each day (in the appropriate order\-\-though this doesn't seem to matter to GitHub), we forge the necessary number of commits on each date (since `git` allows setting arbitrary commit dates).
36+
1. Finally, push the new repository and history (deleting the old one if it exists), and wait a bit for GitHub to render our shiny new contribution graph.
37+
38+
So far, it seems to work pretty well, but it's not *super* well-tested, so if you run into issues feel free to create a pull request: [https://github.com/tbrockman/github-paint](https://github.com/tbrockman/github-paint).
39+
40+
hope you like it!

_sass/blog.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ body {
8787

8888
.blog-post-title {
8989
font-size: 2em;
90-
font-family: Arial;
90+
font-weight: bold;
9191
overflow-y: hidden;
9292
overflow: hidden;
9393
word-break: break-word;
@@ -111,6 +111,10 @@ body {
111111
color: #fff;
112112
}
113113

114+
.blog-post-excerpt>p {
115+
margin: 0;
116+
}
117+
114118
.blog-list li h2 {
115119
margin-top: 0;
116120
}

_sass/common.scss

+36-16
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,48 @@ $breakpoint-navbar: 1400px;
55
$breakpoint-mobile: 800px;
66

77
@keyframes nav-slide-in-from-right {
8-
0% { left: 100vw; }
9-
100% { left: 30vw; }
8+
0% {
9+
left: 100vw;
10+
}
11+
12+
100% {
13+
left: 30vw;
14+
}
1015
}
1116

1217
@keyframes nav-slide-out-from-left {
13-
0% { left: 30vw; }
14-
100% { left: 100vw; }
18+
0% {
19+
left: 30vw;
20+
}
21+
22+
100% {
23+
left: 100vw;
24+
}
1525
}
1626

1727
@keyframes slide-left-make-way-for-nav {
18-
0% { left: 0; }
19-
100% { left: -70vw; }
20-
}
28+
0% {
29+
left: 0;
30+
}
2131

22-
@keyframes slide-right-close-nav {
23-
0% { left: -70vw; position:absolute; }
24-
100% { left: 0}
32+
100% {
33+
left: -70vw;
34+
}
2535
}
2636

27-
@media(max-width: $breakpoint-mobile) {
37+
@keyframes slide-right-close-nav {
38+
0% {
39+
left: -70vw;
40+
position: absolute;
41+
}
2842

43+
100% {
44+
left: 0
45+
}
2946
}
3047

48+
@media(max-width: $breakpoint-mobile) {}
49+
3150
@media(max-width: $breakpoint-navbar) {
3251

3352
// div.page-container {
@@ -58,19 +77,22 @@ body {
5877
height: 100%;
5978
display: flex;
6079
flex-direction: column;
61-
font-size: 1vw;
6280
color: #fff;
81+
text-transform: lowercase;
82+
}
83+
84+
code {
85+
text-transform: none;
6386
}
6487

6588
.page-container {
6689
box-sizing: border-box;
6790
width: 100%;
68-
max-width: 124ch;
91+
max-width: 120ch;
6992
margin: 0 auto;
7093
padding: 0em 12em 8em;
7194
z-index: 1;
7295
flex: 1;
73-
font-size: 1rem;
7496
}
7597

7698
a {
@@ -95,8 +117,6 @@ a.fa:hover {
95117
}
96118

97119
h1 {
98-
font-family: "Montserrat", sans-serif;
99-
font-weight: normal;
100120
color: #fe5858;
101121
font-size: 6em;
102122
}

_sass/post.scss

+3-11
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,18 @@ h2 {
8484
color: $color-primary;
8585
margin-top: 1em;
8686
font-size: 3em;
87-
font-weight: normal;
88-
font-family: 'Montserrat', sans-serif;
8987
word-break: break-word;
9088
}
9189

9290
h3 {
9391
color: $color-primary;
9492
margin-top: 1em;
9593
font-size: 2rem;
96-
font-weight: normal;
97-
font-family: 'Montserrat', sans-serif;
9894
word-break: break-word;
9995
}
10096

10197
img {
102-
margin: 0 auto 4em;
98+
margin: 0 auto 2em;
10399
display: flex;
104100
max-width: -webkit-fill-available;
105101
max-width: -moz-available;
@@ -109,8 +105,8 @@ img {
109105
}
110106

111107
blockquote {
112-
margin: 4em 0;
113-
padding: 2em 4em;
108+
margin: 2em 0 3em;
109+
padding: 0 4em;
114110
color: #fff;
115111
background: $hover-background-color;
116112
box-shadow: $hover-box-shadow;
@@ -159,15 +155,12 @@ p>strong>code {
159155
}
160156

161157
.post-header h1 {
162-
font-family: 'Montserrat', sans-serif;
163-
font-weight: normal;
164158
margin: 0;
165159
margin-bottom: 0.25em;
166160
word-break: break-word;
167161
}
168162

169163
.post-header h4 {
170-
font-weight: normal;
171164
margin: 0;
172165
color: #252525;
173166
font-size: 1.25em;
@@ -207,7 +200,6 @@ p>strong>code {
207200

208201
a:has(img)+em,
209202
img+em {
210-
margin-top: -2rem;
211203
text-align: center;
212204
font-size: 1rem;
213205
display: block;

assets/img/github-paint/example.png

15.3 KB
Loading

blog.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<div>
1212
<div class='blog-post-preview'>
1313
<div class='blog-post-title'>{{post.title | markdownify | remove: '<p>' | remove: '</p>'}}</div>
14-
<div class='blog-post-excerpt'>{{ post.excerpt }}</div>
14+
<div class='blog-post-excerpt'>{{ post.excerpt | markdownify }}</div>
1515
</div>
1616
</div>
1717
</a>

0 commit comments

Comments
 (0)