Compare commits
379 Commits
bobatheme
...
1574cd8515
Author | SHA1 | Date | |
---|---|---|---|
1574cd8515
|
|||
1d0d621963 | |||
5f44c05e57
|
|||
0e67adf41c
|
|||
b4c695aeb4
|
|||
cdfcf3c372
|
|||
6d7dfa6c5d
|
|||
ef8dda9657
|
|||
f6b27235f3
|
|||
1ce61b8260
|
|||
f719cadd1e
|
|||
43d4f47e29
|
|||
510e3e9bf9
|
|||
685a9ed8f4
|
|||
66fac8058f
|
|||
e93871c923
|
|||
07f586e5b0
|
|||
d21feef5b9
|
|||
e49b0aa583
|
|||
91bc38bdd4
|
|||
b80bd5732d
|
|||
b863f577ae
|
|||
c1806338e5
|
|||
f9c4fd8a9a
|
|||
fb0e45d7cd
|
|||
a0165e8569
|
|||
100a86b85f
|
|||
8321945015
|
|||
48ed6eae21
|
|||
795be223eb
|
|||
0e2a26fe56
|
|||
c228d5c903
|
|||
f2494e515f
|
|||
4cd6632799
|
|||
bde9df2aa6
|
|||
87c5d4f1b3
|
|||
31a72c92fa
|
|||
bc76fb5458
|
|||
ddb0045088
|
|||
2fb0d17df1
|
|||
060d3ecd84
|
|||
fd6eb50399
|
|||
87688ef6b3
|
|||
01c2b34920
|
|||
c014da3fe3
|
|||
7d5309862e
|
|||
cef5fe28dc
|
|||
7a529fb1ac
|
|||
852aafb2e7
|
|||
c50d3fda88
|
|||
6f1c5a883f
|
|||
6a941cef7c
|
|||
44c1291fa4
|
|||
dba36c5105
|
|||
6145d4e8d7
|
|||
c5a2e84050
|
|||
94a2404a83
|
|||
fec8bd1933
|
|||
27bc4e28a8
|
|||
e9ad2abd55
|
|||
f0036f20b9
|
|||
2fc8e4646e
|
|||
da8dc12957
|
|||
86f4b102d7
|
|||
d7e219d331 | |||
5b0c092bc0
|
|||
2ce66a14d4 | |||
8a330b59b0
|
|||
de888c1adc
|
|||
927e775439
|
|||
9c572a706b
|
|||
05c8e0da9d
|
|||
191c9a5185
|
|||
c11c9178e0
|
|||
5719a11e8b
|
|||
bacddbfe42
|
|||
4e6f0c7614
|
|||
20abaffc3a
|
|||
3668b6cfb1
|
|||
f3cf22ae33
|
|||
dde5162907
|
|||
90d640bd12
|
|||
904d8928b7
|
|||
827a049946
|
|||
db65e9fc23
|
|||
bd9d294fc1
|
|||
9de4d26b6a
|
|||
f14c1568f7 | |||
1e650ed79b
|
|||
ba9c62ed4f
|
|||
c3632c40ce | |||
02201e806f
|
|||
d27f095c1a
|
|||
2b38b143b1
|
|||
26ccc90cff
|
|||
d5ef788e78
|
|||
8e2673b4ff
|
|||
c58164f1f2
|
|||
4fb9dbaa30
|
|||
359bfbf1b6
|
|||
d011efd2a1
|
|||
98ef3386f5
|
|||
a170885ff8
|
|||
17af722f4d
|
|||
62c62b344c
|
|||
f50665786b
|
|||
57fac4d945
|
|||
f6602dfff0
|
|||
db6fc9e977
|
|||
86a90f907a
|
|||
3838d2d44a
|
|||
ac05117647
|
|||
355d180f6c
|
|||
0bc3f3145e
|
|||
cbe6a1e12a
|
|||
e1dd193bf1
|
|||
0bb3dce6e9
|
|||
6ad002b319
|
|||
1e20d0e943
|
|||
375b90fb07
|
|||
81fa2f6b41
|
|||
fb7b5913c0
|
|||
d8134587e9
|
|||
4db3d24349
|
|||
4017855c29
|
|||
859537be01
|
|||
164565cecb
|
|||
5d08b75f71
|
|||
5782a6a002
|
|||
e21a4b948e
|
|||
9de124a586
|
|||
4a4361dcb5
|
|||
a449933ffe
|
|||
a57715c4fa
|
|||
3ec98f019c
|
|||
fd4a7a7bc2
|
|||
1f263b3a3a
|
|||
c24cdee46c
|
|||
2a79a86fd6
|
|||
97bc1980eb
|
|||
cef1103070
|
|||
1332c16841
|
|||
b124d89391
|
|||
0d432e200c
|
|||
5286bb029f | |||
31e25c2578
|
|||
1033b84687
|
|||
b9a95983b9
|
|||
b14a46d48b
|
|||
99b03ea7ba
|
|||
9c6a2a059d | |||
e10c3a1150
|
|||
9e0d2a9d8f
|
|||
576124d42d
|
|||
7b8f47b56b
|
|||
cab56bd859
|
|||
672bfae812
|
|||
ca40973701 | |||
b2d3bd99f3
|
|||
beb1faf3a8
|
|||
088a52aa96
|
|||
941bb5ce9e
|
|||
a628829bec
|
|||
83cd00078f
|
|||
8207535dca
|
|||
2aec5d33b3
|
|||
11f8115735
|
|||
46af6d4de2
|
|||
efdc6364de
|
|||
5260ca987c
|
|||
8f0b1d4952
|
|||
75f0038a37
|
|||
4d64d0ab0b
|
|||
45d26b2f9f
|
|||
cb02d6f586
|
|||
00a84889b0
|
|||
a4e5997b47
|
|||
1b09947ee6
|
|||
282a5319cc
|
|||
5cc3102deb
|
|||
8c1ee6efe9
|
|||
8a96465a20
|
|||
e3d77d6f60
|
|||
49b7a3a8a1
|
|||
c08d6a927f
|
|||
b23760585d
|
|||
95695e1187
|
|||
4a1d52e11b
|
|||
77731aacb8
|
|||
2dd9928654
|
|||
83f0c77d8d
|
|||
6a1760e3a0
|
|||
2a9af4d89e
|
|||
5250eb5b1d
|
|||
c12fe39134
|
|||
78b7b78e0a
|
|||
37e3442b39
|
|||
f7e2098020
|
|||
54d2599ad3
|
|||
ec7575d7f1
|
|||
bdf9f7737a
|
|||
7f584afa21
|
|||
ad3a77fd7a
|
|||
835068bcbe
|
|||
c92d12cdcd
|
|||
b9b1de8722
|
|||
16b0afafd3
|
|||
0824589054
|
|||
68db383c73
|
|||
b10919bfb0
|
|||
3035740ad1
|
|||
e806ff1b35
|
|||
83bef16379
|
|||
a490baacad
|
|||
cbae5a2fee
|
|||
b76454649b
|
|||
fc67f210d9
|
|||
954bcc19b7
|
|||
a6d6b3ba3c
|
|||
157eb700dd
|
|||
8082b78d02
|
|||
740b849f08
|
|||
04dd824362
|
|||
6a28ab60d4
|
|||
538132bee3
|
|||
fd4022d32d
|
|||
295c4c8095
|
|||
f93f8a643e
|
|||
e4fecdc4c8
|
|||
31053a0a29
|
|||
99bedbaffa
|
|||
b942f7a6a9
|
|||
fc730ad0de
|
|||
da12ee2101
|
|||
ef7eac1bb4
|
|||
9690d77b36
|
|||
463c26a0e0
|
|||
054547afd0
|
|||
dd6d1ac0de
|
|||
c96b2fb91c
|
|||
32933f9001
|
|||
70b2233113
|
|||
b45c051914
|
|||
a887380e66
|
|||
3dd852d3b9
|
|||
a6076f691a
|
|||
e6093c7357
|
|||
59e61545d8
|
|||
cb2cc89ae6
|
|||
1b1ad207b3
|
|||
fda5948b83
|
|||
d19b9ceaf4
|
|||
8c8aeb6712
|
|||
e201233dc5
|
|||
17dae5a100
|
|||
7892e10d31
|
|||
e81abbdee1
|
|||
fa986a6108
|
|||
6a2ea7ae56
|
|||
5c6c2803bb
|
|||
851f8974b3
|
|||
71afc4d7b8
|
|||
1176f18a97
|
|||
fce3e6f626
|
|||
0cd787706a
|
|||
ffaa86a23b
|
|||
9586ff6e7d
|
|||
5be27334a3
|
|||
dec3ac1404
|
|||
9717d84c6f
|
|||
624e7961d9
|
|||
e9f4e4691b
|
|||
591e237dac
|
|||
21c37a5819
|
|||
8770cd6a83
|
|||
5755aa7d4a
|
|||
9246a8b0ec
|
|||
19dc651463
|
|||
c1366096f5
|
|||
58a2a7f097
|
|||
51632d82ae
|
|||
785d0161db
|
|||
39c53eb628
|
|||
9cdf93c7b0
|
|||
0e3e6fa865
|
|||
915b172950
|
|||
3ab4febeb3
|
|||
51680bd3b1
|
|||
14338b653b
|
|||
5c247db719
|
|||
835589c119
|
|||
132cccfb64
|
|||
fa3a19ce78
|
|||
62af527c24
|
|||
822128a5ae
|
|||
f5e6390358
|
|||
2bd777fbd4
|
|||
61d563ca99
|
|||
86d346e4ae
|
|||
4cf931c2ea
|
|||
1013b6c7a5
|
|||
d0752d9ff0
|
|||
a49969bdc9
|
|||
b397e00071
|
|||
57047c6615
|
|||
c7b482ba4b
|
|||
8a49efea0e
|
|||
9ee1d4ff42
|
|||
3dfe41f14e
|
|||
62ff275f91
|
|||
490db14efb
|
|||
d3eebe4114
|
|||
f775b2ccb9
|
|||
dfdf4b2af3
|
|||
6120f3ed37
|
|||
f05769588a
|
|||
f2e2be6a30
|
|||
a18a1d1124
|
|||
becac7d21c
|
|||
6fc906b4aa
|
|||
565ae82bb7
|
|||
30b0773640
|
|||
498da8217f
|
|||
649463e14d
|
|||
96fa82d4a8
|
|||
af927e849a
|
|||
ef1afc1a29
|
|||
395ef1321a
|
|||
b1d4cf96e3
|
|||
a78b958bf7
|
|||
db5d6ddbfe
|
|||
fdf1604bc6
|
|||
bed3e368cd
|
|||
19a94b2f81
|
|||
20406c8a51
|
|||
073ff700cb
|
|||
f6c85b06d6
|
|||
ac92e2583d
|
|||
29ab58ab13
|
|||
5019fd61e8
|
|||
628a6adbc7
|
|||
6c694052b9
|
|||
563547dfda
|
|||
e852a1d521
|
|||
5823dbdc8f
|
|||
842e101948
|
|||
70b3d00116
|
|||
426184757b
|
|||
73d434309d
|
|||
f4df6a6bf6
|
|||
94f98a6b42
|
|||
9c865c7292
|
|||
ac1546cff3
|
|||
e5614a4d35
|
|||
fb752f1849
|
|||
2c79fee81f
|
|||
0eba2deb19
|
|||
d19c931184
|
|||
d1d368baa2
|
|||
ea08849fc5
|
|||
92b555980e
|
|||
8854c6d685
|
|||
d63fa039d3
|
|||
e4e7b843b8
|
|||
b733d3adf9
|
|||
9610df7e27
|
|||
69ee0ea7d3
|
|||
255d2672de
|
|||
64a10abf32
|
|||
b4bd3bdad7
|
|||
5981603cd1
|
|||
71aa212355
|
|||
43fa7b63ae
|
|||
1b39e25098
|
|||
151d707509
|
|||
13369b8d77
|
|||
ac52eea3d5
|
|||
7492bd6f3a
|
|||
0ae0a50264
|
41
.drone.yml
@ -1,41 +0,0 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Deploy to bbaovanc.com
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
steps:
|
||||
- name: submodules
|
||||
image: alpine/git
|
||||
commands:
|
||||
- git submodule update --init --recursive
|
||||
|
||||
- name: build
|
||||
image: bbaovanc/hugo
|
||||
commands:
|
||||
- hugo version
|
||||
- hugo --minify
|
||||
|
||||
- name: list files
|
||||
image: alpine:latest
|
||||
commands:
|
||||
- find public/
|
||||
|
||||
- name: upload
|
||||
image: appleboy/drone-scp
|
||||
settings:
|
||||
host: bbaovanc.com
|
||||
port: 2222
|
||||
username: droneci
|
||||
key:
|
||||
from_secret: SSH_KEY
|
||||
target: /var/www/bbaovanc/public/
|
||||
rm: true
|
||||
source: public/
|
||||
strip_components: 1
|
@ -1,11 +1,16 @@
|
||||
root = true
|
||||
|
||||
[*.{md,toml}]
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.html]
|
||||
indent_size = 4
|
||||
|
||||
[*.{md,toml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
max_line_length = 80
|
||||
|
7
.gitattributes
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
*.md linguist-detectable=true
|
||||
*.html linguist-detectable=true
|
||||
*.css linguist-detectable=true
|
||||
*.js linguist-detectable=true
|
||||
README.md linguist-detectable=false
|
||||
CONTRIBUTING.md linguist-detectable=false
|
||||
docs/** linguist-detectable=false
|
60
.github/workflows/audit.yml
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
name: Audit
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
audit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
with:
|
||||
hugo-version: latest
|
||||
extended: true
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
HUGO_MINIFY_TDEWOLFF_HTML_KEEPCOMMENTS=true HUGO_ENABLEMISSINGTRANSLATIONPLACEHOLDERS=true hugo --buildDrafts --printI18nWarnings --printPathWarnings
|
||||
|
||||
# For the following steps, see
|
||||
# https://discourse.gohugo.io/t/audit-your-published-site-for-problems/35184
|
||||
|
||||
- name: Audit - raw HTML
|
||||
if: always()
|
||||
run: |
|
||||
! grep -inorE "<\!-- raw HTML omitted -->" public/
|
||||
|
||||
- name: Audit - ZgotmplZ (unsafe URL content)
|
||||
if: always()
|
||||
run: |
|
||||
! grep -inorE "ZgotmplZ" public/
|
||||
|
||||
#- name: Audit - missing translations
|
||||
# if: always()
|
||||
# run: |
|
||||
# ! grep -inorE "\[i18n\]" public/
|
||||
|
||||
- name: Audit - nil values in printf
|
||||
if: always()
|
||||
run: |
|
||||
! grep -inorE "\(<nil>\)" public/
|
||||
|
||||
- name: Audit - nil values in printf without safeHTML
|
||||
if: always()
|
||||
run: |
|
||||
! grep -inorE "(<nil>)" public/
|
||||
|
||||
- name: Audit - HAHAHUGO
|
||||
if: always()
|
||||
run: |
|
||||
! grep -inorE "hahahugo" public/
|
53
.github/workflows/deploy.yml
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: bbaovanc.com
|
||||
url: https://bbaovanc.com
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
with:
|
||||
hugo-version: latest
|
||||
extended: true
|
||||
|
||||
- name: Build
|
||||
run: hugo --printI18nWarnings --printPathWarnings
|
||||
|
||||
- name: Compress
|
||||
run: |
|
||||
time sudo ./compress.sh
|
||||
|
||||
- name: Setup SSH
|
||||
uses: kielabokkie/ssh-key-and-known-hosts-action@v1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
ssh-host: srv.bbaovanc.com
|
||||
ssh-port: 2222
|
||||
|
||||
- name: Upload
|
||||
uses: up9cloud/action-rsync@v1
|
||||
env:
|
||||
HOST: srv.bbaovanc.com
|
||||
USER: droneci
|
||||
PORT: 2222
|
||||
SOURCE: public/
|
||||
MODE: push
|
||||
VERBOSE: true
|
||||
KEY: ${{secrets.DEPLOY_SSH_KEY}}
|
||||
TARGET: /var/www/bbaovanc.com/public/
|
||||
ARGS: -avPzc --delete-delay --exclude=/.git/ --exclude=/.github/
|
94
.github/workflows/pull_request.yml
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
name: Pull Request
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- name: Start deployment
|
||||
uses: bobheadxi/deployments@v0.6.0
|
||||
id: deployment
|
||||
with:
|
||||
step: start
|
||||
token: ${{ github.token }}
|
||||
env: pr-${{ github.event.number }}
|
||||
ref: ${{ github.head_ref }}
|
||||
no_override: false
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
with:
|
||||
hugo-version: latest
|
||||
extended: true
|
||||
|
||||
- name: Build
|
||||
run: hugo --printI18nWarnings --printPathWarnings --baseURL "https://demo.bbaovanc.com/pull_request/${{ github.event.number }}" --buildDrafts
|
||||
|
||||
- name: Compress
|
||||
run: |
|
||||
time sudo ./compress.sh
|
||||
|
||||
- name: Setup SSH
|
||||
uses: kielabokkie/ssh-key-and-known-hosts-action@v1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
ssh-host: srv.bbaovanc.com
|
||||
ssh-port: 2222
|
||||
|
||||
- name: Upload
|
||||
uses: up9cloud/action-rsync@v1
|
||||
env:
|
||||
HOST: srv.bbaovanc.com
|
||||
USER: droneci
|
||||
PORT: 2222
|
||||
SOURCE: public/
|
||||
MODE: push
|
||||
VERBOSE: true
|
||||
KEY: ${{secrets.DEPLOY_SSH_KEY}}
|
||||
TARGET: /var/www/demo.bbaovanc.com/pull_request/${{ github.event.number }}/
|
||||
ARGS: -avPzc --delete-delay --exclude=/.git/ --exclude=/.github/
|
||||
|
||||
- name: Finish deployment
|
||||
uses: bobheadxi/deployments@v0.6.0
|
||||
if: always()
|
||||
with:
|
||||
step: finish
|
||||
token: ${{ github.token }}
|
||||
status: ${{ job.status }}
|
||||
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
|
||||
env_url: "https://demo.bbaovanc.com/pull_request/${{ github.event.number }}/"
|
||||
no_override: true
|
||||
auto_inactive: false
|
||||
|
||||
- name: Find PR comment
|
||||
uses: peter-evans/find-comment@v1
|
||||
id: fc
|
||||
with:
|
||||
issue-number: ${{ github.event.number }}
|
||||
comment-author: 'github-actions[bot]'
|
||||
body-includes: "preview of this pull request"
|
||||
|
||||
- name: Comment on PR
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
with:
|
||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||
issue-number: ${{ github.event.number }}
|
||||
body: |
|
||||
A preview of this pull request is ready!
|
||||
See it at https://demo.bbaovanc.com/pull_request/${{ github.event.number }}/
|
||||
View the deploy log at https://github.com/BBaoVanC/bbaovanc.com/actions/runs/${{ github.run_id}}
|
||||
edit-mode: replace
|
29
.github/workflows/pull_request_cleanup.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
name: Pull Request Cleanup
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- closed
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup SSH
|
||||
uses: kielabokkie/ssh-key-and-known-hosts-action@v1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
ssh-host: srv.bbaovanc.com
|
||||
ssh-port: 2222
|
||||
|
||||
- name: Delete pull request on server
|
||||
run:
|
||||
ssh -p 2222 droneci@srv.bbaovanc.com rm -r /var/www/demo.bbaovanc.com/pull_request/${{ github.event.number }}/
|
||||
|
||||
- name: Deactivate deployment
|
||||
uses: bobheadxi/deployments@v0.6.0
|
||||
with:
|
||||
step: deactivate-env
|
||||
token: ${{ github.token }}
|
||||
env: pr-${{ github.event.number }}
|
||||
desc: Deployment was pruned
|
5
.gitignore
vendored
@ -14,3 +14,8 @@ hugo.darwin
|
||||
hugo.linux
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/hugo
|
||||
|
||||
/.hugo_build.lock
|
||||
|
||||
# My private drafts
|
||||
/content/blog/drafts/
|
||||
|
4
.gitmodules
vendored
@ -1,7 +1,3 @@
|
||||
[submodule "themes/hugo-bearblog"]
|
||||
path = themes/hugo-bearblog
|
||||
url = https://github.com/BBaoVanC/hugo-bearblog.git
|
||||
branch = master
|
||||
[submodule "themes/bobatheme"]
|
||||
path = themes/bobatheme
|
||||
url = https://github.com/BBaoVanC/bobatheme.git
|
||||
|
33
CONTRIBUTING.md
Normal file
@ -0,0 +1,33 @@
|
||||
# Contributing to bobatheme
|
||||
|
||||
## Where to put questions/issues/etc
|
||||
|
||||
Use the [GitHub Discussions forum][github-discussions-url] for any questions,
|
||||
or ideas. Use the "Q&A" section for both questions and issues as well.
|
||||
|
||||
[github-discussions-url]: https://github.com/BBaoVanC/bbaovanc.com/discussions
|
||||
|
||||
## Building
|
||||
|
||||
Just in case you need it.
|
||||
|
||||
## Automatic deploy previews with GitHub Actions
|
||||
|
||||
My GitHub Actions workflows will automatically build each pull request into a
|
||||
public deploy preview on demo.bbaovanc.com, and will link it in a comment.
|
||||
|
||||
## Manual (local) building
|
||||
|
||||
You can also build the site yourself using Hugo, including a live local preview.
|
||||
|
||||
1. Make sure you install the latest version of Hugo, or hopefully at least the
|
||||
`min_version` listed in
|
||||
[theme.toml](https://github.com/BBaoVanC/bobatheme/blob/master/theme.toml#L11).
|
||||
Let me know if that minimum version isn't enough and I'll fix it.
|
||||
2. Clone the repo
|
||||
3. Make sure to download and checkout the submodules (use `git submodule update
|
||||
--init --recursive`). The `--recursive` flag is especially important because
|
||||
bobatheme has a submodule in itself for icons.
|
||||
4. Run `hugo serve -D` to run a local webserver. Hugo will show the URL you can
|
||||
access the preview at. It will automatically rebuild and reload pages when
|
||||
you save them.
|
9
Caddyfile
Normal file
@ -0,0 +1,9 @@
|
||||
# vim: ft=caddyfile
|
||||
|
||||
https://localhost {
|
||||
header Cache-Control no-cache
|
||||
root * public/
|
||||
file_server {
|
||||
precompressed br gzip
|
||||
}
|
||||
}
|
12
Makefile
@ -1,12 +0,0 @@
|
||||
all: public
|
||||
|
||||
public:
|
||||
hugo
|
||||
|
||||
clean:
|
||||
rm -rf public
|
||||
|
||||
push: clean public
|
||||
rsync -arvz -e 'ssh -p 2222' --progress --delete public/ bbaovanc.com:/var/www/bbaovanc/blog/
|
||||
|
||||
.PHONY: all clean push
|
@ -1,3 +1,8 @@
|
||||
# bbaovanc.com
|
||||
|
||||
My personal website, generated using [Hugo](https://gohugo.io)
|
||||
|
||||
## Discussions
|
||||
|
||||
Use [GitHub Discussions](https://github.com/BBaoVanC/bbaovanc.com/discussions)
|
||||
for questions, ideas, discussions, etc. relating to me or my website.
|
||||
|
@ -1,13 +0,0 @@
|
||||
+++
|
||||
title = "{{ replace .Name "-" " " | title }}"
|
||||
date = "{{ .Date }}"
|
||||
# Format date like 2006-01-02 (it gives an error if I use .Format)
|
||||
|
||||
description = """
|
||||
Lorem ipsum
|
||||
"""
|
||||
|
||||
tags = [
|
||||
"",
|
||||
]
|
||||
+++
|
@ -1,8 +0,0 @@
|
||||
+++
|
||||
title = "{{ replace .Name "-" " " | title }}"
|
||||
menu = "main"
|
||||
|
||||
description = """
|
||||
Lorem ipsum
|
||||
"""
|
||||
+++
|
121
assets/css/comments.css
Normal file
@ -0,0 +1,121 @@
|
||||
/* Isso styling */
|
||||
h4.isso-thread-heading {
|
||||
color: var(--text-0);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.isso-comment:not(:first-of-type),
|
||||
.isso-follow-up .isso-comment {
|
||||
border-color: var(--background-3);
|
||||
}
|
||||
|
||||
.isso-author,
|
||||
.isso-page-author-suffix,
|
||||
.isso-comment-footer,
|
||||
.isso-comment-footer .isso-votes {
|
||||
color: var(--text-gray-0);
|
||||
}
|
||||
|
||||
.isso-comment-header .isso-spacer,
|
||||
.isso-spacer:hover,
|
||||
.isso-permalink,
|
||||
.isso-permalink:hover {
|
||||
color: var(--text-gray-1) !important;
|
||||
}
|
||||
a.isso-author:hover,
|
||||
.isso-permalink:hover {
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
.isso-comment.isso-is-page-author > .isso-text-wrapper {
|
||||
background-color: var(--background-accent-1);
|
||||
}
|
||||
|
||||
.isso-feedlink:hover,
|
||||
.isso-reply {
|
||||
color: var(--link-0) !important;
|
||||
text-shadow: unset !important;
|
||||
}
|
||||
.isso-reply:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.isso-text pre,
|
||||
.isso-text :not(pre) > code {
|
||||
background-color: var(--background-2);
|
||||
border: none;
|
||||
padding: 2px 4px;
|
||||
border-radius: 5px;
|
||||
/* thanks isso.css for setting this to 85% for whatever reason */
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
.isso-input-wrapper input,
|
||||
.isso-post-action > input,
|
||||
.isso-textarea,
|
||||
.isso-preview {
|
||||
color: var(--text-1);
|
||||
background-color: var(--background-1);
|
||||
border-color: var(--background-2) !important;
|
||||
}
|
||||
|
||||
.isso-input-wrapper input:focus,
|
||||
.isso-textarea:focus {
|
||||
border-color: var(--background-3) !important;
|
||||
}
|
||||
|
||||
.isso-post-action > input:hover {
|
||||
background-color: var(--background-2);
|
||||
}
|
||||
.isso-post-action > input:focus,
|
||||
.isso-post-action > input:active {
|
||||
background-color: var(--background-3);
|
||||
}
|
||||
|
||||
.isso-textarea {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.isso-input-wrapper {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
margin-right: 4px;
|
||||
max-width: 25%;
|
||||
}
|
||||
.isso-input-wrapper input {
|
||||
order: 1;
|
||||
}
|
||||
.isso-input-wrapper label {
|
||||
order: 2;
|
||||
font-size: small;
|
||||
}
|
||||
.isso-post-action {
|
||||
margin-left: 4px;
|
||||
margin-top: 0;
|
||||
}
|
||||
@media screen and (max-width: 600px) {
|
||||
.isso-input-wrapper {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
.comments {
|
||||
break-before: always;
|
||||
}
|
||||
.isso-comment {
|
||||
max-width: unset;
|
||||
}
|
||||
.isso-text-wrapper {
|
||||
break-inside: avoid;
|
||||
}
|
||||
|
||||
.isso-postbox,
|
||||
.isso-feedlink {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.isso-target {
|
||||
animation: target-fade 10s ease-out; /* defined in bobatheme */
|
||||
}
|
3
assets/js/share-event.js
Normal file
@ -0,0 +1,3 @@
|
||||
function share_event(service) {
|
||||
plausible("Share", {props: {Network: service}});
|
||||
}
|
8
changed-urls.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
diff -qrNtbB old/ new/ |
|
||||
grep -oP '(?<=\s)new\/\S*' |
|
||||
xargs -d '\n' ls -1d 2>/dev/null |
|
||||
grep 'index.html$' |
|
||||
sed 's/index.html$//' |
|
||||
sed "s/^new/${SCHEME:=http}:\/\/${DOMAIN:=example.com}/"
|
6
compress.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
files=$(find public/ -name "*.html" -o -name "*.xml" -o -name "*.css" -o -name "*.js" -o -name "*.svg")
|
||||
|
||||
printf '%s\n' "$files" | parallel $@ "echo 'GZIP {}' && gzip -fnk {}"
|
||||
printf '%s\n' "$files" | parallel $@ "echo 'BROTLI {}' && brotli -fZk {}"
|
13
config.toml
@ -1,13 +0,0 @@
|
||||
baseURL = "https://bbaovanc.com"
|
||||
theme = "bobatheme"
|
||||
languageCode = "en-US"
|
||||
author = "bbaovanc"
|
||||
title = "bbaovanc's Website"
|
||||
sectionPagesMenu = "main"
|
||||
enableRobotsTXT = true
|
||||
|
||||
# these are for the OpenGraph/Twitter embeds
|
||||
[params]
|
||||
description = "My personal website"
|
||||
images = ["favicon.png"]
|
||||
title = "boba.best"
|
84
config.yaml
Normal file
@ -0,0 +1,84 @@
|
||||
baseURL: https://bbaovanc.com
|
||||
theme: bobatheme
|
||||
defaultContentLanguage: en
|
||||
copyright: '© 2021-2023 bbaovanc <a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>'
|
||||
sectionPagesMenu: main
|
||||
enableRobotsTXT: true
|
||||
paginate: 10
|
||||
enableGitInfo: true
|
||||
|
||||
taxonomies:
|
||||
_merge: deep
|
||||
|
||||
author:
|
||||
name: bbaovanc
|
||||
|
||||
markup: # this just keeps the bobatheme markup styling
|
||||
_merge: deep
|
||||
|
||||
related:
|
||||
includeNewer: true
|
||||
indices:
|
||||
#- name: keywords
|
||||
# weight: 100
|
||||
- name: categories
|
||||
weight: 80
|
||||
- name: tags
|
||||
weight: 80
|
||||
- name: date
|
||||
weight: 10
|
||||
threshold: 80
|
||||
toLower: true
|
||||
|
||||
params:
|
||||
# these are for the OpenGraph/Twitter embeds in Hugo
|
||||
description: My personal website
|
||||
|
||||
# these are for favicons in bobatheme (disabled by default)
|
||||
faviconSVG: favicon.svg
|
||||
appleTouchPNG: apple-touch-icon.png
|
||||
|
||||
# show reading time (enabled by default)
|
||||
readingtime: true
|
||||
|
||||
# used for "View source" (unset by default)
|
||||
gitFileURL: https://github.com/BBaoVanC/bbaovanc.com/blob/master
|
||||
gitFileIcon: code
|
||||
gitHistoryURL: https://github.com/BBaoVanC/bbaovanc.com/commits/master
|
||||
|
||||
# display a "Latest Posts" section on the homepage below its content
|
||||
homepageLatestPosts: true
|
||||
|
||||
# social media share icons
|
||||
shareButtons:
|
||||
twitter: true
|
||||
facebook: true
|
||||
linkedin: true
|
||||
reddit: true
|
||||
telegram: true
|
||||
print: true
|
||||
|
||||
# show "Latest Posts" section at bottom of content pages
|
||||
# latestPostsOnContent: true
|
||||
|
||||
|
||||
footer: >-
|
||||
See the [anonymous and privacy-friendly
|
||||
analytics](https://plausible.bbaovanc.com/bbaovanc.com) for this site,
|
||||
powered by [Plausible](https://plausible.io).
|
||||
|
||||
# see https://gohugo.io/about/hugo-and-gdpr/#all-privacy-settings
|
||||
# you probably want to keep this default
|
||||
privacy:
|
||||
_merge: deep
|
||||
|
||||
languages:
|
||||
en:
|
||||
languageName: English
|
||||
title: bbaovanc's Website
|
||||
weight: 1
|
||||
menu:
|
||||
main:
|
||||
- identifier: status-page
|
||||
name: Status Page
|
||||
url: https://status.bbaovanc.com
|
@ -1,3 +1,33 @@
|
||||
This is my website.
|
||||
---
|
||||
|
||||
https://boba.best is also my website.
|
||||
title: Home
|
||||
|
||||
description: >-
|
||||
This is my personal website, home to my blog. It's powered by my own custom
|
||||
theme named bobatheme, which is available at
|
||||
https://github.com/BBaoVanC/bobatheme.
|
||||
|
||||
---
|
||||
|
||||
## My Website
|
||||
|
||||
This is my personal website. I wrote it myself from scratch using [my own
|
||||
theme][bobatheme-github] and a static site generator named [Hugo][hugo-website].
|
||||
I occasionally write blog posts under the [blog section][blog-section].
|
||||
|
||||
[bobatheme-github]: https://github.com/BBaoVanC/bobatheme
|
||||
[hugo-website]: https://gohugo.io
|
||||
[blog-section]: {{< ref "/blog/" >}}
|
||||
|
||||
## Topics I write about
|
||||
|
||||
I write mostly about technology, including:
|
||||
|
||||
- Linux
|
||||
- Open Source Software
|
||||
- Programming
|
||||
- Web Development
|
||||
|
||||
## My other website
|
||||
|
||||
I also run another website: https://boba.best.
|
||||
|
8
content/authors/_index.md
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
|
||||
title: Authors
|
||||
|
||||
description: >-
|
||||
List of authors on my website.
|
||||
|
||||
---
|
11
content/authors/bbaovanc/_index.md
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
|
||||
title: bbaovanc
|
||||
issoUserID: 284513e38f5c
|
||||
|
||||
---
|
||||
|
||||
I think you can probably tell from the website URL that I'm the one who owns
|
||||
this website.
|
||||
|
||||
<!--more-->
|
10
content/authors/github-copilot/_index.md
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
title: GitHub Copilot
|
||||
|
||||
---
|
||||
|
||||
More information at https://copilot.github.com/. See [this
|
||||
post](/blog/copilot-post) for how I did it.
|
||||
|
||||
<!--more-->
|
@ -1,7 +1,8 @@
|
||||
+++
|
||||
title = "Blog"
|
||||
---
|
||||
|
||||
description = """
|
||||
My blog posts
|
||||
"""
|
||||
+++
|
||||
title: Blog
|
||||
|
||||
description: >-
|
||||
The home of my blog.
|
||||
|
||||
---
|
||||
|
@ -1,24 +1,35 @@
|
||||
+++
|
||||
title = "Allow Non Root Processes to Bind to Privileged Ports"
|
||||
date = "2021-03-28"
|
||||
aliases = [
|
||||
"posts/allow-non-root-processes-to-bind-to-privileged-ports/",
|
||||
]
|
||||
---
|
||||
|
||||
description = """
|
||||
In Linux, processes cannot bind to privileged ports (<=1024) unless they are
|
||||
title: Allow non root processes to bind to privileged ports in Linux
|
||||
date: 2021-03-28T21:29:52-05:00
|
||||
lastmod: 2022-05-02T01:05:44-05:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
aliases:
|
||||
- posts/allow-non-root-processes-to-bind-to-privileged-ports/
|
||||
|
||||
categories:
|
||||
- guides
|
||||
- linux
|
||||
|
||||
tags:
|
||||
- gitea
|
||||
- systemd
|
||||
|
||||
---
|
||||
|
||||
In Linux, processes cannot bind to privileged ports (<=1024) unless they are
|
||||
running as root. Here's how to allow any process to bind to privileged ports.
|
||||
"""
|
||||
|
||||
tags = [
|
||||
"guide",
|
||||
"linux",
|
||||
]
|
||||
+++
|
||||
<!--more-->
|
||||
|
||||
## Introduction
|
||||
|
||||
In Linux, processes cannot bind to privileged ports (<=1024) unless they are
|
||||
In Linux, processes cannot bind to privileged ports (<=1024) unless they are
|
||||
running as root. I learned about this when I was trying to add SSH cloning to my
|
||||
[Gitea](https://gitea.io) instance. This can be bypassed by giving
|
||||
`CAP_NET_BIND_SERVICE` capabilities to either the systemd service, or the
|
||||
@ -28,9 +39,9 @@ executable itself.
|
||||
|
||||
### Using systemd (preferred)
|
||||
|
||||
The best way is to tell systemd to give `CAP_NET_BIND_SERVICE`
|
||||
capabilities to the service. In fact, the Gitea systemd service has two
|
||||
lines[^1] that are commented out:
|
||||
The best way is to tell systemd to give `CAP_NET_BIND_SERVICE` capabilities to
|
||||
the service. In fact, the Gitea systemd service has two
|
||||
lines[^systemd-set-capabilities] that are commented out:
|
||||
|
||||
```systemd
|
||||
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
|
||||
@ -42,7 +53,7 @@ Uncommenting these two lines was all I had to do for Gitea.
|
||||
### Using `setcap`
|
||||
|
||||
You can add `CAP_NET_BIND_SERVICE` to the executable directly using `setcap`,
|
||||
allowing it to bind to any port. Run the following command[^2]:
|
||||
allowing it to bind to any port. Run the following command[^setcap-command]:
|
||||
|
||||
```bash
|
||||
setcap 'cap_net_bind_service=+ep' /path/to/program
|
||||
@ -51,7 +62,7 @@ setcap 'cap_net_bind_service=+ep' /path/to/program
|
||||
Note that this means that anyone with permission to run this program will be
|
||||
able to run it and bind to any privileged ports.
|
||||
|
||||
Other caveats[^2]:
|
||||
Other caveats[^caveats-quote]:
|
||||
|
||||
> 1. You will need at least a 2.6.24 kernel
|
||||
> 2. This won't work if your file is a script. (ie, uses a #! line to launch an
|
||||
@ -64,6 +75,10 @@ Other caveats[^2]:
|
||||
> privileges like setcap or suid. So if your program uses its own .../lib/,
|
||||
> you might have to look into another option like port forwarding.
|
||||
|
||||
[^1]: https://github.com/go-gitea/gitea/blob/3416e2a82586fca4cd452b93237b979300f55d62/contrib/systemd/gitea.service#L69
|
||||
and https://stackoverflow.com/a/47065825
|
||||
[^2]: https://stackoverflow.com/a/414258
|
||||
|
||||
[^systemd-set-capabilities]: See [these two lines in the Gitea systemd service
|
||||
file](https://github.com/go-gitea/gitea/blob/3416e2a82586fca4cd452b93237b979300f55d62/contrib/systemd/gitea.service#L69)
|
||||
and [this Stack Overflow answer](https://stackoverflow.com/a/47065825).
|
||||
|
||||
[^setcap-command]: https://stackoverflow.com/a/414258
|
||||
[^caveats-quote]: https://stackoverflow.com/a/414258
|
After Width: | Height: | Size: 14 KiB |
@ -0,0 +1,144 @@
|
||||
---
|
||||
|
||||
title: Using GitHub Actions to audit my website with Google Chrome Lighthouse
|
||||
date: 2022-05-07T00:54:11-05:00
|
||||
lastmod: 2022-05-08T16:16:02-05:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
categories:
|
||||
- devops
|
||||
- meta
|
||||
|
||||
tags:
|
||||
- caddy
|
||||
- github-actions
|
||||
- google-lighthouse
|
||||
|
||||
# this will be shown for the article in list pages and in the page metadata
|
||||
# it can be either an image or video (this might change in the future, however)
|
||||
resources:
|
||||
- name: feature
|
||||
src: dashboard-performance-graph.webp
|
||||
title: Picture of the `Performance` section on the Lighthouse CI dashboard
|
||||
|
||||
- name: youtube-embed-performance-comparison
|
||||
src: youtube-embed-performance-comparison.webp
|
||||
title: >-
|
||||
Performance hit caused by adding a YouTube embed. You can see the
|
||||
comparison itself [on this comparison
|
||||
page](https://lhci.bbaovanc.com/app/projects/bbaovanc.com/compare/01d2064b6fac?baseUrl=https%3A%2F%2Flocalhost%2Fblog%2Fthe-redesign-of-my-website%2F&compareUrl=https%3A%2F%2Flocalhost%2Fblog%2Fyoutube-url-structures-you-should-know%2F&baseBuild=01d2064b-6fac-40df-b4e6-373037ae1f9e).
|
||||
|
||||
---
|
||||
|
||||
The other day I set up automatic testing of my website using [Google Chrome
|
||||
Lighthouse][google-lighthouse]. I'm also running my own Lighthouse CI server to
|
||||
store test result history and show trends. Here's an outline of what this means,
|
||||
some of the results I've obtained so far, and my thoughts on the usefulness of
|
||||
Lighthouse.
|
||||
|
||||
[google-lighthouse]: https://developers.google.com/web/tools/lighthouse
|
||||
|
||||
<!--more-->
|
||||
|
||||
## What is Lighthouse?
|
||||
|
||||
Lighthouse is a tool developed by Google which audits websites and gives them a
|
||||
score in four categories: *Performance*, *Accessibility*, *Best Practices*, and
|
||||
*SEO (search engine optimization)*. It's also built into the developer console
|
||||
in Chrome, so you can run it manually on any website you want directly inside
|
||||
your browser.
|
||||
|
||||
I have already been using Lighthouse manually to do occasional tests on my
|
||||
website and its theme, [bobatheme][bobatheme]. However, I recently came across
|
||||
[this GitHub Action][lhci-action]. It caught my eye because I was [already using
|
||||
GitHub Actions][old-audit-workflow] to perform a few basic Hugo[^hugo]-related
|
||||
audits found [in a thread on the Hugo forum][hugo-audits-thread].
|
||||
|
||||
[^hugo]: [Hugo](https://gohugo.io) is the framework that my website is built on. It's
|
||||
a static site generator which generates my site according to my own custom
|
||||
templates that make up my theme.
|
||||
|
||||
[bobatheme]: https://github.com/BBaoVanC/bobatheme
|
||||
[lhci-action]: https://github.com/marketplace/actions/lighthouse-ci-action
|
||||
[old-audit-workflow]: https://github.com/BBaoVanC/bbaovanc.com/blob/31e25c2578a789afe71ce90352747eb427ca3c0e/.github/workflows/audit.yml#L31-L59
|
||||
[hugo-audits-thread]: https://discourse.gohugo.io/t/audit-your-published-site-for-problems/35184
|
||||
|
||||
## Setting it all up
|
||||
|
||||
My goal is to run Lighthouse's audits on an environment as similar to my real
|
||||
website's deployment as possible.
|
||||
|
||||
First, I [created a separate `lighthouse` job on my audit
|
||||
workflow][lighthouse-actions-job] on GitHub Actions. This job will do all of the
|
||||
testing. Since it's a separate job, it runs in parallel with my existing audit
|
||||
task.
|
||||
|
||||
[lighthouse-actions-job]: https://github.com/BBaoVanC/bbaovanc.com/blob/3668b6cfb11d09149b5da347219cdc75d0ce0985/.github/workflows/audit.yml#L7
|
||||
|
||||
Next, I copied [my existing build steps verbatim][production-build-steps]. This
|
||||
makes the site effectively identical to my real deployment on bbaovanc.com. One
|
||||
of the crucial steps is to pre-compress all the files so their compressed
|
||||
versions can be served without the server having to compress them on-the-fly,
|
||||
saving valuable processing power.
|
||||
|
||||
[production-build-steps]: https://github.com/BBaoVanC/bbaovanc.com/blob/db65e9fc23b840429f5c9ad2b43d7dd01a024f36/.github/workflows/deploy.yml#L22-L33
|
||||
|
||||
Serving the compressed files is crucial because it simulates the real world
|
||||
transfer size of the files. In addition, Lighthouse will recommend that you
|
||||
serve the files compressed.
|
||||
|
||||
Inside the audit environment I use the same webserver (Caddy) and a [similar
|
||||
configuration][audit-caddy-config] (compared to the [one running on
|
||||
bbaovanc.com][production-caddy-config]) to what I have running on bbaovanc.com.
|
||||
Caddy also is able to easily run the demo site with HTTPS, even on localhost.
|
||||
That allows it to test certain elements (such as the comment section) that
|
||||
wouldn't be allowed to load if it were plain, unsecured HTTP.
|
||||
|
||||
[audit-caddy-config]: https://github.com/BBaoVanC/bbaovanc.com/blob/3668b6cfb11d09149b5da347219cdc75d0ce0985/Caddyfile
|
||||
[production-caddy-config]: https://git.bbaovanc.com/configs/caddy/src/commit/e3227eb2a2679e27545c2417c2565941f03fb744/conf.d/bbaovanc.com
|
||||
|
||||
{{< see-also "/blog/caddy-is-the-best-webserver" >}}
|
||||
|
||||
I selected [a few significant pages on my website][lighthouse-urls] so
|
||||
Lighthouse can test a wide range of the features in my website's theme. The
|
||||
results of these tests are then uploaded to [my Lighthouse CI
|
||||
server][lhci-dashboard]. There you can view the audit history and see
|
||||
differences in results between builds.
|
||||
|
||||
[lighthouse-urls]: https://github.com/BBaoVanC/bbaovanc.com/blob/3668b6cfb11d09149b5da347219cdc75d0ce0985/lighthouserc.yaml#L4-L19
|
||||
[lhci-dashboard]: https://lhci.bbaovanc.com/app/projects/bbaovanc.com/dashboard
|
||||
|
||||
## What I found from the tests
|
||||
|
||||
### Performance impact of a YouTube video
|
||||
|
||||
I found that embedding a YouTube video using the built-in shortcode in Hugo
|
||||
made the website drastically slower. It's a lot clearer in the audit environment
|
||||
where everything is throttled down a bunch, so the performance impact is more
|
||||
clear. Below is a screenshot of the difference in score between my blog post
|
||||
with a YouTube embed and a similarly sized blog post which has no video.
|
||||
|
||||
{{< figure src="youtube-embed-performance-comparison" >}}
|
||||
|
||||
I can probably optimize this a little by making a copy of the built-in Hugo
|
||||
YouTube shortcode, and modifying it to defer the loading of the remote scripts.
|
||||
That will have to be a future project, and I'll probably write a post if I ever
|
||||
end up testing it.
|
||||
|
||||
## My thoughts on Lighthouse
|
||||
|
||||
You can make the argument that the results from Lighthouse don't really mean
|
||||
much in the real world. On modern devices and a decent internet speed most
|
||||
websites will load just fine.
|
||||
|
||||
Although most pages on my site have a perfect score from Lighthouse, I'm not
|
||||
going to go way out of my way in order to keep it that way. After all,
|
||||
Lighthouse is just a tool intended for "improving the quality of web
|
||||
pages."[^improve-quality-quote] That doesn't mean it needs to be perfect.
|
||||
|
||||
[^improve-quality-quote]: Source: [Google
|
||||
Developers](https://developers.google.com/web/tools/lighthouse)
|
After Width: | Height: | Size: 33 KiB |
105
content/blog/blog-post-newsletter/index.md
Normal file
@ -0,0 +1,105 @@
|
||||
---
|
||||
|
||||
title: Newsletter for my blog posts
|
||||
date: 2022-04-30T01:00:14-05:00
|
||||
lastmod: 2022-05-23T02:17:47-05:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
categories:
|
||||
- meta
|
||||
|
||||
tags:
|
||||
- bobanews
|
||||
- listmonk
|
||||
- newsletter
|
||||
|
||||
# this will be shown for the article in list pages and in the page metadata
|
||||
# it can be either an image or video (this might change in the future, however)
|
||||
resources:
|
||||
- name: feature
|
||||
src: listmonk-bobatheme-template.webp
|
||||
title: My custom newsletter template based on my website's custom theme.
|
||||
|
||||
- name: listmonk-splash
|
||||
src: listmonk-splash.webp
|
||||
title: >-
|
||||
Dashboard on listmonk ---
|
||||
[source](https://listmonk.app/static/images/splash.png)
|
||||
|
||||
---
|
||||
|
||||
I created a newsletter for blog posts on my website so you can sign up for email
|
||||
notifications when I post new ones, so I have more than just an RSS feed.
|
||||
|
||||
<!--more-->
|
||||
|
||||
{{< aside warning >}}
|
||||
I decided that I didn't really want to deal with the extra work of managing a
|
||||
newsletter so I've removed it. (I didn't actually get any sign-ups).
|
||||
{{< /aside >}}
|
||||
|
||||
**See the ["Signing Up" section]({{< ref "#signing-up" >}}) for instructions on
|
||||
how to sign up for the newsletter.**
|
||||
|
||||
## Choosing the right mailing list manager
|
||||
|
||||
For my newsletter manager, I chose [listmonk](https://listmonk.app/). As I was
|
||||
searching for self-hosted newsletter managers, it caught my eye because of how
|
||||
modern and beautiful its interface looks. In fact, it was the only self-hosted
|
||||
newsletter/mailing list manager I looked at that doesn't have an overall old and
|
||||
ugly interface. Additionally, it has a live demo, so I was able to test it out
|
||||
and see if it would be able to meet my (relatively low) requirements.
|
||||
|
||||
{{< figure src="listmonk-splash" >}}
|
||||
|
||||
I also tried out [GNU Mailman 3](https://www.list.org/) about a year ago.
|
||||
However, I could not get it to integrate cleanly with my email
|
||||
server[^mailman-mailcow]. listmonk can operate over SMTP, just like any other
|
||||
program that sends mail. That makes the setup much less complicated, and I was
|
||||
also able to set up the [official Docker
|
||||
image](https://listmonk.app/docs/installation/#docker) using Docker Compose
|
||||
setup just like the other programs I use.
|
||||
|
||||
If you're interested, the Docker Compose configuration files I ended up writing
|
||||
are available at [configs/listmonk on my Gitea
|
||||
instance](https://git.bbaovanc.com/configs/listmonk).
|
||||
|
||||
## Newsletter formatting
|
||||
|
||||
I ended up writing my own template for listmonk from scratch, based on the CSS
|
||||
used in [bobatheme](https://github.com/BBaoVanC/bobatheme), the theme that my
|
||||
website uses. Here's a screenshot of how it currently looks:
|
||||
|
||||
{{< figure src="feature" >}}
|
||||
|
||||
## Signing up
|
||||
|
||||
{{< aside warning >}}
|
||||
I decided that I didn't really want to deal with the extra work of managing a
|
||||
newsletter so I've removed it. (I didn't actually get any sign-ups anyways.)
|
||||
{{< /aside >}}
|
||||
|
||||
You can sign up to get emails about new posts on the [newsletter signup form
|
||||
here](https://lists.bbaovanc.com/subscription/form). Make sure the box next to
|
||||
the list labeled `bbaovanc.com Blog Posts` is checked. You'll need to provide an
|
||||
email address, and optionally a nickname (or your real name if you want).
|
||||
|
||||
Right now there's only one list with public signup enabled, but that may change
|
||||
if you're reading this in the future. In that case, you can sign up for as many
|
||||
or as few lists as you want.
|
||||
|
||||
|
||||
|
||||
[^mailman-mailcow]: Mailman requires access to the mail server over
|
||||
[LMTP](https://en.wikipedia.org/wiki/Local_Mail_Transfer_Protocol). However,
|
||||
giving it access to my mail server over LMTP is not very easy because of the
|
||||
setup that [Mailcow](https://mailcow.email) (my email server) uses. There *is*
|
||||
an existing project called
|
||||
[dockerized-mailcow-mailman](https://github.com/g4rf/dockerized-mailcow-mailman),
|
||||
but it uses the Apache web server to serve the frontend. I'm not familiar with
|
||||
Apache, and also I don't really want to complicate my Mailcow setup switching
|
||||
to an almost completely different setup just for one little program.
|
After Width: | Height: | Size: 13 KiB |
BIN
content/blog/blog-post-newsletter/listmonk-splash.webp
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
content/blog/caddy-is-the-best-webserver/caddy-browse.webp
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
content/blog/caddy-is-the-best-webserver/caddy.webp
Normal file
After Width: | Height: | Size: 42 KiB |
235
content/blog/caddy-is-the-best-webserver/index.md
Normal file
@ -0,0 +1,235 @@
|
||||
---
|
||||
|
||||
title: Caddy is literally the best webserver
|
||||
date: 2021-11-13T00:43:35-06:00
|
||||
lastmod: 2023-01-16T20:57:00-06:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
categories:
|
||||
- linux
|
||||
- sysadmin
|
||||
- software
|
||||
|
||||
tags:
|
||||
- caddy
|
||||
- webserver
|
||||
|
||||
resources:
|
||||
- name: feature
|
||||
src: caddy.webp
|
||||
title: >-
|
||||
Image source:
|
||||
[Caddy](https://caddyserver.com/resources/images/caddy-logo.svg)
|
||||
|
||||
- name: caddy-browse
|
||||
src: caddy-browse.webp
|
||||
title: >-
|
||||
Caddy's gorgeous directory list page.
|
||||
|
||||
---
|
||||
|
||||
After switching from NGINX to Caddy on all of my websites, I have come to the
|
||||
conclusion that Caddy is the best webserver in existence. With automatic HTTPS,
|
||||
a simple configuration file, and more, Caddy is just the best webserver overall
|
||||
for general use.
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Built-in automatic HTTPS
|
||||
|
||||
Caddy can fetch certificates from Let's Encrypt and ZeroSSL out of the box.
|
||||
HTTPS is enabled by default for eligible domains[^hostname-requirements], unless
|
||||
you explicitly tell it not to.
|
||||
|
||||
### Incredible cipher security
|
||||
|
||||
Caddy has incredible defaults for TLS/SSL ciphers. Any site you host on Caddy
|
||||
gets a perfect score from [Qualys SSL Labs](https://www.ssllabs.com/ssltest/)
|
||||
out of the box.[^caddy-qualys-score]
|
||||
|
||||
## Dead simple configuration files: Caddy vs NGINX
|
||||
|
||||
Caddy's configuration file format is the easiest out of all the main webserver.
|
||||
The best way for me to demonstrate this simplicity is to compare it to one of
|
||||
the most popular webservers: [NGINX](https://www.nginx.com/).
|
||||
|
||||
### Serving some static files
|
||||
|
||||
The most essential feature you can use a webserver for.
|
||||
|
||||
#### Caddy
|
||||
|
||||
```caddyfile
|
||||
example.com {
|
||||
root * /var/www/example.com
|
||||
file_server
|
||||
}
|
||||
```
|
||||
|
||||
#### NGINX
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name example.com;
|
||||
index index.html index.txt;
|
||||
root /var/www/example.com;
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
As you can see, the Caddy config is a lot simpler than the NGINX one. But wait,
|
||||
there's more! This NGINX config is unencrypted HTTP only, but the Caddy one will
|
||||
automatically request a certificate from Let's Encrypt, enable HTTPS, and even
|
||||
redirect unencrypted HTTP to HTTPS.
|
||||
|
||||
From now on, for the sake of simplicity, I'll be ignoring HTTPS for the NGINX
|
||||
configs.
|
||||
|
||||
### PHP (PrivateBin)
|
||||
|
||||
The Caddy config for this example is the same as the [one used for
|
||||
bin.boba.best](https://git.boba.best/boba.best/caddy/src/commit/cd00151fbdd784979a8a181980cc36061be68c7d/conf.d/bin.boba.best).
|
||||
I've stripped it down a bit by removing the [custom error
|
||||
pages](https://git.boba.best/boba.best/caddy/src/commit/cd00151fbdd784979a8a181980cc36061be68c7d/Caddyfile#L15-L24),
|
||||
[HSTS](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security), [zstd
|
||||
compression](https://github.com/facebook/zstd), and logging.
|
||||
|
||||
#### Caddy
|
||||
|
||||
```caddyfile
|
||||
bin.boba.best {
|
||||
encode gzip
|
||||
|
||||
root * /var/www/bin.boba.best
|
||||
php_fastcgi unix//run/php/php-fpm.sock
|
||||
file_server
|
||||
}
|
||||
```
|
||||
|
||||
#### NGINX
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name bin.boba.best;
|
||||
index index.html index.txt index.php;
|
||||
root /var/www/bin.boba.best;
|
||||
gzip on;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_pass unix:/run/php/php-fpm.sock;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Reverse proxy + static files (Gitea)
|
||||
|
||||
This last example is based on
|
||||
[git.bbaovanc.com](https://git.bbaovanc.com/boba.best/caddy/src/commit/57c9f0011eae92ef5fa2992d99f01b0956802d64/conf.d/git.bbaovanc.com).
|
||||
Just like the last example, I've stripped off the custom error pages, HSTS, zstd
|
||||
compression, and logging.
|
||||
|
||||
#### Caddy
|
||||
|
||||
```caddyfile
|
||||
git.bbaovanc.com {
|
||||
encode gzip
|
||||
|
||||
handle_path /_/static/assets/* {
|
||||
root * /var/www/git.bbaovanc.com/public
|
||||
file_server
|
||||
}
|
||||
|
||||
handle {
|
||||
reverse_proxy localhost:81 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### NGINX
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name git.bbaovanc.com;
|
||||
gzip on;
|
||||
|
||||
location /_/static/assets {
|
||||
alias /var/www/git.bbaovanc.com/public/;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:81;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
```
|
||||
|
||||
Although in this case the NGINX config was slightly shorter, I find the Caddy
|
||||
one a lot more clear and easy to understand. With NGINX, I find it weird how
|
||||
adding a trailing slash or not defines whether the prefix (`/_/static/assets` in
|
||||
this case) is stripped before searching the filesystem. In Caddy, you can use
|
||||
the `handle_path` directive, instead of just a regular `handle` directive.
|
||||
|
||||
You can read more about how `handle` and `handle_path` work in Caddy on the
|
||||
[Caddy docs](https://caddyserver.com/docs/caddyfile/directives/handle).
|
||||
|
||||
## The smaller details
|
||||
|
||||
These features might not matter to you, but this is my blog, and I care about
|
||||
them, so I'll be including them.
|
||||
|
||||
### Go templates
|
||||
|
||||
Caddy is written in Go and supports [Go
|
||||
templates](https://pkg.go.dev/text/template). This means you can make simple
|
||||
dynamic content while only using Caddy!
|
||||
|
||||
In fact, the [official Caddy website](https://caddyserver.com) is generated
|
||||
entirely using Caddy's and Go templates![^caddy-templating]
|
||||
|
||||
#### Error pages using HTTP Cats
|
||||
|
||||
I use [this
|
||||
snippet](https://git.bbaovanc.com/boba.best/caddy/src/commit/57c9f0011eae92ef5fa2992d99f01b0956802d64/Caddyfile#L8-L15)
|
||||
on both bbaovanc.com and boba.best to make custom error pages using images from
|
||||
[HTTP Cats](https://http.cat). It uses Caddy's template support to generate some
|
||||
simple HTML to show the error code, name, and cat image.
|
||||
|
||||
### Beautiful autoindex file browser
|
||||
|
||||
Apache and NGINX both have an optional "autoindex" feature which generates a
|
||||
list of files in a directory when there's no page there. However, it looks very
|
||||
ugly. Caddy, on the other hand, still has a simple index page, but looks a
|
||||
thousand times better.
|
||||
|
||||
Coincidentally, it matches the theme of my website very well, so I have to put a
|
||||
border around the image.
|
||||
|
||||
{{< figure src="caddy-browse" >}}
|
||||
|
||||
|
||||
[^hostname-requirements]: For the rules on what domains have automatic HTTPS by
|
||||
default, see ["Hostname requirements" on the Caddy
|
||||
documentation](https://caddyserver.com/docs/automatic-https#hostname-requirements).
|
||||
|
||||
[^caddy-qualys-score]: SSL Labs caps the score to an A if HSTS isn't enabled.
|
||||
After enabling it, then you get a perfect A+ score. See [my website's
|
||||
score](https://www.ssllabs.com/ssltest/analyze.html?d=bbaovanc.com&latest)
|
||||
([archived](https://archive.today/4JJDN)) for an example (bbaovanc.com).
|
||||
|
||||
[^caddy-templating]: See more info about templating [on the Caddy
|
||||
docs](https://caddyserver.com/docs/caddyfile/directives/templates#examples)
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@ -1,24 +1,36 @@
|
||||
+++
|
||||
title = "Checkra1n GUI on Other Distros"
|
||||
date = "2021-03-25"
|
||||
aliases = [
|
||||
"posts/checkra1n-gui-on-other-distros/",
|
||||
]
|
||||
---
|
||||
|
||||
title: Checkra1n GUI on other Linux distros
|
||||
date: 2021-03-25T21:19:51-05:00
|
||||
lastmod: 2021-10-16T21:25:38-05:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
aliases:
|
||||
- posts/checkra1n-gui-on-other-distros/
|
||||
|
||||
categories:
|
||||
- guides
|
||||
- jailbreak
|
||||
- linux
|
||||
|
||||
tags:
|
||||
- arch-linux
|
||||
- checkra1n
|
||||
|
||||
resources:
|
||||
- name: feature
|
||||
src: gui.webp
|
||||
title: Checkra1n GUI running on Arch Linux
|
||||
|
||||
---
|
||||
|
||||
description = """
|
||||
You can run the GUI version of checkra1n on non Debian-based distributions.
|
||||
"""
|
||||
|
||||
tags = [
|
||||
"guide",
|
||||
"linux",
|
||||
"archlinux",
|
||||
"jailbreak",
|
||||
"checkra1n",
|
||||
]
|
||||
+++
|
||||
|
||||

|
||||
<!--more-->
|
||||
|
||||
## Introduction
|
||||
|
342
content/blog/copilot-post/index.md
Normal file
@ -0,0 +1,342 @@
|
||||
---
|
||||
|
||||
# this is the title it generated. not even joking
|
||||
title: Copilot
|
||||
date: 2021-11-07T16:20:15-06:00
|
||||
lastmod: 2021-11-07T16:20:15-06:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- GitHub Copilot
|
||||
|
||||
categories:
|
||||
|
||||
tags:
|
||||
- github-copilot
|
||||
|
||||
series:
|
||||
- github-copilot-experiments
|
||||
|
||||
_build:
|
||||
list: never
|
||||
|
||||
---
|
||||
|
||||
Did you know that Copilot is a command line interface for Copilot? It's a tool
|
||||
for creating and managing Copilot projects.
|
||||
|
||||
<!--more-->
|
||||
|
||||
|
||||
{{< aside >}}
|
||||
## What is this post?
|
||||
|
||||
I used [GitHub Copilot](https://copilot.github.com/) to write everything. All I
|
||||
did myself (being a human) was write a couple words and let it finish it off.
|
||||
I'll put any text that I wrote myself in an "aside" box, like you can see on
|
||||
this paragraph.
|
||||
{{< /aside >}}
|
||||
|
||||
## What is Copilot?
|
||||
|
||||
Copilot is a [Cloud Native
|
||||
Computing](https://en.wikipedia.org/wiki/Cloud_computing). It's used for
|
||||
managing the lifecycle of your application. It's also used as a tool for
|
||||
creating and managing Copilot projects.
|
||||
|
||||
## What is this?
|
||||
|
||||
This is an article about [GitHub Copilot]() and the Copilot CLI. It's a tool for
|
||||
creating and managing Copilot projects. I wrote it to help me learn the [GitHub
|
||||
Copilot API]() and to learn how to use the CLI. You can read more about the API
|
||||
[here](https://developer.github.com/v4/explorer/). Next time you want to learn
|
||||
more about Copilot, check out the [GitHub Copilot
|
||||
docs](https://developer.github.com/apps/copilot/).
|
||||
|
||||
## Why is this?
|
||||
|
||||
Because I'm a developer and I like to learn new things. This is a tool I wrote
|
||||
to learn how the Copilot API works. It's a tool for creating and managing
|
||||
Copilot projects. I wrote it to help me learn the [GitHub Copilot API]() and to
|
||||
learn how to use the CLI. You can read more about the API
|
||||
[here](https://developer.github.com/v4/explorer/). Next time you want to learn
|
||||
more about Copilot, check out the [GitHub Copilot
|
||||
docs](https://developer.github.com/apps/copilot/). It's a tool for creating and
|
||||
managing Copilot projects. I wrote it to help me learn the [GitHub Copilot
|
||||
API]() and to learn how to use the CLI. You can read more about the API
|
||||
[here](https://developer.github.com/v4/explorer/). Next time you want to learn
|
||||
more about Copilot, check out the [GitHub Copilot
|
||||
docs](https://developer.github.com/apps/copilot/).
|
||||
|
||||
## How did I write this?
|
||||
|
||||
I used [Hugo](https://gohugo.io/) to write this article. It's a static site
|
||||
generator that makes it easy to create and manage a blog. GitHub Copilot is what
|
||||
I use to create and manage Copilot projects.
|
||||
|
||||
## How do I use this?
|
||||
|
||||
Here's how you use this. You can read more about the CLI
|
||||
[here](https://developer.github.com/apps/copilot/). You can read more about the
|
||||
API [here](https://developer.github.com/v4/explorer/). Next time you want to
|
||||
learn more about Copilot, check out the [GitHub Copilot
|
||||
docs](https://developer.github.com/apps/copilot/). It's a tool for creating and
|
||||
managing Copilot projects. I wrote it to help me learn the [GitHub Copilot
|
||||
API]() and to learn how to use the CLI. You can read more about the API
|
||||
[here](https://developer.github.com/v4/explorer/). Next time you want to learn
|
||||
more about Copilot, check out the [GitHub Copilot
|
||||
docs](https://developer.github.com/apps/copilot/). Did you know that Copilot is
|
||||
a command line interface for Copilot? It's a tool for creating and managing
|
||||
Copilot projects. It's not a tool for creating and managing Copilot projects.
|
||||
It's a tool for creating and managing Copilot projects. I wrote it to help me
|
||||
learn the [GitHub Copilot API]() and to learn how to use the CLI. You can read
|
||||
more about the API [here](https://developer.github.com/v4/explorer/). Next time
|
||||
you want to learn more about Copilot, check out the [GitHub Copilot
|
||||
docs](https://developer.github.com/apps/copilot/).
|
||||
|
||||
## What do I need to know?
|
||||
|
||||
* You need a GitHub account
|
||||
* You need to have a GitHub Copilot API key
|
||||
* You need to have a GitHub Copilot CLI
|
||||
* You need to have a GitHub Copilot project
|
||||
|
||||
## How do I create a project?
|
||||
|
||||
1. Create a project on [GitHub
|
||||
Copilot](https://developer.github.com/apps/copilot/).
|
||||
2. Create a project on [GitHub
|
||||
Copilot](https://developer.github.com/apps/copilot/).
|
||||
3. Create a project on [GitHub
|
||||
Copilot](https://developer.github.com/apps/copilot/).
|
||||
|
||||
## How do I delete a project?
|
||||
|
||||
1. Delete a project on [GitHub
|
||||
Copilot](https://developer.github.com/apps/copilot/).
|
||||
2. Delete a project on [GitHub
|
||||
Copilot](https://developer.github.com/apps/copilot/).
|
||||
3. Delete a project on [GitHub
|
||||
Copilot](https://developer.github.com/apps/copilot/).
|
||||
|
||||
## I want to create a project, but I don't have an API key.
|
||||
|
||||
Well, you need an API key. You can create one on [GitHub
|
||||
Copilot](https://developer.github.com/apps/copilot/). You can create one on
|
||||
[GitHub Copilot](https://developer.github.com/apps/copilot/). You can create one
|
||||
on [GitHub Copilot](https://developer.github.com/apps/copilot/). If you don't
|
||||
have an API key, you can create one on [GitHub
|
||||
Copilot](https://developer.github.com/apps/copilot/). Sorry about that. You can
|
||||
create one on [GitHub Copilot](https://developer.github.com/apps/copilot/).
|
||||
|
||||
|
||||
## I want to create a project, but I don't have a CLI.
|
||||
|
||||
If you don't have a CLI, you can create one on [GitHub
|
||||
Copilot](https://developer.github.com/apps/copilot/). Unfortunately, you can't
|
||||
create one on [GitHub Copilot](https://developer.github.com/apps/copilot/). You
|
||||
can create one on [GitHub Copilot](https://developer.github.com/apps/copilot/).
|
||||
|
||||
{{< aside >}}
|
||||
The following made me laugh:
|
||||
{{< /aside >}}
|
||||
|
||||
## It keeps saying the same thing.
|
||||
|
||||
1. It keeps saying the same thing.
|
||||
2. It keeps saying the same thing.
|
||||
3. It keeps saying the same thing.
|
||||
|
||||
```js
|
||||
var password = process.env.GITHUB_API_KEY;
|
||||
```
|
||||
|
||||
Did you know that Copilot is a command line interface for Copilot? It's a tool
|
||||
for creating and managing Copilot projects. It keeps saying the same thing. You
|
||||
can create one on [GitHub Copilot](https://developer.github.com/apps/copilot/).
|
||||
|
||||
## Code blocks
|
||||
|
||||
{{< aside >}}
|
||||
These next subsections are written by GitHub Copilot. All I did was write the
|
||||
section headers, start the code block, and type some comments to get it started.
|
||||
I have no idea if the code actually works (or even does anything at all), so
|
||||
test it at your own risk!
|
||||
{{< /aside >}}
|
||||
|
||||
### Copilot
|
||||
|
||||
```python
|
||||
import os
|
||||
import json
|
||||
import requests
|
||||
|
||||
# Get the API key from the environment
|
||||
api_key = os.environ.get('GITHUB_API_KEY')
|
||||
# Get the project name from the environment
|
||||
project_name = os.environ.get('GITHUB_PROJECT_NAME')
|
||||
# Get the project description from the environment
|
||||
project_description = os.environ.get('GITHUB_PROJECT_DESCRIPTION')
|
||||
# Get the project homepage from the environment
|
||||
project_homepage = os.environ.get('GITHUB_PROJECT_HOMEPAGE')
|
||||
# Get the project repository from the environment
|
||||
project_repository = os.environ.get('GITHUB_PROJECT_REPOSITORY')
|
||||
# Get the project organization from the environment
|
||||
project_organization = os.environ.get('GITHUB_PROJECT_ORGANIZATION')
|
||||
# Get the project visibility from the environment
|
||||
project_visibility = os.environ.get('GITHUB_PROJECT_VISIBILITY')
|
||||
# Get the project topics from the environment
|
||||
project_topics = os.environ.get('GITHUB_PROJECT_TOPICS')
|
||||
# Get the project languages from the environment
|
||||
project_languages = os.environ.get('GITHUB_PROJECT_LANGUAGES')
|
||||
# Get the project license from the environment
|
||||
project_license = os.environ.get('GITHUB_PROJECT_LICENSE')
|
||||
# Get the project documentation from the environment
|
||||
project_documentation = os.environ.get('GITHUB_PROJECT_DOCUMENTATION')
|
||||
|
||||
# Create the project
|
||||
response = requests.post(
|
||||
'https://api.github.com/orgs/{}/projects'.format(project_organization),
|
||||
headers={
|
||||
'Authorization': 'token {}'.format(api_key),
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data=json.dumps({
|
||||
'name': project_name,
|
||||
'body': project_description,
|
||||
'homepage': project_homepage,
|
||||
'repository_url': project_repository,
|
||||
'visibility': project_visibility,
|
||||
'topics': project_topics,
|
||||
'languages': project_languages,
|
||||
'license_template': project_license,
|
||||
'documentation_url': project_documentation,
|
||||
}),
|
||||
)
|
||||
```
|
||||
|
||||
### A basic Discord bot
|
||||
|
||||
```python
|
||||
import discord
|
||||
import os
|
||||
import json
|
||||
import requests
|
||||
|
||||
# the token of the bot
|
||||
token = os.environ.get('DISCORD_BOT_TOKEN')
|
||||
# the name of the bot
|
||||
name = os.environ.get('DISCORD_BOT_NAME')
|
||||
|
||||
# command handler
|
||||
async def handle_command(message):
|
||||
# get the command
|
||||
command = message.content.split()[0]
|
||||
# get the arguments
|
||||
args = message.content.split()[1:]
|
||||
# get the author
|
||||
author = message.author
|
||||
# get the author's id
|
||||
author_id = message.author.id
|
||||
|
||||
# create the response
|
||||
response = '{}'.format(author.mention)
|
||||
|
||||
# if the command is `ping`
|
||||
if command == 'ping':
|
||||
# respond with pong
|
||||
response = 'pong'
|
||||
|
||||
# if the command is `hello`
|
||||
if command == 'hello':
|
||||
# respond with hello
|
||||
response = 'hello'
|
||||
|
||||
# if the command is `help`
|
||||
if command == 'help':
|
||||
# respond with help
|
||||
response = 'help'
|
||||
|
||||
# send the response
|
||||
await client.send_message(message.channel, response)
|
||||
```
|
||||
|
||||
### A basic Minecraft bot
|
||||
|
||||
```python
|
||||
import minecraft
|
||||
import os
|
||||
import json
|
||||
import requests
|
||||
|
||||
# run the Minecraft bot
|
||||
client = minecraft.Minecraft.create()
|
||||
|
||||
# build a house
|
||||
def build_house(x, y, z):
|
||||
# build a house
|
||||
client.setBlock(x, y, z, 1)
|
||||
client.setBlock(x, y + 1, z, 1)
|
||||
client.setBlock(x, y + 2, z, 1)
|
||||
client.setBlock(x, y + 3, z, 1)
|
||||
client.setBlock(x, y + 4, z, 1)
|
||||
client.setBlock(x, y + 5, z, 1)
|
||||
client.setBlock(x, y + 6, z, 1)
|
||||
client.setBlock(x, y + 7, z, 1)
|
||||
client.setBlock(x, y + 8, z, 1)
|
||||
client.setBlock(x, y + 9, z, 1)
|
||||
client.setBlock(x, y + 10, z, 1)
|
||||
client.setBlock(x, y + 11, z, 1)
|
||||
client.setBlock(x, y + 12, z, 1)
|
||||
client.setBlock(x, y + 13, z, 1)
|
||||
client.setBlock(x, y + 14, z, 1)
|
||||
client.setBlock(x, y + 15, z, 1)
|
||||
client.setBlock(x, y + 16, z, 1)
|
||||
client.setBlock(x, y + 17, z, 1)
|
||||
client.setBlock(x, y + 18, z, 1)
|
||||
client.setBlock(x, y + 19, z, 1)
|
||||
client.setBlock(x, y + 20, z, 1)
|
||||
client.setBlock(x, y + 21, z, 1)
|
||||
client.setBlock(x, y + 22, z, 1)
|
||||
client.setBlock(x, y + 23, z, 1)
|
||||
|
||||
# build a door
|
||||
client.setBlock(x - 1, y + 1, z, 64)
|
||||
client.setBlock(x - 1, y + 2, z, 64)
|
||||
client.setBlock(x - 1, y + 3, z, 64)
|
||||
client.setBlock(x - 1, y + 4, z, 64)
|
||||
client.setBlock(x - 1, y + 5, z, 64)
|
||||
client.setBlock(x - 1, y + 6, z, 64)
|
||||
|
||||
# build a window
|
||||
client.setBlock(x - 1, y + 10, z, 64)
|
||||
client.setBlock(x - 1, y + 11, z, 64)
|
||||
client.setBlock(x - 1, y + 12, z, 64)
|
||||
client.setBlock(x - 1, y + 13, z, 64)
|
||||
```
|
||||
|
||||
### A random program
|
||||
|
||||
```js
|
||||
var x = Math.random() * 10;
|
||||
var y = Math.random() * 10;
|
||||
var z = Math.random() * 10;
|
||||
|
||||
// do something with the coordinates
|
||||
console.log(x, y, z);
|
||||
```
|
||||
|
||||
### Find the last digit of pi
|
||||
|
||||
{{< aside >}}
|
||||
This next one is actually genius.
|
||||
{{< /aside >}}
|
||||
|
||||
```python
|
||||
import math
|
||||
|
||||
# find the last digit of pi
|
||||
def last_digit_of_pi():
|
||||
return int(str(math.pi)[-1])
|
||||
```
|
BIN
content/blog/discord-sex-hack/6969th.webp
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
content/blog/discord-sex-hack/chess.webp
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
content/blog/discord-sex-hack/default-sex.webp
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
content/blog/discord-sex-hack/double-sex.webp
Normal file
After Width: | Height: | Size: 139 KiB |
BIN
content/blog/discord-sex-hack/example.webp
Normal file
After Width: | Height: | Size: 56 KiB |
295
content/blog/discord-sex-hack/index.md
Normal file
@ -0,0 +1,295 @@
|
||||
---
|
||||
|
||||
title: How the "Discord sex" (`s/e/x`) hack works
|
||||
date: 2022-05-11T21:11:17-05:00
|
||||
lastmod: 2022-09-24T14:56:05-05:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
categories:
|
||||
- tips-and-tricks
|
||||
|
||||
tags:
|
||||
- discord
|
||||
- discord-tricks
|
||||
- sed
|
||||
|
||||
_build:
|
||||
# won't appear on main Home page, but will in Blog
|
||||
list: local
|
||||
|
||||
# this will be shown for the article in list pages and in the page metadata
|
||||
# it can be either an image or video (this might change in the future, however)
|
||||
resources:
|
||||
- name: feature
|
||||
src: example.webp
|
||||
title: Result after sending a GIF and then sending `s/e/x`.
|
||||
|
||||
- name: default-sex
|
||||
src: default-sex.webp
|
||||
title: Fallback image on `txnor.com`
|
||||
|
||||
- name: double-sex
|
||||
src: double-sex.webp
|
||||
title: Resulting image after typing `s/e/x` a second time.
|
||||
|
||||
- name: chess
|
||||
src: chess.webp
|
||||
title: This happens once you type `s/w/ag` after having done `s/e/x`.
|
||||
|
||||
- name: sword
|
||||
src: sword.webp
|
||||
title: This happens when you type `s/w/ord` after having done `s/e/x`.
|
||||
- name: sword-atk
|
||||
src: sword-atk.webp
|
||||
title: This happens when you type `s/d/dATK`
|
||||
- name: sword-def
|
||||
src: sword-def.webp
|
||||
title: This happens when you type `s/d/dDEF`
|
||||
- name: sword-hug
|
||||
src: sword-hug.webp
|
||||
title: This happens when you type `s/d/dHUG`
|
||||
- name: sword-win
|
||||
src: sword-win.webp
|
||||
title: Win screen on the `s/w/ord` game.
|
||||
- name: sword-lose
|
||||
src: sword-lose.webp
|
||||
title: Lose screen on the `s/w/ord` game.
|
||||
|
||||
- name: 6969th
|
||||
src: 6969th.webp
|
||||
title: This happens on average (since it's randomized) every 6070th use.
|
||||
|
||||
- name: math-challenge
|
||||
src: math-challenge.webp
|
||||
title: Math challenge example
|
||||
|
||||
---
|
||||
|
||||
There's this trick going around on Discord recently where if you send any GIF
|
||||
from Tenor, and then type `s/e/x`, then it turns it into a different meme GIF.
|
||||
Here's how it works.
|
||||
|
||||
<!--more-->
|
||||
|
||||
{{< aside info >}}
|
||||
Credit goes to Rebane2001 (not me) for making this trick, and setting it up on
|
||||
`txnor.com`.
|
||||
{{< /aside >}}
|
||||
|
||||
## The `sed` syntax
|
||||
|
||||
For operating systems based on Unix or Linux, there's usually a simple terminal
|
||||
command included called [`sed`][sed-wikipedia], which is most commonly used to
|
||||
run text replacement commands. Here's a very simple example of what a basic
|
||||
`sed` command looks like:
|
||||
|
||||
[sed-wikipedia]: https://en.wikipedia.org/wiki/Sed
|
||||
|
||||
```bashsession
|
||||
$ sed 's/hello/goodbye/'
|
||||
```
|
||||
|
||||
Discord likely implemented this in order to appeal to
|
||||
[IRC][irc-wikipedia][^irc-definition] users. Since IRC doesn't support editing
|
||||
messages, it's common for people to send messages in that format to tell people
|
||||
about changes to their previous message. Discord implemented this into both
|
||||
their web/desktop client and their iOS app, excluding the Android app.
|
||||
|
||||
[irc-wikipedia]: https://en.wikipedia.org/wiki/Internet_Relay_Chat
|
||||
|
||||
[^irc-definition]: IRC (Internet Relay Chat) is a simple text-based chat system.
|
||||
It's a very old protocol, however its simplicity and minimalism is the main
|
||||
reason people choose it. It's not very popular anymore.
|
||||
|
||||
Note that while real `sed` commands can get much more complicated, Discord's
|
||||
implementation doesn't support those advanced features[^trailing-slash-note].
|
||||
|
||||
[^trailing-slash-note]: Also note that in Discord's implementation, the trailing
|
||||
slash (after `goodbye`) can be ommitted (making it just `s/hello/goodbye`),
|
||||
but with the real `sed` command, it's required.
|
||||
|
||||
{{< see-also "/blog/text-substitution-in-discord-using-sed" >}}
|
||||
|
||||
## What does `s/e/x` do?
|
||||
|
||||
When you send a GIF using the GIF picker on Discord, it actually sends the link
|
||||
to the GIF, which is served by [Tenor][tenor-website]. For example, here's a GIF
|
||||
sent from Tenor:
|
||||
|
||||
[tenor-website]: https://tenor.com
|
||||
|
||||
https://tenor.com/view/cat-massage-gif-24282757
|
||||
|
||||
Running `s/e/x` will take the first occurrence of `e` and replace it with `x`.
|
||||
The link becomes the following (notice the bolded letter `x`):
|
||||
|
||||
[https://t**x**nor.com/view/cat-massage-gif-24282757][example-1]
|
||||
|
||||
[example-1]: https://txnor.com/view/cat-massage-gif-24282757
|
||||
|
||||
Then, all that's left to do is to buy the domain `txnor.com`, and write a simple
|
||||
program to run on it. In fact, it looks like that domain was purchased purely in
|
||||
order to make this trick possible[^txnor-domain-date].
|
||||
|
||||
[^txnor-domain-date]: According to [a quick WHOIS lookup][txnor-whois], the
|
||||
domain was registered on May 3, 2022. That's the same day that [@Rebane
|
||||
tweeted about the new feature][rebane-tweet] (~~going to https://txnor.com
|
||||
redirects to this tweet~~ now the domain redirects to [Rebane's YouTube video
|
||||
about the hack]({{< ref "#youtube-video" >}})), so I assume that this is the
|
||||
only reason they bought the domain.
|
||||
|
||||
[txnor-whois]: https://www.whois.com/whois/txnor.com
|
||||
[rebane-tweet]: https://twitter.com/rebane2001/status/1521544722875142145
|
||||
|
||||
## How does it display on Discord without redirecting?
|
||||
|
||||
When viewing any of the URLs on `txnor.com` in a normal web browser, you get
|
||||
[redirected to a tweet][rebane-tweet]. However, Discord is able to display the
|
||||
image without being redirected.
|
||||
|
||||
When Discord loads a website to generate an embed, it uses a user
|
||||
agent[^user-agent-definition] (which is a little piece of text which tells the
|
||||
server what your browser is) which looks something like this:
|
||||
|
||||
[^user-agent-definition]: If you actually care, there's a [Wikipedia
|
||||
article](https://en.wikipedia.org/wiki/User_agent), and a [page on
|
||||
WhatIsMyIPAddress.com](https://whatismyipaddress.com/user-agent) which also
|
||||
explain what a user agent is.
|
||||
|
||||
```text
|
||||
User-Agent: Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com/)
|
||||
```
|
||||
|
||||
The important part here is the word `Discord`. If you visit the website with
|
||||
your user agent set to anything containing `Discord`
|
||||
(case-insensitive)[^discord-user-agent], then it serves the image directly.
|
||||
|
||||
[^discord-user-agent]: [According to the source code][user-agent-source-code],
|
||||
it looks like `Intel Mac OS X 11.6; rv:92.0` also triggers the same response.
|
||||
|
||||
[user-agent-source-code]: https://github.com/rebane2001/txnor-server/blob/26c7c279b0b4668c8a3b061692d83c507aeac7c5/txnor.nginx#L23-L27
|
||||
|
||||
## Default image
|
||||
|
||||
If you go to any URL on `txnor.com` that doesn't fit one of the existing
|
||||
patterns/games, then it returns this fallback image:
|
||||
|
||||
{{< figure src="default-sex" >}}
|
||||
|
||||
## Extra features
|
||||
|
||||
### Double sex
|
||||
|
||||
If you then run `s/e/x` a second time, then it changes to a different image:
|
||||
|
||||
{{< figure src="double-sex" >}}
|
||||
|
||||
This works in a simple way as well. The next `e` that appears in the URL is
|
||||
inside `/view/`. So, after typing `s/e/x` a second time, the URL becomes:
|
||||
|
||||
[https://txnor.com/vi**x**w/cat-massage-gif-24282757][example-2]
|
||||
|
||||
[example-2]: https://txnor.com/vixw/cat-massage-gif-24282757
|
||||
|
||||
### Chess (`s/w/ag`)
|
||||
|
||||
Another cool feature is that you can play chess by typing `s/w/ag` after typing
|
||||
the initial message of `s/e/x`.
|
||||
|
||||
{{< figure src="chess" >}}
|
||||
|
||||
### `s/w/ord`
|
||||
|
||||
If you do `s/w/ord` after `s/e/x`, then it starts a fighting game (titled
|
||||
"Wumpagotchi Adventures". You can use three commands: s/d/d**ATK**,
|
||||
s/d/d**DEF**, and s/d/d**HUG**.
|
||||
|
||||
Here are a few example images:
|
||||
|
||||
#### Main `s/w/ord` screen
|
||||
|
||||
{{< figure src="sword" >}}
|
||||
|
||||
#### ATK command
|
||||
|
||||
{{< figure src="sword-atk" >}}
|
||||
|
||||
#### DEF command
|
||||
|
||||
{{< figure src="sword-def" >}}
|
||||
|
||||
#### HUG command
|
||||
|
||||
{{< figure src="sword-hug" >}}
|
||||
|
||||
#### Win screen
|
||||
|
||||
{{< figure src="sword-win" >}}
|
||||
|
||||
#### Lose screen
|
||||
|
||||
{{< figure src="sword-lose" >}}
|
||||
|
||||
### 6969th Discord Sexer
|
||||
|
||||
If you happen to get a one in 6970 chance, it will instead return
|
||||
a special image:
|
||||
|
||||
{{< figure src="6969th" >}}
|
||||
|
||||
[6969th-source]: https://github.com/rebane2001/txnor-server/blob/26c7c279b0b4668c8a3b061692d83c507aeac7c5/sex.py#L130-L133
|
||||
|
||||
Here's a [snippet of the code that handles this chance][6969th-source]:
|
||||
|
||||
```python
|
||||
# 6969th winner image (disable for chess)
|
||||
if random.randint(0, 6969) == 6969 and "ag" not in name:
|
||||
web.header('Cache-Control', 'no-store')
|
||||
return six_nine
|
||||
```
|
||||
|
||||
I believe it's supposed to be a 1/6969 chance, but `random.randint` in Python
|
||||
[includes both numbers][randint-inclusive]. That means that the possible numbers that it could pick
|
||||
would be 0, 1, ... 6968, 6969. If you were to count the numbers included in that
|
||||
sequence, it would total 6970.
|
||||
|
||||
[randint-inclusive]: https://docs.python.org/3/library/random.html#random.randint
|
||||
|
||||
### Math challenge
|
||||
|
||||
Any URL that matches [this regular expression][math-challenge-regex] will
|
||||
instead return a randomized math challenge:
|
||||
|
||||
[math-challenge-regex]: https://regex101.com/r/ddEkML/1
|
||||
|
||||
{{< figure src="math-challenge" >}}
|
||||
|
||||
What's special is that the math challenge is [set to not be
|
||||
cached][math-challenge-caching].
|
||||
|
||||
[math-challenge-caching]: https://github.com/rebane2001/txnor-server/blob/26c7c279b0b4668c8a3b061692d83c507aeac7c5/sex.py#L137
|
||||
|
||||
How it works is that when each person's Discord client sends a request to the
|
||||
Discord CDN to get the image, the client caches that image. That means each
|
||||
client will see the same challenge problem, even if the user restarts the
|
||||
client. But separate clients will not have it cached, so they'll request it
|
||||
again themselves, and different numbers will be generated.
|
||||
|
||||
## Discord sex is open source
|
||||
|
||||
Thanks to a [comment from Rebane on this post](#isso-16), I now know that the
|
||||
server running on `txnor.com` is open source. See
|
||||
[rebane2001/txnor-server][txnor-server-github].
|
||||
|
||||
[txnor-server-github]: https://github.com/rebane2001/txnor-server
|
||||
|
||||
## YouTube video
|
||||
|
||||
Rebane also [made a YouTube video][txnor-youtube-video] about this trick. Make
|
||||
sure to check it out too!
|
||||
|
||||
[txnor-youtube-video]: https://www.youtube.com/watch?v=km8CR-fdB7o
|
BIN
content/blog/discord-sex-hack/math-challenge.webp
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
content/blog/discord-sex-hack/sword-atk.webp
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
content/blog/discord-sex-hack/sword-def.webp
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
content/blog/discord-sex-hack/sword-hug.webp
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
content/blog/discord-sex-hack/sword-lose.webp
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
content/blog/discord-sex-hack/sword-win.webp
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
content/blog/discord-sex-hack/sword.webp
Normal file
After Width: | Height: | Size: 47 KiB |
@ -1,34 +0,0 @@
|
||||
+++
|
||||
title = "Put (edited) in the middle of a message in Discord"
|
||||
date = "2021-03-25"
|
||||
aliases = [
|
||||
"posts/edited-in-middle-of-message-discord/",
|
||||
]
|
||||
|
||||
description = """
|
||||
With a bit of trickery using the RLE character (U+202B), you can get the
|
||||
(edited) text on a message to be somewhere other than at the end of the message.
|
||||
"""
|
||||
|
||||
tags = [
|
||||
"tutorial",
|
||||
"discord",
|
||||
"discord-tricks",
|
||||
]
|
||||
+++
|
||||
|
||||

|
||||
|
||||
## Tutorial
|
||||
|
||||
1. Copy the "right-to-left embedding" character (U+202A) to your clipboard.
|
||||
2. Open editing box of a message
|
||||
3. Delete all text inside
|
||||
4. Paste the character
|
||||
5. Type the text you want on the right of `(edited)`
|
||||
6. Press space and paste the character
|
||||
7. Type the text you want on the left of `(edited)`
|
||||
|
||||
*This post was adapted from [gitea:bbaovanc/discord-tricks][1]*
|
||||
|
||||
[1]: https://git.bbaovanc.com/bbaovanc/discord-tricks
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
77
content/blog/edited-in-middle-of-message-discord/index.md
Normal file
@ -0,0 +1,77 @@
|
||||
---
|
||||
|
||||
title: How to put `(edited)` in the middle of a message in Discord
|
||||
date: 2021-03-25T18:48:34-05:00
|
||||
lastmod: 2022-12-06T19:59:22-06:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
aliases:
|
||||
- posts/edited-in-middle-of-message-discord/
|
||||
|
||||
categories:
|
||||
- guides
|
||||
- tips-and-tricks
|
||||
|
||||
tags:
|
||||
- discord
|
||||
- discord-tricks
|
||||
|
||||
resources:
|
||||
- name: feature
|
||||
src: example.webp
|
||||
title: Example image
|
||||
|
||||
---
|
||||
|
||||
You might have seen a trick on Discord where the little `(edited)` caption
|
||||
appears in the middle of a message instead of at the end. With a small hack
|
||||
involving the [right-to-left embedding character
|
||||
(U+202B)](https://unicode-explorer.com/c/202B), the `(edited)` text can be moved
|
||||
to any location inside the message.
|
||||
|
||||
<!--more-->
|
||||
|
||||
{{< aside note >}}
|
||||
This trick only works if you're on desktop/web, and will also only show to
|
||||
people on desktop/web.
|
||||
{{< /aside >}}
|
||||
|
||||
## Tutorial
|
||||
|
||||
Before you start, copy the "right-to-left embedding" character
|
||||
([U+202B](https://unicode-explorer.com/c/202B)) to your clipboard.
|
||||
|
||||
### Method 1
|
||||
|
||||
With this method you write a placeholder message, and then replace it completely
|
||||
with a new message containing the `(edited)` text inside it all at once.
|
||||
|
||||
1. Send a message with some random text (this text will be replaced entirely)
|
||||
2. Start editing the message you just created and delete all the text inside
|
||||
3. Type the text you want on the left of `(edited)`.
|
||||
4. Type a space, then paste the character twice, and type another space.
|
||||
5. Type the text you want on the right of `(edited)`.
|
||||
6. Save the message.
|
||||
|
||||
You can also start at step 3 instead, send the message, and then perform any
|
||||
edit on the message afterwards to add the `(edited)` text.
|
||||
|
||||
### Method 2
|
||||
|
||||
This method works by adding `(edited)` to the end of an existing message, and
|
||||
then extra text to the right.
|
||||
|
||||
1. Send a message containing the text you want on the left of `(edited)`.
|
||||
2. Start editing the message you just created
|
||||
3. At the end of the message, type a space, then paste the character twice, and
|
||||
type another space.
|
||||
4. Type the text you want on the right of `(edited)`.
|
||||
5. Save the message.
|
||||
|
||||
*This post was adapted from [bbaovanc/discord-tricks][1]*
|
||||
|
||||
[1]: https://git.bbaovanc.com/bbaovanc/discord-tricks
|
BIN
content/blog/github-copilot-experiments/boba-shop-color.webp
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
content/blog/github-copilot-experiments/boba-shop-size.webp
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
content/blog/github-copilot-experiments/boba-shop.webp
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
content/blog/github-copilot-experiments/cheese-burger-poem.webp
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
content/blog/github-copilot-experiments/dropdown-css.webp
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
content/blog/github-copilot-experiments/girlfriend.webp
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
content/blog/github-copilot-experiments/horrible-code.webp
Normal file
After Width: | Height: | Size: 7.2 KiB |
184
content/blog/github-copilot-experiments/index.md
Normal file
@ -0,0 +1,184 @@
|
||||
---
|
||||
|
||||
title: Experimenting with GitHub Copilot
|
||||
date: 2021-11-06T23:56:47-05:00
|
||||
lastmod: 2021-11-08T21:46:39-06:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
categories:
|
||||
- programming
|
||||
- tinkering
|
||||
|
||||
tags:
|
||||
- github-copilot
|
||||
|
||||
series:
|
||||
- github-copilot-experiments
|
||||
|
||||
resources:
|
||||
- name: feature
|
||||
src: boba-shop.webp
|
||||
title: GitHub Copilot tends to repeat stuff.
|
||||
|
||||
- name: rust-poem
|
||||
src: rust-poem.webp
|
||||
|
||||
- name: python-twinkle-poem
|
||||
src: python-twinkle-poem.webp
|
||||
|
||||
- name: horrible-code
|
||||
src: horrible-code.webp
|
||||
|
||||
- name: dropdown-css
|
||||
src: dropdown-css.webp
|
||||
|
||||
- name: boba-shop # same as feature
|
||||
src: boba-shop.webp
|
||||
|
||||
- name: boba-shop-size
|
||||
src: boba-shop-size.webp
|
||||
|
||||
- name: boba-shop-color
|
||||
src: boba-shop-color.webp
|
||||
|
||||
- name: girlfriend
|
||||
src: girlfriend.webp
|
||||
|
||||
- name: cheese-burger-poem
|
||||
src: cheese-burger-poem.webp
|
||||
|
||||
- name: sing
|
||||
src: sing.webp
|
||||
|
||||
- name: what-is-boba
|
||||
src: what-is-boba.webp
|
||||
|
||||
- name: what-is-github-copilot
|
||||
src: what-is-github-copilot.webp
|
||||
|
||||
- name: what-is-the-purpose-of-this-file
|
||||
src: what-is-the-purpose-of-this-file.webp
|
||||
|
||||
- name: who-is-steve-jobs
|
||||
src: who-is-steve-jobs.webp
|
||||
|
||||
---
|
||||
|
||||
I decided to play around with GitHub Copilot. Here's some of the code that I
|
||||
got as a result.
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Poems
|
||||
|
||||
First, I tried to get Copilot to write me a poem in Rust. It didn't really work.
|
||||
|
||||
{{< figure src="rust-poem" >}}
|
||||
|
||||
So, I tried Python instead.
|
||||
|
||||
{{< figure src="python-twinkle-poem" >}}
|
||||
|
||||
This is where I realized that Copilot was doing a little more than just
|
||||
repeating code it had seen before verbatim.
|
||||
|
||||
Before this testing, my understanding was that Copilot was sort of like a search
|
||||
engine. It looked at the context and found a piece of code from GitHub that
|
||||
matched the functionality you wanted. This was the reason I had such a negative
|
||||
opinion about it. I saw it as a way to easily violate copyleft licenses such as
|
||||
GPLv3.
|
||||
|
||||
Anyways, back to more testing.
|
||||
|
||||
## Horrible code
|
||||
|
||||
I decided to ask it to generate some horrible code for me. Unfortunately, it
|
||||
didn't quite do what I wanted.
|
||||
|
||||
{{< figure src="horrible-code" >}}
|
||||
|
||||
## Solving problems in bobatheme
|
||||
|
||||
I decided to consult Copilot on how to make a nice CSS dropdown, which I need
|
||||
for the language picker in bobatheme.
|
||||
|
||||
{{< figure src="dropdown-css" >}}
|
||||
|
||||
Maybe I'll have to test it out.
|
||||
|
||||
## Making a boba shop
|
||||
|
||||
Now, I asked Copilot for help on creating a new
|
||||
[boba](https://en.wikipedia.org/wiki/Bubble_tea) shop, which got a little
|
||||
spammy.
|
||||
|
||||
{{< figure src="boba-shop" >}}
|
||||
|
||||
{{< figure src="boba-shop-size" >}}
|
||||
|
||||
## More random code
|
||||
|
||||
I got some ideas of important questions to ask Copilot thanks to the
|
||||
conversations going on in Discord.
|
||||
|
||||
{{< figure src="girlfriend" >}}
|
||||
|
||||
Turns out the API endpoint in that code is real, and returns a (presumably)
|
||||
nonexistent person.
|
||||
|
||||
## Another poem
|
||||
|
||||
I decided to generate one more poem, this time naming the function something
|
||||
different in hopes of getting a different result.
|
||||
|
||||
{{< figure src="cheese-burger-poem" >}}
|
||||
|
||||
It was a success! And the output of the program:
|
||||
|
||||
```text
|
||||
Mary had a little lamb.
|
||||
Its fleece was white as snow.
|
||||
And everywhere that Mary went.
|
||||
..........
|
||||
Cheese Burger
|
||||
```
|
||||
|
||||
## A song
|
||||
|
||||
I decided to try and get it to sing a song.
|
||||
|
||||
{{< figure src="sing" >}}
|
||||
|
||||
According to Google Translate, here's what that says:
|
||||
|
||||
```python
|
||||
def sing():
|
||||
print("""
|
||||
You are my little pig
|
||||
I love you
|
||||
You are my little pig
|
||||
I love you
|
||||
""")
|
||||
```
|
||||
|
||||
## GitHub Copilot as an encyclopedia
|
||||
|
||||
I decided to ask Copilot a few random questions to test its encyclopedia
|
||||
abilities.
|
||||
|
||||
{{< figure src="what-is-boba" >}}
|
||||
|
||||
{{< figure src="what-is-github-copilot" >}}
|
||||
|
||||
{{< figure src="who-is-steve-jobs" >}}
|
||||
|
||||
I had run out of questions to ask, so I just started the comment with a generic
|
||||
"what is" and let Copilot finish the question and answer.
|
||||
|
||||
{{< figure src="what-is-the-purpose-of-this-file" >}}
|
||||
|
||||
That last line came out of nowhere!
|
BIN
content/blog/github-copilot-experiments/python-twinkle-poem.webp
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
content/blog/github-copilot-experiments/rust-poem.webp
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
content/blog/github-copilot-experiments/sing.webp
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
content/blog/github-copilot-experiments/what-is-boba.webp
Normal file
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 10 KiB |
BIN
content/blog/github-copilot-experiments/who-is-steve-jobs.webp
Normal file
After Width: | Height: | Size: 15 KiB |
@ -1,40 +0,0 @@
|
||||
+++
|
||||
title = "New Comment System (again)"
|
||||
date = "2021-04-17"
|
||||
aliases = [
|
||||
"posts/new-comment-system-again/",
|
||||
]
|
||||
|
||||
description = """
|
||||
I decided to switch my comment system from Isso to
|
||||
[Commento](https://www.commento.io/)
|
||||
"""
|
||||
|
||||
tags = [
|
||||
"announcement",
|
||||
"hugo",
|
||||
"blog",
|
||||
]
|
||||
+++
|
||||
|
||||
## Isso vs Commento
|
||||
|
||||
I know it's only been six days since I added Isso, but I decided to switch to a
|
||||
better comment system. Isso is meant to be simple, which means that it's missing
|
||||
a lot of features. Commento has a lot of features such as sticky (pinned)
|
||||
comments, spam detection, thread locking, email notifications (I couldn't get
|
||||
this working on Isso), and a nicer design. I also was able to write some
|
||||
[custom CSS rules][1] which make it look alright on my blog's theme. It also
|
||||
supports SSO, so I might add support for signing up with GitHub, and possibly
|
||||
GitLab.
|
||||
|
||||
## Summary of the [first post]({{< ref "/blog/new-comment-system" >}})
|
||||
|
||||
If you haven't read the
|
||||
[New Comment System]({{< ref "/blog/new-comment-system" >}}) post, here's the
|
||||
most important information. There's a comment section at the bottom of each post
|
||||
where you can view and post comments. You can post anonymously, or create an
|
||||
account so you can show your username and get email notifications. You can also
|
||||
upvote, downvote, and reply to other comments.
|
||||
|
||||
[1]: https://git.bbaovanc.com/bbaovanc.com/blog/src/commit/478e15218313a33216d361de387b3bd878cd0ba6/assets/css/comments.css
|
@ -1,42 +0,0 @@
|
||||
+++
|
||||
title = "New Comment System"
|
||||
date = "2021-04-11"
|
||||
aliases = [
|
||||
"posts/new-comment-system/",
|
||||
]
|
||||
|
||||
description = """
|
||||
I added a comment system to my blog, using [Isso](https://posativ.org/isso/).
|
||||
"""
|
||||
|
||||
tags = [
|
||||
"announcement",
|
||||
"hugo",
|
||||
"blog",
|
||||
]
|
||||
+++
|
||||
|
||||
## About
|
||||
|
||||
I set up a comment system named [Isso](https://posativ.org/isso/) on my blog
|
||||
today. At the bottom of each blog post, there's a comment section. You don't
|
||||
need to sign up with an account or sign in with Google, Facebook, none of that
|
||||
junk. You can comment anonymously, or provide any of the following three fields:
|
||||
name, email address, and website, which will be shown to other people viewing
|
||||
your comment. I'm going off of the assumption that no one cares/is malicious
|
||||
enough to spam my comment sections.
|
||||
|
||||
## Known Issues
|
||||
|
||||
### Editing and deleting not working
|
||||
|
||||
You're supposed to be able to edit and delete comments up to 15 minutes after
|
||||
posting them. As of now, that doesn't seem to be working; the request just
|
||||
returns 403 (forbidden).
|
||||
|
||||
### White text on white background when previewing comment
|
||||
|
||||
This is a CSS related issue. This was also happening when editing/writing a
|
||||
comment, but I edited it so the edit box has black text. I think a better fix is
|
||||
to make the new comment form have a dark background, but I'll deal with that
|
||||
later.
|
255
content/blog/swapfile-guide/index.md
Normal file
@ -0,0 +1,255 @@
|
||||
---
|
||||
|
||||
title: How to create (or remove) a swapfile on Linux
|
||||
date: 2023-04-04T17:26:44-05:00
|
||||
lastmod: 2023-04-04T17:26:44-05:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
categories:
|
||||
- guides
|
||||
- linux
|
||||
- tips-and-tricks
|
||||
|
||||
tags:
|
||||
- linux-swap
|
||||
- swapfile
|
||||
|
||||
---
|
||||
|
||||
This is a step-by-step tutorial on how to create or remove a swapfile on a Linux
|
||||
machine, and whether you should create swap space in the first place.
|
||||
|
||||
Also included is the most correct `fstab` entry: most articles get this "wrong"
|
||||
(but it doesn't actually matter).
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Should you use swap?
|
||||
|
||||
A common misconception is that adding swap to your system can reduce
|
||||
performance. However, even if you aren't running out of RAM, it can still be
|
||||
beneficial to add swap.
|
||||
|
||||
See these points according to [an article by Hayden James][always-add-swap]:
|
||||
|
||||
> - Even if there is still available RAM, the Linux Kernel will **move memory
|
||||
> pages that are hardly ever used** into swap space.
|
||||
>
|
||||
> - It’s better to swap out memory pages that have been inactive for a while,
|
||||
> **keeping often-used data in cache**, and this should happen when the server
|
||||
> is most idle, which is the aim of the Kernel.
|
||||
>
|
||||
> - Avoid setting your swap space too large if it will result in prolonging
|
||||
> performance issues, outages, or your response time (without proper
|
||||
> monitoring/alerts).
|
||||
|
||||
[always-add-swap]: https://haydenjames.io/linux-performance-almost-always-add-swap-space/
|
||||
|
||||
### Should you use a swap file or partition?
|
||||
|
||||
Swap partitions should be preferred because swapfiles tend to be slower and
|
||||
slightly more complex to set up, especially if hibernating. A swapfile might be
|
||||
preferred due to its flexibility (ease to resize), but if you use
|
||||
[LVM][lvm-archwiki] then you can easily resize the swap partition anyways.
|
||||
|
||||
[lvm-archwiki]: https://wiki.archlinux.org/title/LVM
|
||||
|
||||
## Tutorial
|
||||
|
||||
{{< include path="include/bashsession.md" markdown=true >}}
|
||||
|
||||
### Step 1: Create the file
|
||||
|
||||
The first step is to allocate the file.
|
||||
|
||||
```bashsession
|
||||
# dd if=/dev/zero of=/swapfile bs=1M count=[size in MiB] status=progress
|
||||
```
|
||||
|
||||
Replace `[size in MiB]` with the size of your swapfile in Mebibytes (MiB). You
|
||||
can use [this online converter](https://www.convertunits.com/from/GiB/to/MiB) to
|
||||
convert from Gibibytes (GiB, often confused with Gigabytes, but that's a
|
||||
misconception for another time) to MiB, which you can put in the command.
|
||||
|
||||
Or you can look at this table for common sizes:
|
||||
|
||||
{{< table >}}
|
||||
| GiB | MiB |
|
||||
|-----|-------------|
|
||||
| 1 | count=1024 |
|
||||
| 2 | count=2048 |
|
||||
| 3 | count=3072 |
|
||||
| 4 | count=4096 |
|
||||
| 8 | count=8192 |
|
||||
| 16 | count=16384 |
|
||||
{{< /table >}}
|
||||
|
||||
If you aren't sure how big your swapfile should be, take a look at [Table 15.1
|
||||
on this Red Hat documentation page][redhat-swap-table]. Remember that if your
|
||||
first swapfile isn't large enough, you can create another one.
|
||||
|
||||
[redhat-swap-table]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/ch-swapspace#tb-recommended-system-swap-space
|
||||
|
||||
On my computer I have 32 GiB of RAM and a 16 GiB swap partition, rather than
|
||||
swapfile, because I can flexibly expand the swap partition using
|
||||
[LVM][lvm-archwiki].
|
||||
|
||||
{{< aside example >}}
|
||||
|
||||
To create a swapfile 4 GiB in size, you would run:
|
||||
|
||||
```bashsession
|
||||
# dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress
|
||||
4096+0 records in
|
||||
4096+0 records out
|
||||
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 0.960183 s, 4.5 GB/s
|
||||
```
|
||||
|
||||
{{< /aside >}}
|
||||
|
||||
### Step 2: Change swapfile permissions
|
||||
|
||||
The swapfile should only be readable by the system (`root` user). Run this
|
||||
command to change it:
|
||||
|
||||
```bashsession
|
||||
# chmod 600 /swapfile
|
||||
```
|
||||
|
||||
### Step 3: Format the swapfile
|
||||
|
||||
Use the `mkswap` command to format the file to be used as swap (basically just
|
||||
add a header to identify it):
|
||||
|
||||
```bashsession
|
||||
# mkswap /swapfile
|
||||
Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
|
||||
no label, UUID=a0b87eca-b951-4344-be2d-020d77cdef48
|
||||
```
|
||||
|
||||
### Step 4: Create an entry in `/etc/fstab`
|
||||
|
||||
An entry needs to be added to `/etc/fstab` for the swapfile to be enabled during
|
||||
bootup. Open `/etc/fstab` in a text editor, and add this line to the end (add
|
||||
spaces to line up with other entries if you want, whitespace is ignored):
|
||||
|
||||
```text
|
||||
/swapfile none swap sw 0 0
|
||||
```
|
||||
|
||||
{{< aside note >}}
|
||||
|
||||
Above, I have filled the "options" field with `sw`. Some guides suggest using
|
||||
either `sw` or `defaults`. Neither of those options is valid for `swapon` and
|
||||
they are both ignored. However, the field does need to be filled out with
|
||||
something, so feel free to put something funny (do let me know in the comments
|
||||
if this somehow breaks something though).
|
||||
|
||||
If you're curious, this is my `fstab` entry (`UUID` is because I use a swap
|
||||
partition, rather than swapfile):
|
||||
|
||||
```text
|
||||
# /dev/mapper/bobavg0-swap
|
||||
UUID=4f7c3ae8-839b-4474-b8a5-96bd78db06f8 none swap bobaswap 0 0
|
||||
```
|
||||
|
||||
{{< /aside >}}
|
||||
|
||||
### Step 5: Enable the swapfile
|
||||
|
||||
Adding the `fstab` entry won't enable the swapfile until a reboot. To enable it
|
||||
now, use the `swapon` command.
|
||||
|
||||
```bashsession
|
||||
# swapon /swapfile
|
||||
```
|
||||
|
||||
### Finally: check the swap status
|
||||
|
||||
Use `swapon` and `free` to verify that your new swapfile has been added:
|
||||
|
||||
```bashsession
|
||||
$ swapon --show
|
||||
NAME TYPE SIZE USED PRIO
|
||||
/swapfile file 4G 0B -2
|
||||
|
||||
$ free -h
|
||||
total used free shared buff/cache available
|
||||
Mem: 31Gi 3.6Gi 20Gi 233Mi 6.9Gi 26Gi
|
||||
Swap: 4.0Gi 0B 4.0Gi
|
||||
```
|
||||
|
||||
{{< aside note >}}
|
||||
|
||||
If you get an error saying that the `swapon` command was not found, try running
|
||||
it as `root` (using `sudo`). On Debian-based distributions the `swapon` command
|
||||
is not available to regular users.
|
||||
|
||||
```bashsession
|
||||
$ swapon --show
|
||||
bash: swapon: command not found
|
||||
|
||||
# swapon --show
|
||||
NAME TYPE SIZE USED PRIO
|
||||
/swapfile file 4G 0B -2
|
||||
```
|
||||
|
||||
{{< /aside >}}
|
||||
|
||||
## Removing a swapfile
|
||||
|
||||
{{< aside warning >}}
|
||||
|
||||
Be careful that the swapfile isn't being highly used because once you run
|
||||
`swapoff`, it will dump the entire contents back into RAM and may cause you to
|
||||
run out of memory.
|
||||
|
||||
{{< /aside >}}
|
||||
|
||||
### Step 1: Disable/unload the swapfile
|
||||
|
||||
```bashsession
|
||||
$ swapon --show
|
||||
NAME TYPE SIZE USED PRIO
|
||||
/swapfile file 4G 0B -2
|
||||
|
||||
$ # the path to the swapfile I want to remove is `/swapfile`
|
||||
|
||||
# swapoff /swapfile
|
||||
```
|
||||
|
||||
### Step 2: Remove the entry from `fstab`
|
||||
|
||||
Open `/etc/fstab` in a text editor and find the line matching the swapfile you
|
||||
want to remove, and delete it. For example:
|
||||
|
||||
```text
|
||||
/swapfile none swap sw 0 0
|
||||
```
|
||||
|
||||
### Step 3: Delete the actual file
|
||||
|
||||
```bashsession
|
||||
# rm /swapfile
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
### Use `dd` instead of `fallocate`
|
||||
|
||||
See ["Files with holes" under the man page][swapon-holes-man].
|
||||
|
||||
[swapon-holes-man]: https://man.archlinux.org/man/core/util-linux/swapon.8.en#Files_with_holes
|
||||
|
||||
### The options field in fstab
|
||||
|
||||
On Linux, `sw` doesn't mean anything for `swapon`, so it gets ignored. See:
|
||||
|
||||
- [StackExchange answer 1](https://unix.stackexchange.com/a/365961/525130)
|
||||
- [StackExchange answer 2](https://unix.stackexchange.com/a/365954/525130)
|
||||
- [`parse_options` in the `swapon` source code](https://github.com/util-linux/util-linux/blob/2ea397239683270a0fc8cd3b72ed5457f52dbda8/sys-utils/swapon.c#L699)
|
||||
- [options set by fstab `defaults` (none have any effect on `swapon`)](https://man.archlinux.org/man/fstab.5#The_fourth_field_(%3Ci%3Efs_mntops%3C/i%3E).)
|
@ -1,33 +0,0 @@
|
||||
+++
|
||||
title = "Text Substitution in Discord using `sed`"
|
||||
date = "2021-03-25"
|
||||
aliases = [
|
||||
"posts/text-substitution-in-discord-using-sed/",
|
||||
]
|
||||
|
||||
description = """
|
||||
Discord has (very primitive) support for text replacement using `sed` syntax.
|
||||
"""
|
||||
|
||||
tags = [
|
||||
"tutorial",
|
||||
"discord",
|
||||
"discord-tricks",
|
||||
]
|
||||
+++
|
||||
|
||||
## Tutorial
|
||||
|
||||
[Example Video](/blog/media/discord-tricks/sed-text-replacement.mov)
|
||||
|
||||
If you send a message using `sed` substitution format (`s/old text/new text`),
|
||||
Discord will execute it on the message you've last sent.
|
||||
|
||||
## Caveats
|
||||
|
||||
- Regex is not supported
|
||||
- Global substitution is not supported
|
||||
|
||||
*This post was adapted from [gitea:bbaovanc/discord-tricks][1]*
|
||||
|
||||
[1]: https://git.bbaovanc.com/bbaovanc/discord-tricks
|
47
content/blog/text-substitution-in-discord-using-sed/index.md
Normal file
@ -0,0 +1,47 @@
|
||||
---
|
||||
|
||||
title: Text substitution in Discord using `sed`
|
||||
date: 2021-03-25T18:48:15-05:00
|
||||
lastmod: 2021-10-19T14:02:08-05:00
|
||||
toc: false
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
aliases:
|
||||
- /blog/posts/sed-text-substitution-in-discord/
|
||||
- /blog/posts/text-substitution-in-discord-using-sed/
|
||||
|
||||
categories:
|
||||
- tips-and-tricks
|
||||
|
||||
tags:
|
||||
- discord
|
||||
- discord-tricks
|
||||
- sed
|
||||
|
||||
resources:
|
||||
- name: feature
|
||||
src: example.mov
|
||||
title: Example Video
|
||||
|
||||
---
|
||||
|
||||
Discord has (very primitive) support for text replacement using `sed` syntax.
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Tutorial
|
||||
|
||||
If you send a message using `sed` substitution format (`s/old text/new text`),
|
||||
Discord will execute it on the message you've last sent.
|
||||
|
||||
## Caveats
|
||||
|
||||
- Regex is not supported
|
||||
- Global substitution is not supported
|
||||
|
||||
*This post was adapted from [gitea:bbaovanc/discord-tricks][1]*
|
||||
|
||||
[1]: https://git.bbaovanc.com/bbaovanc/discord-tricks
|
BIN
content/blog/the-redesign-of-my-website/bobatheme.webp
Normal file
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 30 KiB |
113
content/blog/the-redesign-of-my-website/index.md
Normal file
@ -0,0 +1,113 @@
|
||||
---
|
||||
|
||||
title: The redesign of my website
|
||||
date: 2021-10-18T14:03:05-05:00
|
||||
lastmod: 2021-10-27T09:51:43-05:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
categories:
|
||||
- meta
|
||||
|
||||
tags:
|
||||
- bobatheme
|
||||
- hugo
|
||||
- web-development
|
||||
|
||||
resources:
|
||||
- name: feature
|
||||
src: bobatheme.webp
|
||||
title: Homepage on bbaovanc.com, using bobatheme.
|
||||
|
||||
- name: actions-comment
|
||||
src: github-actions-deploy-comment.webp
|
||||
title: Comment from GitHub Actions that links to the pull request preview.
|
||||
|
||||
- name: deployment
|
||||
src: pull-request-deployment.webp
|
||||
title: GitHub deployments are created for the previews as well.
|
||||
|
||||
---
|
||||
|
||||
For the past three weeks I've been designing and perfecting a new theme for my
|
||||
website with the goal of keeping it simple but not ugly.
|
||||
|
||||
<!--more-->
|
||||
|
||||
## A total redesign
|
||||
|
||||
I've switched to a new theme. Visually, it's similar to
|
||||
[hugo-bearblog](https://github.com/janraasch/hugo-bearblog) which was the theme
|
||||
I had previously. Bearblog does a great job for being simple and very light, but
|
||||
it's not featureful enough for me. bobatheme has a lot of fancy features thanks
|
||||
to Hugo. For example: list pages (such as [/blog/]({{< ref "/blog/" >}})) have
|
||||
previews for each article, including featured images or videos for select
|
||||
articles. You can also link to specific headers in an article, and articles have
|
||||
metadata such as word count, reading time, and the git commit that last modified
|
||||
them. My favorite new feature, however, is that bobatheme has icons.
|
||||
|
||||
### Icons
|
||||
|
||||
I'm using an icon pack called [Feather](https://feathericons.com/). Using Hugo,
|
||||
I have a template that just takes the contents of the SVG file and inserts it
|
||||
directly into the HTML source code. While that increases the size of the HTML
|
||||
file, it minimizes the amount of requests that your browser has to make, and in
|
||||
a lot of cases, it will reduce the total amount of data you have to download
|
||||
thanks to compression.
|
||||
|
||||
### No JavaScript (yet)
|
||||
|
||||
There isn't any JavaScript yet, but in the future I'll use a little to add small
|
||||
features such as copying code blocks to the clipboard.
|
||||
|
||||
## My website is on GitHub
|
||||
|
||||
My website's source code was previously on git.bbaovanc.com, but I migrated it
|
||||
to [a new repository on GitHub](https://github.com/BBaoVanC/bbaovanc.com) so I
|
||||
could use Netlify/GitHub Actions to automatically build website previews for
|
||||
pull requests.
|
||||
|
||||
### Automatic Pull Request Previews
|
||||
|
||||
Every pull request has its own preview built for it using GitHub Actions, which
|
||||
is linked in a comment, and shown as a deployment on the pull request.
|
||||
|
||||
{{< figure src="actions-comment" >}}
|
||||
|
||||
{{< figure src="deployment" >}}
|
||||
|
||||
## Translations
|
||||
|
||||
I'm working on translating all pages on my site to Spanish. If you know Spanish,
|
||||
or any other languages, I'd appreciate if you could help out by reviewing
|
||||
existing translations, or submitting new ones. See the [contributing
|
||||
guidelines](https://github.com/BBaoVanC/bbaovanc.com/blob/master/CONTRIBUTING.md#translations)
|
||||
for more information).
|
||||
|
||||
### Tracking Status
|
||||
|
||||
I'm currently tracking translation status using [GitHub
|
||||
projects](https://github.com/BBaoVanC/bbaovanc.com/projects). There's a
|
||||
[Translation Pull Requests](https://github.com/BBaoVanC/bbaovanc.com/projects/1)
|
||||
project which tracks the review status of translation pull requests in all
|
||||
languages. If you want to look at pull requests for a specific language, you can
|
||||
filter by the label (for example: Spanish is `translate-es`).
|
||||
|
||||
### Contribute translations
|
||||
|
||||
If you speak any other languages (especially Spanish), then I'd really
|
||||
appreciate it if you could review any [open translation-related pull
|
||||
requests](https://github.com/BBaoVanC/bbaovanc.com/pulls?q=is%3Apr+is%3Aopen+label%3Atranslation-needs-review).
|
||||
If you have some free time, I'd also appreciate it even more if you could create
|
||||
some new translations into other languages, or write translations for pages that
|
||||
aren't already translated.
|
||||
|
||||
Just remember to read the [contribution
|
||||
guidelines](https://github.com/BBaoVanC/bbaovanc.com/blob/master/CONTRIBUTING.md#translations)
|
||||
before contributing as I have some important information such as how to format
|
||||
pull requests and how to build the site yourself instead of having to wait for
|
||||
Netlify. You can also look at any existing translation related pull requests as
|
||||
an example.
|
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 9.7 KiB |
@ -0,0 +1,66 @@
|
||||
---
|
||||
|
||||
title: Using Github Copilot to write a blog post
|
||||
date: 2021-11-07T16:17:15-06:00
|
||||
lastmod: 2021-11-08T21:46:39-06:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
categories:
|
||||
|
||||
tags:
|
||||
- github-copilot
|
||||
- markdown
|
||||
|
||||
series:
|
||||
- github-copilot-experiments
|
||||
|
||||
# this will be shown for the article in list pages and in the page metadata
|
||||
# it can be either an image or video (this might change in the future, however)
|
||||
resources:
|
||||
- name: feature
|
||||
src: copilot-blog-post.webp
|
||||
title: GitHub Copilot helps me write a blog post.
|
||||
|
||||
- name: print-a-news-article
|
||||
src: print-a-news-article.webp
|
||||
|
||||
---
|
||||
|
||||
I found out that GitHub Copilot can write in Markdown, so I decided to get it to
|
||||
write a blog post for me. Here's how I did it.
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Preface
|
||||
|
||||
I recommend you read my [other blog post about Copilot]({{< ref
|
||||
"/blog/github-copilot-experiments/index.md" >}}) where I showed a bunch of
|
||||
examples of code I generated using Copilot. Near the end of it, I started to
|
||||
experiment asking some questions to it, rather than using it to generate code.
|
||||
That turned out to be a great idea, and led to the creation of this blog post.
|
||||
|
||||
## Writing English with Copilot
|
||||
|
||||
After using Copilot as an encyclopedia, I got an idea. What if I used GitHub
|
||||
Copilot to generate ideas?
|
||||
|
||||
{{< figure src="print-a-news-article" >}}
|
||||
|
||||
I decided to take it a step further and set the language to Markdown. I started
|
||||
writing out the basic structure of a blog post on my website and let it
|
||||
autocomplete.
|
||||
|
||||
{{< figure src="feature" >}}
|
||||
|
||||
I'm not quite sure who Kurt A. Smith is, why Copilot chose April Fools 2020 for
|
||||
the date, or why it was so adamant on writing a blog post about itself. What I
|
||||
do know is that I would be able to write a blog post. All I had to do was type a
|
||||
word or two, and Copilot turned it into a couple sentences.
|
||||
|
||||
## The finished product
|
||||
|
||||
The actual blog post written by Copilot is available [here]({{< ref "../copilot-post/" >}}).
|
After Width: | Height: | Size: 25 KiB |
134
content/blog/youtube-url-structures-you-should-know/index.md
Normal file
@ -0,0 +1,134 @@
|
||||
---
|
||||
|
||||
title: Youtube URL structures you should know
|
||||
date: 2021-10-30T21:20:38-05:00
|
||||
lastmod: 2023-01-16T21:04:09-06:00
|
||||
toc: true
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
categories:
|
||||
- tips-and-tricks
|
||||
|
||||
tags:
|
||||
- query-parameters
|
||||
- url-structures
|
||||
- youtube
|
||||
|
||||
resources:
|
||||
- name: feature
|
||||
src: youtube-url.webp
|
||||
title: YouTube URL
|
||||
|
||||
- name: mdn-url-parameters
|
||||
src: mdn-url-parameters@x2.png
|
||||
title: >-
|
||||
[What is a
|
||||
URL?](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL#parameters)
|
||||
by [Mozilla
|
||||
Contributors](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL/contributors.txt)
|
||||
is licensed under [CC-BY-SA
|
||||
2.5](https://creativecommons.org/licenses/by-sa/2.5/)
|
||||
|
||||
---
|
||||
|
||||
Knowing the basic structure and parameters in a YouTube URL can come in handy on
|
||||
the occasion you need it. Here's how to find the video ID, link to a specific
|
||||
timestamp, and more.
|
||||
|
||||
<!--more-->
|
||||
|
||||
## What is youtu.be?
|
||||
|
||||
YouTube has its own domain for [URL
|
||||
shortening](https://en.wikipedia.org/wiki/URL_shortening): `youtu.be`. It's
|
||||
roughly equivalent to `youtube.com/watch`.
|
||||
|
||||
## Query parameter basics
|
||||
|
||||
Query parameters can be added to a URL just by suffixing it with something like
|
||||
`?key=value&something=else`. That example sets `key` to `value` and `something`
|
||||
to `else`. Note how the first parameter is prefixed with `?`, and then the
|
||||
following parameters are separated with `&`.
|
||||
|
||||
{{< figure src="mdn-url-parameters" >}}
|
||||
|
||||
See the [page on the Mozilla Developer
|
||||
Docs](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL)
|
||||
for more information on the anatomy of a URL.
|
||||
|
||||
## Linking to a video
|
||||
|
||||
Here's the video I'll be using as an example:
|
||||
|
||||
{{< youtube F6va6tg62qg >}}
|
||||
|
||||
I embedded that video on my website with this code:[^hugo-shortcode]
|
||||
|
||||
```text
|
||||
{{</* youtube F6va6tg62qg */>}}
|
||||
```
|
||||
|
||||
The argument there (`F6va6tg62qg`) is the video ID, which is the unique
|
||||
identifier for the video. Here's how the YouTube URLs for that video look:
|
||||
|
||||
- https://www.youtube.com/watch?v=F6va6tg62qg
|
||||
- https://youtu.be/F6va6tg62qg
|
||||
|
||||
Take note that on `youtube.com`, the video ID is provided as a [query
|
||||
parameter](#query-parameter-basics), and on `youtu.be`, it's just provided as
|
||||
the path of the URL.
|
||||
|
||||
## Linking a specific timestamp
|
||||
|
||||
You can add the `t=` parameter to the URL to have it automatically seek to a
|
||||
specific timestamp when opened. The value can be expressed in hours, minutes,
|
||||
and seconds (using `h`, `m`, and `s` respectively). Here's how that looks:
|
||||
|
||||
- https://www.youtube.com/watch?v=F6va6tg62qg&t=14s
|
||||
- https://youtu.be/F6va6tg62qg?t=14s
|
||||
|
||||
Unfortunately my example video isn't long enough to show hours or minutes, so
|
||||
here's a different one:
|
||||
|
||||
- https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=3m14s
|
||||
- https://youtu.be/dQw4w9WgXcQ?t=3m14s
|
||||
|
||||
Those link 3 minutes and 14 seconds into the video. Notice how the `youtube.com`
|
||||
link prefixes the `t=` parameter with an `&` since it's the second parameter.
|
||||
The `youtu.be` link just uses a `?` because it's the first (and only) parameter.
|
||||
|
||||
## Playlists
|
||||
|
||||
The `list=` parameter contains the ID of the playlist you're watching the video
|
||||
from, if any. Otherwise, the parameter is omitted. Here's how that looks:
|
||||
|
||||
- https://www.youtube.com/watch?v=47dtFZ8CFo8&list=PLwxnUUM01nt2nMh9DPq09e6fIDbumybgt
|
||||
- https://youtu.be/47dtFZ8CFo8?list=PLwxnUUM01nt2nMh9DPq09e6fIDbumybgt
|
||||
|
||||
There, the playlist ID was `PLwxnUUM01nt2nMh9DPq09e6fIDbumybgt`. You can link to
|
||||
the playlist itself with a format like:
|
||||
|
||||
```text
|
||||
https://youtube.com/playlist?list=[playlist_id]
|
||||
```
|
||||
|
||||
For example, the direct link to the playlist in the two example links I used is:
|
||||
|
||||
- https://youtube.com/playlist?list=PLwxnUUM01nt2nMh9DPq09e6fIDbumybgt
|
||||
|
||||
As far as I know, it's not possible to link to a playlist using `youtu.be`.
|
||||
|
||||
## Further reading
|
||||
|
||||
[This Stack Exchange answer](https://webapps.stackexchange.com/a/9881) is a good
|
||||
reference for some other YouTube parameters.
|
||||
|
||||
[^hugo-shortcode]: I use a static site generator called
|
||||
[Hugo](https://gohugo.io) for my website. It has a built in "shortcode" which
|
||||
is a feature that allows me to embed certain code blocks into a page. One of
|
||||
its shortcodes, named `youtube`, allows me to embed a YouTube video into my
|
||||
post. You can read more info about [shortcodes on the Hugo
|
||||
docs](https://gohugo.io/content-management/shortcodes/#use-hugos-built-in-shortcodes)
|
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 3.3 KiB |
7
content/categories/_index.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
title: Categories
|
||||
|
||||
---
|
||||
|
||||
List of categories on my website. These are different types or styles of posts.
|
11
content/categories/devops/_index.md
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
|
||||
title: DevOps
|
||||
|
||||
---
|
||||
|
||||
Posts about toolchain and software pipeline stuff. The abbreviation means
|
||||
software development (Dev) plus IT operations (Ops). Includes things such as
|
||||
CI/CD (GitHub Actions).
|
||||
|
||||
<!--more-->
|
9
content/categories/guides/_index.md
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
title: Guides
|
||||
|
||||
---
|
||||
|
||||
Any kind of guide or tutorial.
|
||||
|
||||
<!--more-->
|
9
content/categories/jailbreak/_index.md
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
title: Jailbreak
|
||||
|
||||
---
|
||||
|
||||
Anything related to jailbreaking (iOS or other Apple devices).
|
||||
|
||||
<!--more-->
|
9
content/categories/linux/_index.md
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
title: Linux
|
||||
|
||||
---
|
||||
|
||||
Anything relating to Linux (the kernel or operating systems).
|
||||
|
||||
<!--more-->
|
9
content/categories/meta/_index.md
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
title: Meta
|
||||
|
||||
---
|
||||
|
||||
Posts talking about my website.
|
||||
|
||||
<!--more-->
|
9
content/categories/programming/_index.md
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
title: Programming
|
||||
|
||||
---
|
||||
|
||||
Any posts relating to programming and/or software development.
|
||||
|
||||
<!--more-->
|
9
content/categories/software/_index.md
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
title: Software
|
||||
|
||||
---
|
||||
|
||||
Posts that discuss/review various programs.
|
||||
|
||||
<!--more-->
|
10
content/categories/sysadmin/_index.md
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
title: Sysadmin
|
||||
|
||||
---
|
||||
|
||||
Anything relating to managing servers (usually relating to Linux). "Sysadmin" is
|
||||
short for "system administrator".
|
||||
|
||||
<!--more-->
|
9
content/categories/tinkering/_index.md
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
title: Tinkering
|
||||
|
||||
---
|
||||
|
||||
Posts where I experiment with things.
|
||||
|
||||
<!--more-->
|
10
content/categories/tips-and-tricks/_index.md
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
title: Tips and Tricks
|
||||
|
||||
---
|
||||
|
||||
Random little tips and/or tricks that I want to share. Will probably be mostly
|
||||
short articles (but that's not a bad thing).
|
||||
|
||||
<!--more-->
|
@ -1,11 +0,0 @@
|
||||
+++
|
||||
title = "Contact"
|
||||
menu = "main"
|
||||
|
||||
description = """
|
||||
List of ways to contact me
|
||||
"""
|
||||
+++
|
||||
|
||||
- [Email](mailto:contact@bbaovanc.com)
|
||||
- [Matrix](https://matrix.to/#/@bbaovanc:boba.best)
|
20
content/contact/index.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
|
||||
title: Contact
|
||||
menu: main
|
||||
toc: false
|
||||
comments: true
|
||||
|
||||
authors:
|
||||
- bbaovanc
|
||||
|
||||
description: >-
|
||||
Want to contact me? Here's how you can.
|
||||
|
||||
---
|
||||
|
||||
- Email: bbaovanc@bbaovanc.com
|
||||
- If needed, encrypt your email with [my PGP
|
||||
key](https://keyserver.ubuntu.com/pks/lookup?search=bbaovanc%40bbaovanc.com&fingerprint=on&op=index)
|
||||
- GitHub Discussions (Q&A):
|
||||
https://github.com/BBaoVanC/bbaovanc.com/discussions/categories/q-a
|