Migrating notes from Notion - Initial stage

This commit is contained in:
2025-02-14 16:56:31 +00:00
parent 8e3b07730b
commit 2c6d0e104d
167 changed files with 39800 additions and 1 deletions

5
content/notes/.obsidian/app.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"promptDelete": false,
"tabSize": 2,
"alwaysUpdateLinks": true
}

View File

@@ -0,0 +1,9 @@
{
"accentColor": "#f5bd5c",
"cssTheme": "Adwaita",
"interfaceFontFamily": "Adwaita Sans",
"textFontFamily": "Adwaita Sans",
"monospaceFontFamily": "Adwaita Mono",
"nativeMenus": false,
"baseFontSize": 16
}

View File

@@ -0,0 +1,8 @@
[
"obsidian-importer",
"obsidian-linter",
"table-editor-obsidian",
"obsidian-languagetool-plugin",
"obsidian-local-images-plus",
"obsidian-bulk-rename-plugin"
]

View File

@@ -0,0 +1,31 @@
{
"file-explorer": true,
"global-search": true,
"switcher": true,
"graph": true,
"backlink": true,
"canvas": true,
"outgoing-link": true,
"tag-pane": true,
"properties": false,
"page-preview": true,
"daily-notes": true,
"templates": true,
"note-composer": true,
"command-palette": true,
"slash-command": true,
"editor-status": true,
"bookmarks": true,
"markdown-importer": false,
"zk-prefixer": false,
"random-note": false,
"outline": true,
"word-count": true,
"slides": true,
"audio-recorder": false,
"workspaces": false,
"file-recovery": true,
"publish": false,
"sync": false,
"webviewer": false
}

37
content/notes/.obsidian/graph.json vendored Normal file
View File

@@ -0,0 +1,37 @@
{
"collapse-filter": false,
"search": "",
"showTags": false,
"showAttachments": false,
"hideUnresolved": false,
"showOrphans": true,
"collapse-color-groups": false,
"colorGroups": [
{
"query": "path:Notion ",
"color": {
"a": 1,
"rgb": 14701138
}
},
{
"query": "path:temp ",
"color": {
"a": 1,
"rgb": 16711680
}
}
],
"collapse-display": false,
"showArrow": false,
"textFadeMultiplier": 0,
"nodeSizeMultiplier": 1,
"lineSizeMultiplier": 1,
"collapse-forces": true,
"centerStrength": 0.518713248970312,
"repelStrength": 10,
"linkStrength": 1,
"linkDistance": 250,
"scale": 0.12668834340524918,
"close": true
}

View File

@@ -0,0 +1,13 @@
{
"folderName": "temp",
"fileNames": [],
"existingSymbol": "",
"replacePattern": "",
"regExpState": {
"regExp": "",
"flags": [],
"withRegExpForReplaceSymbols": false
},
"tags": [],
"viewType": "folder"
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
{
"id": "obsidian-bulk-rename-plugin",
"name": "Bulk Rename",
"version": "0.5.2",
"minAppVersion": "0.15.0",
"description": "Purpose of this plugin rename files based on pattern",
"author": "Oleg Lustenko",
"authorUrl": "https://obsidian.md",
"isDesktopOnly": false
}

View File

@@ -0,0 +1,155 @@
.bulk_rename_plugin {
padding-right: 1rem;
}
.bulk_rename {
width: calc(100% - 20px);
}
.bulk_rename_preview {
width: 80%;
height: 100%;
gap: 0;
}
@media screen and (max-width: 983px) {
.bulk_rename_preview {
display: flex;
flex-direction: column;
max-height: 300px;
}
}
.flex {
display: flex;
}
.flex-col {
flex-direction: column;
}
.m-auto {
margin: auto;
}
.bulk_info {
display: flex;
justify-content: space-between;
margin: auto;
width: 100%;
}
.bulk_rename_preview > textarea {
height: 360px;
}
.replaceRenderSymbols {
display: flex;
width: 100%;
padding-top: 0.5rem;
}
.setting-item-control.replaceRenderSymbols .bulk_input {
min-height: 80px;
}
.setting-item-control .bulk_preview_textarea {
min-width: 19em;
}
.bulk_preview_textarea {
margin-left: 5px;
margin-right: 5px;
font-size: 14px;
width: 100%;
height: 400px;
resize: none;
}
.bulk_button {
width: 100%;
}
.bulk_preview_header {
margin-top: 5px;
margin-bottom: 5px;
}
.setting-item-control .bulk_input {
width: 100%;
resize: none;
min-width: auto;
}
.setting-item-control .bulk_input:first-child {
margin-right: 15px;
}
.bulk_regexp_search {
padding-right: 1rem;
}
.bulk_toggle {
border-top: none;
}
.bulk_preview_label:first-child {
margin-right: 15px;
}
.bulk_preview_label {
text-align: center;
}
.bulk_regexp_container {
justify-content: space-between;
}
.bulk_regexp_control {
background: var(--background-modifier-form-field);
border: 1px solid var(--background-modifier-border);
transition: box-shadow 0.15s ease-in-out, border 0.15s ease-in-out;
font-family: inherit;
border-radius: var(--input-radius);
outline: none;
max-width: 400px;
}
.bulk_regexp_control:hover,
.bulk_regexp_control:focus,
.bulk_regexp_control:focus-visible {
box-shadow: 0 0 0 2px var(--background-modifier-border-hover);
}
.bulk_regexp_control > input {
border: none;
margin: 0;
padding: 0;
}
.bulk_regexp,
.bulk_regexp_flags {
width: 100%;
}
.bulk_regexp:hover,
.bulk_regexp:focus,
.bulk_regexp:focus-visible .bulk_regexp_flags:hover,
.bulk_regexp_flags:focus,
.bulk_regexp_flags:focus-visible {
border: none !important;
box-shadow: none !important;
}
.bulk_regexp_flags {
caret-color: transparent;
max-width: 80px;
}
.bulk_regexp_slash {
font-size: 1.5em;
opacity: 0.5;
}
.bulk-flag-selected {
background-color: lavender !important;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
{
"id": "obsidian-importer",
"name": "Importer",
"version": "1.6.19",
"minAppVersion": "0.15.0",
"description": "Import data from Notion, Evernote, Apple Notes, Microsoft OneNote, Google Keep, Bear, Roam, and HTML files.",
"author": "Obsidian",
"authorUrl": "https://obsidian.md",
"isDesktopOnly": false
}

View File

@@ -0,0 +1,87 @@
.modal.mod-importer {
max-height: var(--modal-height);
padding: var(--size-4-4) 0 0 0;
position: relative;
overflow: hidden;
}
.modal.mod-importer .modal-title {
padding: 0 var(--size-4-4);
}
.modal.mod-importer .modal-content {
overflow: auto;
padding: var(--size-4-4);
margin-bottom: calc(var(--input-height) + var(--size-4-8));
border-top: var(--border-width) solid var(--background-modifier-border);
}
.modal.mod-importer .modal-button-container {
margin: 0 0 0 calc(var(--size-4-4) * -1);
padding: var(--size-4-4);
gap: var(--size-4-2);
position: absolute;
bottom: 0;
background-color: var(--background-primary);
border-top: var(--border-width) solid var(--background-modifier-border);
width: 100%;
}
.importer-progress-bar {
width: 100%;
height: 8px;
background-color: var(--background-secondary);
overflow: hidden;
box-shadow: inset 0px 0px 0px 1px var(--background-modifier-border);
border-radius: var(--radius-s);
}
.importer-progress-bar-inner {
width: 0;
height: 100%;
background-color: var(--interactive-accent);
}
.importer-status {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding: var(--size-4-2) 0;
}
.importer-stats-container {
display: flex;
justify-content: space-evenly;
margin-top: var(--size-4-5);
margin-bottom: var(--size-4-5);
}
.importer-stat {
text-align: center;
}
.importer-stat-count {
font-size: var(--font-ui-large);
}
.importer-log {
overflow: auto;
flex-grow: 1;
font-family: var(--font-monospace);
font-size: var(--font-ui-smaller);
color: var(--text-muted);
border: 1px solid var(--background-modifier-border);
padding: var(--size-4-4);
background-color: var(--background-secondary);
border-radius: var(--radius-s);
max-height: 300px;
user-select: text;
}
.importer-log .list-item {
display: inline-block;
line-height: var(--line-height-normal);
white-space: pre;
margin: var(--size-2-1);
}
.importer-error {
color: var(--text-error);
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
{
"id": "obsidian-languagetool-plugin",
"name": "LanguageTool Integration",
"version": "0.3.7",
"minAppVersion": "0.15.2",
"description": "Inofficial LanguageTool plugin",
"author": "Clemens Ertle",
"authorUrl": "https://github.com/Clemens-E",
"isDesktopOnly": false
}

View File

@@ -0,0 +1,204 @@
.lt-underline {
cursor: pointer;
transition: background-color 100ms ease-out;
}
.lt-underline.lt-minor {
box-shadow: inset 0 -2px #e9b35f;
}
.lt-underline.lt-major {
box-shadow: inset 0 -2px #da615c;
}
.lt-underline.lt-style {
box-shadow: inset 0 -2px #8981f3;
}
.lt-underline.lt-minor:hover {
background-color: #e9b35f21;
}
.lt-underline.lt-major:hover {
background-color: #da615c21;
}
.lt-underline.lt-style:hover {
background-color: #8981f321;
}
@keyframes lineInserted {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.lt-predictions-container-glass.cm-tooltip,
.lt-predictions-container.cm-tooltip,
.lt-predictions-container-glass,
.lt-predictions-container {
position: absolute;
animation-duration: 150ms;
animation-name: lineInserted;
font-family: var(--default-font);
font-size: 0.93rem;
padding: 12px 0 0;
background-color: var(--background-primary);
border: 1px solid var(--background-modifier-border);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
border-radius: 6px;
width: 300px;
line-height: 1.5;
z-index: var(--layer-popover);
overflow: visible;
}
.lt-predictions-container-glass {
background: hsla(0, 0%, 100%, 0.25);
backdrop-filter: blur(12px);
}
.lt-predictions-container > button {
transition-delay: 0.5s;
}
.lt-buttoncontainer:not(:empty) {
padding-top: 10px;
}
.lt-buttoncontainer > button {
border: 1px solid var(--background-modifier-border);
font-size: 1rem;
margin-right: 4px;
margin-bottom: 4px;
padding: 4px 10px;
}
.lt-title {
display: block;
font-weight: 600;
margin-bottom: 6px;
padding: 0 12px;
}
.lt-message {
padding: 0 12px;
display: block;
}
.lt-bottom {
min-height: 10px;
padding-left: 12px;
position: relative;
}
.lt-info-container {
position: absolute;
right: 0;
bottom: 0;
}
.lt-info-button {
color: var(--text-faint);
}
.lt-info-box {
position: absolute;
right: 0;
animation-duration: 150ms;
animation-name: lineInserted;
font-family: var(--default-font);
font-size: 0.93rem;
padding: 12px 0;
background-color: var(--background-primary);
border: 1px solid var(--background-modifier-border);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
border-radius: 6px;
line-height: 1.5;
z-index: var(--layer-popover);
overflow: hidden;
}
.hidden {
display: none;
}
.lt-info {
padding: 0 12px;
display: block;
font-size: 0.8rem;
color: var(--text-muted);
user-select: text;
-webkit-user-select: text;
}
.lt-ignorecontainer {
display: flex;
}
.lt-status-bar-btn {
height: 100%;
display: flex;
cursor: pointer;
line-height: 1;
align-items: center;
}
.lt-status-bar-check-icon {
display: block;
text-decoration: underline;
text-decoration-style: dotted;
}
.lt-ignore-btn {
margin: 0;
padding: 12px;
display: flex;
width: 100%;
text-align: left;
border-radius: 0;
align-items: center;
line-height: 1;
border-top: 1px solid var(--background-modifier-border);
}
.lt-ignore-btn > span {
display: flex;
}
.lt-ignore-btn > span:last-child {
margin-left: 5px;
}
.lt-minor .lt-title > span {
box-shadow: inset 0 -2px #e9b35f88;
}
.lt-major .lt-title > span {
box-shadow: inset 0 -2px #da615c88;
}
.lt-style .lt-title > span {
box-shadow: inset 0 -2px #8981f388;
}
.lt-loading > svg {
animation-name: spin;
animation-duration: 1s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View File

@@ -0,0 +1,293 @@
{
"ruleConfigs": {
"add-blank-line-after-yaml": {
"enabled": false
},
"dedupe-yaml-array-values": {
"enabled": false,
"dedupe-alias-key": true,
"dedupe-tag-key": true,
"dedupe-array-keys": true,
"ignore-keys": ""
},
"escape-yaml-special-characters": {
"enabled": false,
"try-to-escape-single-line-arrays": false
},
"force-yaml-escape": {
"enabled": false,
"force-yaml-escape-keys": ""
},
"format-tags-in-yaml": {
"enabled": false
},
"format-yaml-array": {
"enabled": false,
"alias-key": true,
"tag-key": true,
"default-array-style": "single-line",
"default-array-keys": true,
"force-single-line-array-style": "",
"force-multi-line-array-style": ""
},
"insert-yaml-attributes": {
"enabled": false,
"text-to-insert": "aliases: \ntags: "
},
"move-tags-to-yaml": {
"enabled": false,
"how-to-handle-existing-tags": "Nothing",
"tags-to-ignore": ""
},
"remove-yaml-keys": {
"enabled": false,
"yaml-keys-to-remove": ""
},
"sort-yaml-array-values": {
"enabled": false,
"sort-alias-key": true,
"sort-tag-key": true,
"sort-array-keys": true,
"ignore-keys": "",
"sort-order": "Ascending Alphabetical"
},
"yaml-key-sort": {
"enabled": false,
"yaml-key-priority-sort-order": "",
"priority-keys-at-start-of-yaml": true,
"yaml-sort-order-for-other-keys": "None"
},
"yaml-timestamp": {
"enabled": false,
"date-created": true,
"date-created-key": "date created",
"date-created-source-of-truth": "file system",
"date-modified": true,
"date-modified-key": "date modified",
"date-modified-source-of-truth": "file system",
"format": "dddd, MMMM Do YYYY, h:mm:ss a",
"convert-to-utc": false,
"update-on-file-contents-updated": "never"
},
"yaml-title": {
"enabled": false,
"title-key": "title",
"mode": "first-h1-or-filename-if-h1-missing"
},
"yaml-title-alias": {
"enabled": false,
"preserve-existing-alias-section-style": true,
"keep-alias-that-matches-the-filename": false,
"use-yaml-key-to-keep-track-of-old-filename-or-heading": true,
"alias-helper-key": "linter-yaml-title-alias"
},
"capitalize-headings": {
"enabled": true,
"style": "Title Case",
"ignore-case-words": true,
"ignore-words": "macOS, iOS, iPhone, iPad, JavaScript, TypeScript, AppleScript, I",
"lowercase-words": "a, an, the, aboard, about, abt., above, abreast, absent, across, after, against, along, aloft, alongside, amid, amidst, mid, midst, among, amongst, anti, apropos, around, round, as, aslant, astride, at, atop, ontop, bar, barring, before, B4, behind, below, beneath, neath, beside, besides, between, 'tween, beyond, but, by, chez, circa, c., ca., come, concerning, contra, counting, cum, despite, spite, down, during, effective, ere, except, excepting, excluding, failing, following, for, from, in, including, inside, into, less, like, minus, modulo, mod, near, nearer, nearest, next, notwithstanding, of, o', off, offshore, on, onto, opposite, out, outside, over, o'er, pace, past, pending, per, plus, post, pre, pro, qua, re, regarding, respecting, sans, save, saving, short, since, sub, than, through, thru, throughout, thruout, till, times, to, t', touching, toward, towards, under, underneath, unlike, until, unto, up, upon, versus, vs., v., via, vice, vis-à-vis, wanting, with, w/, w., c̄, within, w/i, without, 'thout, w/o, abroad, adrift, aft, afterward, afterwards, ahead, apart, ashore, aside, away, back, backward, backwards, beforehand, downhill, downstage, downstairs, downstream, downward, downwards, downwind, east, eastward, eastwards, forth, forward, forwards, heavenward, heavenwards, hence, henceforth, here, hereby, herein, hereof, hereto, herewith, home, homeward, homewards, indoors, inward, inwards, leftward, leftwards, north, northeast, northward, northwards, northwest, now, onward, onwards, outdoors, outward, outwards, overboard, overhead, overland, overseas, rightward, rightwards, seaward, seawards, skywards, skyward, south, southeast, southwards, southward, southwest, then, thence, thenceforth, there, thereby, therein, thereof, thereto, therewith, together, underfoot, underground, uphill, upstage, upstairs, upstream, upward, upwards, upwind, west, westward, westwards, when, whence, where, whereby, wherein, whereto, wherewith, although, because, considering, given, granted, if, lest, once, provided, providing, seeing, so, supposing, though, unless, whenever, whereas, wherever, while, whilst, ago, according to, as regards, counter to, instead of, owing to, pertaining to, at the behest of, at the expense of, at the hands of, at risk of, at the risk of, at variance with, by dint of, by means of, by virtue of, by way of, for the sake of, for sake of, for lack of, for want of, from want of, in accordance with, in addition to, in case of, in charge of, in compliance with, in conformity with, in contact with, in exchange for, in favor of, in front of, in lieu of, in light of, in the light of, in line with, in place of, in point of, in quest of, in relation to, in regard to, with regard to, in respect to, with respect to, in return for, in search of, in step with, in touch with, in terms of, in the name of, in view of, on account of, on behalf of, on grounds of, on the grounds of, on the part of, on top of, with a view to, with the exception of, à la, a la, as soon as, as well as, close to, due to, far from, in case, other than, prior to, pursuant to, regardless of, subsequent to, as long as, as much as, as far as, by the time, in as much as, inasmuch, in order to, in order that, even, provide that, if only, whether, whose, whoever, why, how, or not, whatever, what, both, and, or, not only, but also, either, neither, nor, just, rather, no sooner, such, that, yet, is, it"
},
"file-name-heading": {
"enabled": false
},
"header-increment": {
"enabled": true,
"start-at-h2": true
},
"headings-start-line": {
"enabled": true
},
"remove-trailing-punctuation-in-heading": {
"enabled": false,
"punctuation-to-remove": ".,;:!。,;:!"
},
"footnote-after-punctuation": {
"enabled": false
},
"move-footnotes-to-the-bottom": {
"enabled": false
},
"re-index-footnotes": {
"enabled": false
},
"auto-correct-common-misspellings": {
"enabled": false,
"ignore-words": "",
"skip-words-with-multiple-capitals": false,
"extra-auto-correct-files": []
},
"blockquote-style": {
"enabled": true,
"style": "space"
},
"convert-bullet-list-markers": {
"enabled": false
},
"default-language-for-code-fences": {
"enabled": false,
"default-language": ""
},
"emphasis-style": {
"enabled": true,
"style": "asterisk"
},
"no-bare-urls": {
"enabled": false,
"no-bare-uris": false
},
"ordered-list-style": {
"enabled": true,
"number-style": "ascending",
"list-end-style": ".",
"preserve-start": true
},
"proper-ellipsis": {
"enabled": false
},
"quote-style": {
"enabled": true,
"single-quote-enabled": true,
"single-quote-style": "''",
"double-quote-enabled": true,
"double-quote-style": "\"\""
},
"remove-consecutive-list-markers": {
"enabled": true
},
"remove-empty-list-markers": {
"enabled": true
},
"remove-hyphenated-line-breaks": {
"enabled": true
},
"remove-multiple-spaces": {
"enabled": true
},
"strong-style": {
"enabled": true,
"style": "asterisk"
},
"two-spaces-between-lines-with-content": {
"enabled": true,
"line-break-indicator": " "
},
"unordered-list-style": {
"enabled": true,
"list-style": "-"
},
"compact-yaml": {
"enabled": false,
"inner-new-lines": false
},
"consecutive-blank-lines": {
"enabled": false
},
"convert-spaces-to-tabs": {
"enabled": false,
"tabsize": 4
},
"empty-line-around-blockquotes": {
"enabled": true
},
"empty-line-around-code-fences": {
"enabled": true
},
"empty-line-around-horizontal-rules": {
"enabled": true
},
"empty-line-around-math-blocks": {
"enabled": true
},
"empty-line-around-tables": {
"enabled": true
},
"heading-blank-lines": {
"enabled": true,
"bottom": true,
"empty-line-after-yaml": true
},
"line-break-at-document-end": {
"enabled": true
},
"move-math-block-indicators-to-their-own-line": {
"enabled": false
},
"paragraph-blank-lines": {
"enabled": false
},
"remove-empty-lines-between-list-markers-and-checklists": {
"enabled": false
},
"remove-link-spacing": {
"enabled": false
},
"remove-space-around-characters": {
"enabled": false,
"include-fullwidth-forms": true,
"include-cjk-symbols-and-punctuation": true,
"include-dashes": true,
"other-symbols": ""
},
"remove-space-before-or-after-characters": {
"enabled": false,
"characters-to-remove-space-before": ",!?;:).’”]",
"characters-to-remove-space-after": "¿¡‘“(["
},
"space-after-list-markers": {
"enabled": false
},
"space-between-chinese-japanese-or-korean-and-english-or-numbers": {
"enabled": false,
"english-symbols-punctuation-before": "-+;:'\"°%$)]",
"english-symbols-punctuation-after": "-+'\"([¥$"
},
"trailing-spaces": {
"enabled": false,
"twp-space-line-break": false
},
"add-blockquote-indentation-on-paste": {
"enabled": false
},
"prevent-double-checklist-indicator-on-paste": {
"enabled": false
},
"prevent-double-list-item-indicator-on-paste": {
"enabled": false
},
"proper-ellipsis-on-paste": {
"enabled": false
},
"remove-hyphens-on-paste": {
"enabled": false
},
"remove-leading-or-trailing-whitespace-on-paste": {
"enabled": false
},
"remove-leftover-footnotes-from-quote-on-paste": {
"enabled": false
},
"remove-multiple-blank-lines-on-paste": {
"enabled": false
}
},
"lintOnSave": true,
"recordLintOnSaveLogs": false,
"displayChanged": true,
"lintOnFileChange": false,
"displayLintOnFileChangeNotice": false,
"settingsConvertedToConfigKeyValues": true,
"foldersToIgnore": [],
"filesToIgnore": [],
"linterLocale": "system-default",
"logLevel": "ERROR",
"lintCommands": [],
"customRegexes": [],
"commonStyles": {
"aliasArrayStyle": "single-line",
"tagArrayStyle": "single-line",
"minimumNumberOfDollarSignsToBeAMathBlock": 2,
"escapeCharacter": "\"",
"removeUnnecessaryEscapeCharsForMultiLineArrays": false
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
{
"id": "obsidian-linter",
"name": "Linter",
"version": "1.28.0",
"minAppVersion": "1.5.7",
"description": "Formats and styles your notes. It can be used to format YAML tags, aliases, arrays, and metadata; footnotes; headings; spacing; math blocks; regular markdown contents like list, italics, and bold styles; and more with the use of custom rule options as well.",
"author": "Victor Tao",
"authorUrl": "https://github.com/platers",
"helpUrl": "https://platers.github.io/obsidian-linter/",
"isDesktopOnly": false
}

View File

@@ -0,0 +1 @@
.linter-navigation-item{align-items:center;background-color:var(--background-primary-secondary-alt);border:1px solid var(--background-modifier-border);border-radius:100px;border-radius:8px 8px 2px 2px;cursor:pointer;display:flex;flex-direction:row;font-size:16px;font-weight:700;gap:4px;height:32px;overflow:hidden;padding:4px 6px;transition:color .25s ease-in-out,padding .25s ease-in-out,background-color .35s cubic-bezier(.45,.25,.83,.67),max-width .35s cubic-bezier(.57,.04,.58,1);white-space:nowrap}@media screen and (max-width:1325px){.linter-navigation-item.linter-desktop{max-width:32px}}@media screen and (max-width:800px){.linter-navigation-item.linter-mobile{max-width:32px}}.linter-navigation-item-icon,.linter-warning{padding-top:5px}.linter-navigation-item:hover{border-color:var(--interactive-accent-hover);border-bottom:0}.linter-navigation-item-selected{background-color:var(--interactive-accent)!important;border:1px solid var(--background-modifier-border);border-bottom:0;border-radius:8px 8px 2px 2px;color:var(--text-on-accent);max-width:100%!important;padding:4px 9px!important;transition:color .25s ease-in-out,padding .25s ease-in-out,background-color .35s cubic-bezier(.45,.25,.83,.67),max-width .45s cubic-bezier(.57,.04,.58,1) .2s}.linter{transition:transform .4s 0s}.linter-setting-title{align-items:baseline;display:flex;gap:30px;justify-content:space-between}.linter-setting-title.linter-mobile{justify-content:space-around}.linter-setting-title h1{font-weight:900;margin-bottom:12px;margin-top:6px}.linter-setting-header{margin-bottom:24px;overflow-x:auto;overflow-y:hidden}.linter-setting-header .linter-setting-tab-group{align-items:flex-end;display:flex;flex-wrap:wrap;width:100%}.linter-setting-tab-group{border-bottom:2px solid var(--background-modifier-border);margin-top:6px;padding-left:2px;padding-right:2px}.linter-setting-header .linter-tab-settings{border-left:2px solid transparent;border-right:2px solid transparent;cursor:pointer;font-weight:600;padding:6px 12px;white-space:nowrap}.linter-setting-header .linter-tab-settings:first-child{margin-left:6px}.linter-setting-header .linter-tab-settings.linter-tab-settings-active{border:2px solid var(--background-modifier-border);border-bottom-color:var(--background-primary);border-radius:2px;transform:translateY(2px)}.linter-navigation-item:not(.linter-navigation-item-selected)>span:nth-child(2),.linter-visually-hidden{border:0;clip:rect(0 0 0 0);clip-path:rect(0 0 0 0);height:auto;margin:0;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}textarea.full-width{margin-bottom:.8em;margin-top:.8em;min-height:10em;width:100%}.full-width-textbox-input-wrapper{position:relative}.settings-copy-button{margin:0 0 0 auto;padding:4px;position:absolute;right:.8em;top:.8em}.settings-copy-button svg.linter-clipboard path{fill:var(--text-faint)}.settings-copy-button svg.linter-success path{fill:var(--interactive-success)}.settings-copy-button:active,.settings-copy-button:hover{cursor:pointer}.settings-copy-button:active svg path,.settings-copy-button:hover svg path{fill:var(--text-accent-hover);transition:all .3s ease}.settings-copy-button:focus{outline:0}.linter-custom-regex-replacement-container div:last-child{border:none}.linter-custom-regex-replacement{border:none;border-bottom:var(--hr-thickness) solid;border-color:var(--hr-color);margin-bottom:15px}.linter-custom-regex-replacement-row2{flex-wrap:wrap}.linter-custom-regex-replacement-normal-input{width:40%}.linter-custom-regex-replacement-flags{width:15%}.linter-custom-regex-replacement-label{flex-direction:row-reverse}.linter-custom-regex-replacement-label-input{width:50%}.linter-files-to-ignore-container div:last-child{border:none}.linter-files-to-ignore{border:none;border-bottom:var(--hr-thickness) solid;border-color:var(--hr-color);margin-bottom:15px}.linter-files-to-ignore-normal-input{width:40%}.linter-files-to-ignore-flags{width:15%}.linter-no-border{border:none}.linter-border-bottom{border-bottom:1px solid var(--background-modifier-border);border-top:0;margin-bottom:.75em}.linter-no-padding-top{padding-top:0}.custom-row-description{margin-top:0}.modal-warn,.search-zero-state{font-weight:700}.modal-heading,.search-zero-state{text-align:center}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
{
"id": "obsidian-local-images-plus",
"name": "Local Images Plus",
"version": "0.16.3",
"minAppVersion": "1.0.3",
"description": "Local Images Plus plugin searches for all external media links in your notes, downloads and saves them locally and adjusts the links in your notes to point to the saved files.",
"author": "catalysm, aleksey-rezvov, Sergei Korneev",
"authorUrl": "https://github.com/Sergei-Korneev/obsidian-local-images-plus",
"fundingUrl": "https://www.buymeacoffee.com/sergeikorneev",
"isDesktopOnly": true
}

View File

@@ -0,0 +1,14 @@
/* This file was created to satisfy requirements for Obsidian's plugins */
.title_txt{
color:white;
align:center;
}
.donheader_txt{
text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
font-weight: 600;
color:red;
align:center;
}

View File

@@ -0,0 +1,6 @@
{
"formatType": "normal",
"showRibbonIcon": true,
"bindEnter": true,
"bindTab": true
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,17 @@
{
"id": "table-editor-obsidian",
"name": "Advanced Tables",
"author": "Tony Grosinger",
"authorUrl": "https://grosinger.net",
"description": "Improved table navigation, formatting, manipulation, and formulas",
"isDesktopOnly": false,
"minAppVersion": "1.0.0",
"version": "0.22.1",
"js": "main.js",
"fundingUrl": {
"Github Sponsor": "https://github.com/sponsors/tgrosinger",
"Buy me a Coffee": "https://buymeacoffee.com/tgrosinger",
"Paypal": "https://paypal.me/tgrosinger"
},
"donation": "https://buymeacoffee.com/tgrosinger"
}

View File

@@ -0,0 +1,78 @@
:root {
--advanced-tables-helper-size: 28px;
}
.HyperMD-table-row span.cm-inline-code {
font-size: 100%;
padding: 0px;
}
.advanced-tables-buttons>div>.title {
font-weight: var(--font-medium);
font-size: var(--nav-item-size);
color: var(--nav-item-color);
text-decoration: underline;
}
[data-type="advanced-tables-toolbar"] .nav-buttons-container {
column-gap: 0.2rem;
margin: 0.2rem 0 0.2rem 0;
justify-content: start;
}
[data-type="advanced-tables-toolbar"] .nav-buttons-container::before {
min-width: 2.6rem;
line-height: var(--advanced-tables-helper-size);
font-size: var(--nav-item-size);
font-weight: var(--nav-item-weight);
color: var(--nav-item-color);
}
[data-type="advanced-tables-toolbar"] .nav-buttons-container>* {
height: var(--advanced-tables-helper-size);
line-height: var(--advanced-tables-helper-size);
}
[data-type="advanced-tables-toolbar"] .nav-buttons-container .nav-action-button {
width: var(--advanced-tables-helper-size);
height: var(--advanced-tables-helper-size);
display: flex;
justify-content: center;
align-items: center;
border-radius: var(--radius-s);
}
[data-type="advanced-tables-toolbar"] .nav-buttons-container .nav-action-button:hover {
background-color: var(--nav-item-background-hover);
color: var(--nav-item-color-hover);
font-weight: var(--nav-item-weight-hover);
}
.advanced-tables-row-label {
width: 50px;
}
.widget-icon {
width: 20px;
height: 20px;
fill: var(--text-muted);
}
.widget-icon:hover {
fill: var(--text-normal);
}
.advanced-tables-csv-export textarea {
height: 200px;
width: 100%;
}
.advanced-tables-donation {
width: 70%;
margin: 0 auto;
text-align: center;
}
.advanced-tables-donate-button {
margin: 10px;
}

View File

@@ -0,0 +1,7 @@
{
"name": "Adwaita",
"version": "0.5.0",
"minAppVersion": "1.0.0",
"author": "@birneee",
"authorUrl": "https://github.com/birneee"
}

View File

@@ -0,0 +1,744 @@
/* This file is generated; DO NOT EDIT. */
/* @settings
name: Adwaita
id: com-github-birneee-obsidian-adwaita
settings:
-
title: Window Buttons
description: Style of minimize, maximize and close window buttons
type: heading
level: 2
collapsed: false
-
id: adwaita-mod
title: Enable
description: Whether to use the Adwaita style window buttons
type: class-select
default: adwaita-mod-linux-only
allowEmpty: false
options:
-
label: Always
value: adwaita-mod-always
-
label: Linux Only
value: adwaita-mod-linux-only
-
label: Never
value: adwaita-mod-never
-
id: adwaita-mod-scale
title: Scale
description:
type: variable-number
default: 1
-
id: adwaita-mod-right-margin
title: Right Margin
type: variable-number
default: 8
format: px
-
id: adwaita-window-button-minimize-hide
title: Hide minimize button
type: class-toggle
-
id: adwaita-window-button-maximize-hide
title: Hide maximize button
type: class-toggle
-
id: adwaita-window-button-close-hide
title: Hide close button
type: class-toggle
-
title: Tabs
type: heading
level: 2
collapsed: false
-
id: adwaita-tabs
title: Enable
description: Whether to use the Adwaita style tabs
type: class-select
default: adwaita-tabs-linux-only
allowEmpty: false
options:
-
label: Always
value: adwaita-tabs-always
-
label: Linux Only
value: adwaita-tabs-linux-only
-
label: Never
value: adwaita-tabs-never
-
id: adwaita-tabs-short
title: Short
type: class-toggle
-
title: Colors
type: heading
level: 2
collapsed: false
-
id: adwaita-colors
title: Enable
description: Whether to use the Adwaita colors
type: class-select
default: adwaita-colors-linux-only
allowEmpty: false
options:
-
label: Always
value: adwaita-colors-always
-
label: Linux Only
value: adwaita-colors-linux-only
-
label: Never
value: adwaita-colors-never
-
title: Font
type: heading
level: 2
collapsed: false
-
id: adwaita-font
title: Enable
description: Whether to use the Cantarell font (must be installed on system)
type: class-select
default: adwaita-font-linux-only
allowEmpty: false
options:
-
label: Always
value: adwaita-font-always
-
label: Linux Only
value: adwaita-font-linux-only
-
label: Never
value: adwaita-font-never
-
title: Icons
type: heading
level: 2
collapsed: false
-
id: adwaita-icon
title: Enable
description: Whether to use the Adwaita icons
type: class-select
default: adwaita-icons-linux-only
allowEmpty: false
options:
-
label: Always
value: adwaita-icons-always
-
label: Linux Only
value: adwaita-icons-linux-only
-
label: Never
value: adwaita-icons-never
*/
:root {
--adwaita-mod-scale: 1;
--adwaita-mod-right-margin: 8px;
/* TODO window radius */ }
:root {
--adwaita-icon-folder-saved-search-symbolic: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8cGF0aCBkPSJtIDYuNjA1NDY5IDAuMDU4NTkzOCBjIC0zLjU3ODEyNSAwIC02LjUgMi45MjE4NzUyIC02LjUgNi41MDAwMDAyIHMgMi45MjE4NzUgNi40OTYwOTQgNi41IDYuNDk2MDk0IGMgMS40Mjk2ODcgMCAyLjc1MzkwNiAtMC40NjQ4NDQgMy44MjgxMjUgLTEuMjUzOTA3IGwgMi45NzI2NTYgMi45NzI2NTcgYyAwLjk1NzAzMSAwLjk0MTQwNiAyLjM2MzI4MSAtMC40OTYwOTQgMS40MDYyNSAtMS40Mzc1IGwgLTIuOTU3MDMxIC0yLjk1NzAzMiBjIDAuNzgxMjUgLTEuMDc0MjE4IDEuMjUgLTIuMzk0NTMxIDEuMjUgLTMuODIwMzEyIGMgMCAtMy41NzgxMjUgLTIuOTI1NzgxIC02LjUwMDAwMDIgLTYuNSAtNi41MDAwMDAyIHogbSAwIDIuMDAwMDAwMiBjIDIuNDk2MDkzIDAgNC41IDIuMDAzOTA2IDQuNSA0LjUgcyAtMi4wMDM5MDcgNC40OTYwOTQgLTQuNSA0LjQ5NjA5NCBjIC0yLjUgMCAtNC41IC0yIC00LjUgLTQuNDk2MDk0IHMgMiAtNC41IDQuNSAtNC41IHogbSAwIDAiIGZpbGw9IiMyZTM0MzYiLz4KPC9zdmc+Cg==");
--adwaita-icon-folder-visiting-symbolic: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8cGF0aCBkPSJtIDMgMSBjIC0xLjY0NDUzMSAwIC0zIDEuMzU1NDY5IC0zIDMgdiA4IGMgMCAxLjY0NDUzMSAxLjM1NTQ2OSAzIDMgMyBoIDEwIGMgMS42NDQ1MzEgMCAzIC0xLjM1NTQ2OSAzIC0zIHYgLTYgYyAwIC0xLjY0NDUzMSAtMS4zNTU0NjkgLTMgLTMgLTMgaCAtMy41ODU5MzggbCAtMS43MDcwMzEgLTEuNzA3MDMxIGMgLTAuMTg3NSAtMC4xODc1IC0wLjQ0MTQwNiAtMC4yOTI5NjkgLTAuNzA3MDMxIC0wLjI5Mjk2OSB6IG0gMCAyIGggMy41ODU5MzggbCAxLjcwNzAzMSAxLjcwNzAzMSBjIDAuMTg3NSAwLjE4NzUgMC40NDE0MDYgMC4yOTI5NjkgMC43MDcwMzEgMC4yOTI5NjkgaCA0IGMgMC41NjI1IDAgMSAwLjQzNzUgMSAxIHYgNiBjIDAgMC41NjY0MDYgLTAuNDM3NSAxIC0xIDEgaCAtMTAgYyAtMC41NjI1IDAgLTEgLTAuNDMzNTk0IC0xIC0xIHYgLTggYyAwIC0wLjU2MjUgMC40Mzc1IC0xIDEgLTEgeiBtIDAgMCIgZmlsbD0iIzJlMzQzNiIvPgo8L3N2Zz4K");
--adwaita-icon-go-down-symbolic: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8cGF0aCBkPSJtIDEgNSBjIDAgLTAuMjY1NjI1IDAuMTA1NDY5IC0wLjUxOTUzMSAwLjI5Mjk2OSAtMC43MDcwMzEgYyAwLjM5MDYyNSAtMC4zOTA2MjUgMS4wMjM0MzcgLTAuMzkwNjI1IDEuNDE0MDYyIDAgbCA1LjI5Mjk2OSA1LjI5Mjk2OSBsIDUuMjkyOTY5IC01LjI5Mjk2OSBjIDAuMzkwNjI1IC0wLjM5MDYyNSAxLjAyMzQzNyAtMC4zOTA2MjUgMS40MTQwNjIgMCBjIDAuMTg3NSAwLjE4NzUgMC4yOTI5NjkgMC40NDE0MDYgMC4yOTI5NjkgMC43MDcwMzEgcyAtMC4xMDU0NjkgMC41MTk1MzEgLTAuMjkyOTY5IDAuNzA3MDMxIGwgLTYgNiBjIC0wLjM5MDYyNSAwLjM5MDYyNSAtMS4wMjM0MzcgMC4zOTA2MjUgLTEuNDE0MDYyIDAgbCAtNiAtNiBjIC0wLjE4NzUgLTAuMTg3NSAtMC4yOTI5NjkgLTAuNDQxNDA2IC0wLjI5Mjk2OSAtMC43MDcwMzEgeiBtIDAgMCIgZmlsbD0iIzJlMzQzNiIvPgo8L3N2Zz4K");
--adwaita-icon-sidebar-show-right-symbolic: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8ZyBmaWxsPSIjMmUzNDM2Ij4KICAgICAgICA8cGF0aCBkPSJtIDkuNSAxNCB2IC0xMiBoIDUgdiAxMiB6IG0gMCAwIiBmaWxsLW9wYWNpdHk9IjAuMzQ5MDIiLz4KICAgICAgICA8cGF0aCBkPSJtIDEzIDEgYyAxLjY0NDUzMSAwIDMgMS4zNTU0NjkgMyAzIHYgOCBjIDAgMS42NDQ1MzEgLTEuMzU1NDY5IDMgLTMgMyBoIC0xMCBjIC0xLjY0NDUzMSAwIC0zIC0xLjM1NTQ2OSAtMyAtMyB2IC04IGMgMCAtMS42NDQ1MzEgMS4zNTU0NjkgLTMgMyAtMyB6IG0gMCAyIGggLTEwIGMgLTAuNTcwMzEyIDAgLTEgMC40Mjk2ODggLTEgMSB2IDggYyAwIDAuNTcwMzEyIDAuNDI5Njg4IDEgMSAxIGggMTAgYyAwLjU3MDMxMiAwIDEgLTAuNDI5Njg4IDEgLTEgdiAtOCBjIDAgLTAuNTcwMzEyIC0wLjQyOTY4OCAtMSAtMSAtMSB6IG0gMCAwIi8+CiAgICAgICAgPHBhdGggZD0ibSAxMCAyIGggLTEgdiAxMiBoIDEgeiBtIDAgMCIvPgogICAgPC9nPgo8L3N2Zz4K");
--adwaita-icon-sidebar-show-symbolic: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8ZyBmaWxsPSIjMmUzNDM2Ij4KICAgICAgICA8cGF0aCBkPSJtIDYuNSAxNCB2IC0xMiBoIC01IHYgMTIgeiBtIDAgMCIgZmlsbC1vcGFjaXR5PSIwLjM0OTAyIi8+CiAgICAgICAgPHBhdGggZD0ibSAzIDEgYyAtMS42NDQ1MzEgMCAtMyAxLjM1NTQ2OSAtMyAzIHYgOCBjIDAgMS42NDQ1MzEgMS4zNTU0NjkgMyAzIDMgaCAxMCBjIDEuNjQ0NTMxIDAgMyAtMS4zNTU0NjkgMyAtMyB2IC04IGMgMCAtMS42NDQ1MzEgLTEuMzU1NDY5IC0zIC0zIC0zIHogbSAwIDIgaCAxMCBjIDAuNTcwMzEyIDAgMSAwLjQyOTY4OCAxIDEgdiA4IGMgMCAwLjU3MDMxMiAtMC40Mjk2ODggMSAtMSAxIGggLTEwIGMgLTAuNTcwMzEyIDAgLTEgLTAuNDI5Njg4IC0xIC0xIHYgLTggYyAwIC0wLjU3MDMxMiAwLjQyOTY4OCAtMSAxIC0xIHogbSAwIDAiLz4KICAgICAgICA8cGF0aCBkPSJtIDYgMiBoIDEgdiAxMiBoIC0xIHogbSAwIDAiLz4KICAgIDwvZz4KPC9zdmc+Cg==");
--adwaita-icon-tab-new-symbolic: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8ZyBmaWxsPSIjMmUzNDM2Ij4KICAgICAgICA8cGF0aCBkPSJtIDMgMCBjIC0xLjY0NDUzMSAwIC0zIDEuMzU1NDY5IC0zIDMgdiAxMCBjIDAgMS42NDQ1MzEgMS4zNTU0NjkgMyAzIDMgaCAxMCBjIDEuNjQ0NTMxIDAgMyAtMS4zNTU0NjkgMyAtMyB2IC0xMCBjIDAgLTEuNjQ0NTMxIC0xLjM1NTQ2OSAtMyAtMyAtMyB6IG0gMCAyIGggMTAgYyAwLjU3MDMxMiAwIDEgMC40Mjk2ODggMSAxIHYgMTAgYyAwIDAuNTcwMzEyIC0wLjQyOTY4OCAxIC0xIDEgaCAtMTAgYyAtMC41NzAzMTIgMCAtMSAtMC40Mjk2ODggLTEgLTEgdiAtMTAgYyAwIC0wLjU3MDMxMiAwLjQyOTY4OCAtMSAxIC0xIHogbSAwIDAiLz4KICAgICAgICA8cGF0aCBkPSJtIDQgNyBoIDggdiAyIGggLTggeiBtIDAgMCIvPgogICAgICAgIDxwYXRoIGQ9Im0gOSA0IHYgOCBoIC0yIHYgLTggeiBtIDAgMCIvPgogICAgPC9nPgo8L3N2Zz4K");
--adwaita-icon-view-more-symbolic: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8cGF0aCBkPSJtIDcuOTk2MDk0IDAgYyAtMS4xMDU0NjkgMCAtMiAwLjg5NDUzMSAtMiAyIHMgMC44OTQ1MzEgMiAyIDIgYyAxLjEwMTU2MiAwIDIgLTAuODk0NTMxIDIgLTIgcyAtMC44OTg0MzggLTIgLTIgLTIgeiBtIDAgNiBjIC0xLjEwNTQ2OSAwIC0yIDAuODk0NTMxIC0yIDIgcyAwLjg5NDUzMSAyIDIgMiBjIDEuMTAxNTYyIDAgMiAtMC44OTQ1MzEgMiAtMiBzIC0wLjg5ODQzOCAtMiAtMiAtMiB6IG0gMCA2IGMgLTEuMTA1NDY5IDAgLTIgMC44OTQ1MzEgLTIgMiBzIDAuODk0NTMxIDIgMiAyIGMgMS4xMDE1NjIgMCAyIC0wLjg5NDUzMSAyIC0yIHMgLTAuODk4NDM4IC0yIC0yIC0yIHogbSAwIDAiIGZpbGw9IiMyZTM0MzYiLz4KPC9zdmc+Cg==");
--adwaita-icon-window-close-symbolic: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8cGF0aCBkPSJtIDQgNCBoIDEgaCAwLjAzMTI1IGMgMC4yNTM5MDYgMC4wMTE3MTkgMC41MTE3MTkgMC4xMjg5MDYgMC42ODc1IDAuMzEyNSBsIDIuMjgxMjUgMi4yODEyNSBsIDIuMzEyNSAtMi4yODEyNSBjIDAuMjY1NjI1IC0wLjIzMDQ2OSAwLjQ0NTMxMiAtMC4zMDQ2ODggMC42ODc1IC0wLjMxMjUgaCAxIHYgMSBjIDAgMC4yODUxNTYgLTAuMDM1MTU2IDAuNTUwNzgxIC0wLjI1IDAuNzUgbCAtMi4yODEyNSAyLjI4MTI1IGwgMi4yNSAyLjI1IGMgMC4xODc1IDAuMTg3NSAwLjI4MTI1IDAuNDUzMTI1IDAuMjgxMjUgMC43MTg3NSB2IDEgaCAtMSBjIC0wLjI2NTYyNSAwIC0wLjUzMTI1IC0wLjA5Mzc1IC0wLjcxODc1IC0wLjI4MTI1IGwgLTIuMjgxMjUgLTIuMjgxMjUgbCAtMi4yODEyNSAyLjI4MTI1IGMgLTAuMTg3NSAwLjE4NzUgLTAuNDUzMTI1IDAuMjgxMjUgLTAuNzE4NzUgMC4yODEyNSBoIC0xIHYgLTEgYyAwIC0wLjI2NTYyNSAwLjA5Mzc1IC0wLjUzMTI1IDAuMjgxMjUgLTAuNzE4NzUgbCAyLjI4MTI1IC0yLjI1IGwgLTIuMjgxMjUgLTIuMjgxMjUgYyAtMC4yMTA5MzggLTAuMTk1MzEyIC0wLjMwNDY4OCAtMC40Njg3NSAtMC4yODEyNSAtMC43NSB6IG0gMCAwIiBmaWxsPSIjMmUzNDM2Ii8+Cjwvc3ZnPgo=");
--adwaita-icon-window-maximize-symbolic: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8cGF0aCBkPSJtIDMuOTg4MjgxIDMuOTkyMTg4IHYgOC4wMTE3MTggaCA4LjAxMTcxOSB2IC04LjAxMTcxOCB6IG0gMiAyIGggNC4wMTE3MTkgdiA0LjAxMTcxOCBoIC00LjAxMTcxOSB6IG0gMCAwIiBmaWxsPSIjMmUzNDM2Ii8+Cjwvc3ZnPgo=");
--adwaita-icon-window-minimize-symbolic: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2cHgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8cGF0aCBkPSJtIDQgMTAuMDA3ODEyIGggOCB2IDEuOTg4MjgyIGggLTggeiBtIDAgMCIgZmlsbD0iIzJlMzQzNiIvPgo8L3N2Zz4K"); }
body {
--adwaita-blue-1: #99c1f1;
--adwaita-blue-2: #62a0ea;
--adwaita-blue-3: #3584e4;
--adwaita-blue-4: #1c71d8;
--adwaita-blue-5: #1a5fb4;
--adwaita-green-1: #8ff0a4;
--adwaita-green-2: #57e389;
--adwaita-green-3: #33d17a;
--adwaita-green-4: #2ec27e;
--adwaita-green-5: #26a269;
--adwaita-yellow-1: #f9f06b;
--adwaita-yellow-2: #f8e45c;
--adwaita-yellow-3: #f6d32d;
--adwaita-yellow-4: #f5c211;
--adwaita-yellow-5: #e5a50a;
--adwaita-orange-1: #ffbe6f;
--adwaita-orange-2: #ffa348;
--adwaita-orange-3: #ff7800;
--adwaita-orange-4: #e66100;
--adwaita-orange-5: #c64600;
--adwaita-red-1: #f66151;
--adwaita-red-2: #ed333b;
--adwaita-red-3: #e01b24;
--adwaita-red-4: #c01c28;
--adwaita-red-5: #a51d2d;
--adwaita-purple-1: #dc8add;
--adwaita-purple-2: #c061cb;
--adwaita-purple-3: #9141ac;
--adwaita-purple-4: #813d9c;
--adwaita-purple-5: #613583;
--adwaita-brown-2: #b5835a;
--adwaita-brown-1: #cdab8f;
--adwaita-brown-3: #986a44;
--adwaita-brown-4: #865e3c;
--adwaita-brown-5: #63452c;
--adwaita-light-1: #ffffff;
--adwaita-light-2: #f6f5f4;
--adwaita-light-3: #deddda;
--adwaita-light-4: #c0bfbc;
--adwaita-light-5: #9a9996;
--adwaita-dark-1: #77767b;
--adwaita-dark-2: #5e5c64;
--adwaita-dark-3: #3d3846;
--adwaita-dark-4: #241f31;
--adwaita-dark-5: #000000; }
body.theme-dark {
--adwaita-accent-color: #78aeed;
--adwaita-accent-bg-color: #3584e4;
--adwaita-accent-fg-color: #ffffff;
--adwaita-destructive-color: #ff7b63;
--adwaita-destructive-bg-color: #c01c28;
--adwaita-destructive-fg-color: #ffffff;
--adwaita-success-color: #8ff0a4;
--adwaita-success-bg-color: #26a269;
--adwaita-success-fg-color: #ffffff;
--adwaita-warning-color: #f8e45c;
--adwaita-warning-bg-color: #cd9309;
--adwaita-warning-fg-color: rgba(0, 0, 0, 0.8);
--adwaita-error-color: #ff7b63;
--adwaita-error-bg-color: #c01c28;
--adwaita-error-fg-color: #ffffff;
--adwaita-window-bg-color: #242424;
--adwaita-window-fg-color: #ffffff;
--adwaita-view-bg-color: #1e1e1e;
--adwaita-view-fg-color: #ffffff;
--adwaita-headerbar-bg-color: #303030;
--adwaita-headerbar-fg-color: #ffffff;
--adwaita-headerbar-border-color: #ffffff;
--adwaita-headerbar-backdrop-color: #242424;
--adwaita-headerbar-shade-color: rgba(0, 0, 0, 0.36);
--adwaita-card-bg-color: rgba(255, 255, 255, 0.08);
--adwaita-card-fg-color: #ffffff;
--adwaita-card-shade-color: rgba(0, 0, 0, 0.36);
--adwaita-dialog-bg-color: #383838;
--adwaita-dialog-fg-color: #ffffff;
--adwaita-popover-bg-color: #383838;
--adwaita-popover-fg-color: #ffffff;
--adwaita-popover-shader-color: rgba(0, 0, 0, 0.36);
--adwaita-shade-color: rgba(0, 0, 0, 0.36);
--adwaita-scrollbar-outline-color: rgba(0, 0, 0, 0.5); }
body.theme-light {
--adwaita-accent-color: #1c71d8;
--adwaita-accent-bg-color: #3584e4;
--adwaita-accent-fg-color: #ffffff;
--adwaita-destructive-color: #c01c28;
--adwaita-destructive-bg-color: #e01b24;
--adwaita-destructive-fg-color: #ffffff;
--adwaita-success-color: #1b8553;
--adwaita-success-bg-color: #2ec27e;
--adwaita-success-fg-color: #ffffff;
--adwaita-warning-color: #9c6e03;
--adwaita-warning-bg-color: #e5a50a;
--adwaita-warning-fg-color: rgba(0, 0, 0, 0.8);
--adwaita-error-color: #c01c28;
--adwaita-error-bg-color: #e01b24;
--adwaita-error-fg-color: #ffffff;
--adwaita-window-bg-color: #fafafa;
--adwaita-window-fg-color: rgba(0, 0, 0, 0.8);
--adwaita-view-bg-color: #ffffff;
--adwaita-view-fg-color: rgba(0, 0, 0, 0.8);
--adwaita-headerbar-bg-color: #ffffff;
--adwaita-headerbar-fg-color: rgba(0, 0, 0, 0.8);
--adwaita-headerbar-border-color: rgba(0, 0, 0, 0.8);
--adwaita-headerbar-backdrop-color: #fafafa;
--adwaita-headerbar-shade-color: rgba(0, 0, 0, 0.12);
--adwaita-card-bg-color: #ffffff;
--adwaita-card-fg-color: rgba(0, 0, 0, 0.8);
--adwaita-card-shade-color: rgba(0, 0, 0, 0.07);
--adwaita-dialog-bg-color: #ffffff;
--adwaita-dialog-fg-color: rgba(0, 0, 0, 0.8);
--adwaita-popover-bg-color: #fafafa;
--adwaita-popover-fg-color: rgba(0, 0, 0, 0.8);
--adwaita-popover-shader-color: rgba(0, 0, 0, 0.07);
--adwaita-shade-color: rgba(0, 0, 0, 0.07);
--adwaita-scrollbar-outline-color: #ffffff; }
body:not(.adwaita-colors-always, .adwaita-colors-linux-only, .adwaita-colors-never).mod-linux,
body.adwaita-colors-always,
body.adwaita-colors-linux-only.mod-linux {
--titlebar-background: var(--adwaita-headerbar-backdrop-color);
--titlebar-background-focused: var(--adwaita-headerbar-bg-color);
--titlebar-text-color-focused: var(--adwaita-headerbar-fg-color);
--text-normal: var(--adwaita-view-fg-color); }
body:not(.adwaita-colors-always, .adwaita-colors-linux-only, .adwaita-colors-never).mod-linux.is-focused .workspace-tabs.mod-top .workspace-tab-header-container,
body:not(.adwaita-colors-always, .adwaita-colors-linux-only, .adwaita-colors-never).mod-linux.is-focused .sidebar-toggle-button,
body.adwaita-colors-always.is-focused .workspace-tabs.mod-top .workspace-tab-header-container,
body.adwaita-colors-always.is-focused .sidebar-toggle-button,
body.adwaita-colors-linux-only.mod-linux.is-focused .workspace-tabs.mod-top .workspace-tab-header-container,
body.adwaita-colors-linux-only.mod-linux.is-focused .sidebar-toggle-button {
--icon-color: var(--adwaita-headerbar-fg-color);
--icon-color-hover: var(--adwaita-headerbar-fg-color);
--icon-color-focused: var(--adwaita-headerbar-fg-color);
--tab-text-color-focused: var(--adwaita-headerbar-fg-color);
--tab-text-color-focused-active-current: var(--adwaita-headerbar-fg-color); }
body:not(.adwaita-colors-always, .adwaita-colors-linux-only, .adwaita-colors-never).mod-linux.theme-dark,
body.adwaita-colors-always.theme-dark,
body.adwaita-colors-linux-only.mod-linux.theme-dark {
--titlebar-text-color: #919191;
--icon-color: #929292;
--icon-color-hover: #929292;
--icon-color-focused: #929292;
--tab-text-color: #929292;
--tab-text-color-focused: #8a8a8a;
--tab-text-color-focused-active-current: #8a8a8a;
--background-modifier-hover: #323232; }
body:not(.adwaita-colors-always, .adwaita-colors-linux-only, .adwaita-colors-never).mod-linux.theme-dark.is-focused .workspace-tabs.mod-top .workspace-tab-header-container,
body:not(.adwaita-colors-always, .adwaita-colors-linux-only, .adwaita-colors-never).mod-linux.theme-dark.is-focused .sidebar-toggle-button,
body.adwaita-colors-always.theme-dark.is-focused .workspace-tabs.mod-top .workspace-tab-header-container,
body.adwaita-colors-always.theme-dark.is-focused .sidebar-toggle-button,
body.adwaita-colors-linux-only.mod-linux.theme-dark.is-focused .workspace-tabs.mod-top .workspace-tab-header-container,
body.adwaita-colors-linux-only.mod-linux.theme-dark.is-focused .sidebar-toggle-button {
--background-modifier-hover: #464646; }
body:not(.adwaita-colors-always, .adwaita-colors-linux-only, .adwaita-colors-never).mod-linux.theme-light,
body.adwaita-colors-always.theme-light,
body.adwaita-colors-linux-only.mod-linux.theme-light {
--titlebar-text-color: #8c8c8c;
--icon-color: #939393;
--icon-color-hover: #939393;
--icon-color-focused: #939393;
--tab-text-color: #939393;
--tab-text-color-focused: #939393;
--tab-text-color-focused-active-current: #939393;
--background-modifier-hover: #f0f0f0; }
body:not(.adwaita-colors-always, .adwaita-colors-linux-only, .adwaita-colors-never).mod-linux.theme-light.is-focused .workspace-tabs.mod-top .workspace-tab-header-container,
body:not(.adwaita-colors-always, .adwaita-colors-linux-only, .adwaita-colors-never).mod-linux.theme-light.is-focused .sidebar-toggle-button,
body.adwaita-colors-always.theme-light.is-focused .workspace-tabs.mod-top .workspace-tab-header-container,
body.adwaita-colors-always.theme-light.is-focused .sidebar-toggle-button,
body.adwaita-colors-linux-only.mod-linux.theme-light.is-focused .workspace-tabs.mod-top .workspace-tab-header-container,
body.adwaita-colors-linux-only.mod-linux.theme-light.is-focused .sidebar-toggle-button {
--background-modifier-hover: #d8d8d8; }
body:not(.adwaita-colors-always, .adwaita-colors-linux-only, .adwaita-colors-never).mod-linux .titlebar-button.mod-logo:hover,
body.adwaita-colors-always .titlebar-button.mod-logo:hover,
body.adwaita-colors-linux-only.mod-linux .titlebar-button.mod-logo:hover {
background-color: inherit; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux,
body.adwaita-mod-always,
body.adwaita-mod-linux-only.mod-linux {
--frame-right-space: calc(var(--adwaita-mod-scale) * 120px);
--adwaita-mod-foreground-focus: var(--adwaita-headerbar-fg-color); }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.theme-dark,
body.adwaita-mod-always.theme-dark,
body.adwaita-mod-linux-only.mod-linux.theme-dark {
--adwaita-mod-background: #2e2e2e;
--adwaita-mod-background-focus: #444444;
--adwaita-mod-background-hover: #4f4f4f;
--adwaita-mod-background-active: #6e6e6e;
--adwaita-mod-foreground: #929292; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.theme-light,
body.adwaita-mod-always.theme-light,
body.adwaita-mod-linux-only.mod-linux.theme-light {
--adwaita-mod-background: #efefef;
--adwaita-mod-background-focus: #d8d8d8;
--adwaita-mod-background-hover: #cfcfcf;
--adwaita-mod-background-active: #b3b3b3;
--adwaita-mod-foreground: #949494; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.adwaita-window-button-minimize-hide .titlebar-button-container.mod-right .titlebar-button.mod-minimize,
body.adwaita-mod-always.adwaita-window-button-minimize-hide .titlebar-button-container.mod-right .titlebar-button.mod-minimize,
body.adwaita-mod-linux-only.mod-linux.adwaita-window-button-minimize-hide .titlebar-button-container.mod-right .titlebar-button.mod-minimize {
display: none; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.adwaita-window-button-maximize-hide .titlebar-button-container.mod-right .titlebar-button.mod-maximize,
body.adwaita-mod-always.adwaita-window-button-maximize-hide .titlebar-button-container.mod-right .titlebar-button.mod-maximize,
body.adwaita-mod-linux-only.mod-linux.adwaita-window-button-maximize-hide .titlebar-button-container.mod-right .titlebar-button.mod-maximize {
display: none; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.adwaita-window-button-close-hide .titlebar-button-container.mod-right .titlebar-button.mod-close,
body.adwaita-mod-always.adwaita-window-button-close-hide .titlebar-button-container.mod-right .titlebar-button.mod-close,
body.adwaita-mod-linux-only.mod-linux.adwaita-window-button-close-hide .titlebar-button-container.mod-right .titlebar-button.mod-close {
display: none; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.adwaita-window-button-minimize-hide:not(.adwaita-window-button-maximize-hide.adwaita-window-button-close-hide), body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.adwaita-window-button-maximize-hide:not(.adwaita-window-button-close-hide.adwaita-window-button-minimize-hide), body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.adwaita-window-button-close-hide:not(.adwaita-window-button-minimize-hide.adwaita-window-button-maximize-hide),
body.adwaita-mod-always.adwaita-window-button-minimize-hide:not(.adwaita-window-button-maximize-hide.adwaita-window-button-close-hide),
body.adwaita-mod-always.adwaita-window-button-maximize-hide:not(.adwaita-window-button-close-hide.adwaita-window-button-minimize-hide),
body.adwaita-mod-always.adwaita-window-button-close-hide:not(.adwaita-window-button-minimize-hide.adwaita-window-button-maximize-hide),
body.adwaita-mod-linux-only.mod-linux.adwaita-window-button-minimize-hide:not(.adwaita-window-button-maximize-hide.adwaita-window-button-close-hide),
body.adwaita-mod-linux-only.mod-linux.adwaita-window-button-maximize-hide:not(.adwaita-window-button-close-hide.adwaita-window-button-minimize-hide),
body.adwaita-mod-linux-only.mod-linux.adwaita-window-button-close-hide:not(.adwaita-window-button-minimize-hide.adwaita-window-button-maximize-hide) {
--frame-right-space: calc(var(--adwaita-mod-scale) * (120px - 38px)); }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.adwaita-window-button-minimize-hide.adwaita-window-button-maximize-hide:not(.adwaita-window-button-close-hide), body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.adwaita-window-button-maximize-hide.adwaita-window-button-close-hide:not(.adwaita-window-button-minimize-hide), body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.adwaita-window-button-close-hide.adwaita-window-button-minimize-hide:not(.adwaita-window-button-maximize-hide),
body.adwaita-mod-always.adwaita-window-button-minimize-hide.adwaita-window-button-maximize-hide:not(.adwaita-window-button-close-hide),
body.adwaita-mod-always.adwaita-window-button-maximize-hide.adwaita-window-button-close-hide:not(.adwaita-window-button-minimize-hide),
body.adwaita-mod-always.adwaita-window-button-close-hide.adwaita-window-button-minimize-hide:not(.adwaita-window-button-maximize-hide),
body.adwaita-mod-linux-only.mod-linux.adwaita-window-button-minimize-hide.adwaita-window-button-maximize-hide:not(.adwaita-window-button-close-hide),
body.adwaita-mod-linux-only.mod-linux.adwaita-window-button-maximize-hide.adwaita-window-button-close-hide:not(.adwaita-window-button-minimize-hide),
body.adwaita-mod-linux-only.mod-linux.adwaita-window-button-close-hide.adwaita-window-button-minimize-hide:not(.adwaita-window-button-maximize-hide) {
--frame-right-space: calc(var(--adwaita-mod-scale) * (120px - 38px - 38px)); }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.adwaita-window-button-minimize-hide.adwaita-window-button-maximize-hide.adwaita-window-button-close-hide,
body.adwaita-mod-always.adwaita-window-button-minimize-hide.adwaita-window-button-maximize-hide.adwaita-window-button-close-hide,
body.adwaita-mod-linux-only.mod-linux.adwaita-window-button-minimize-hide.adwaita-window-button-maximize-hide.adwaita-window-button-close-hide {
--frame-right-space: calc(var(--adwaita-mod-scale) * (120px - 38px - 38px - 38px)); }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right,
body.adwaita-mod-always .titlebar-button-container.mod-right,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right {
transform: scale(var(--adwaita-mod-scale));
margin-right: var(--adwaita-mod-right-margin);
transform-origin: right; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right .titlebar-button,
body.adwaita-mod-always .titlebar-button-container.mod-right .titlebar-button,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right .titlebar-button {
height: 24px;
width: 24px;
border-radius: 12px;
padding: 0;
margin: auto 0 auto 14px;
background: var(--adwaita-mod-background);
color: var(--adwaita-mod-foreground); }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-minimize svg, body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-maximize svg, body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-close svg,
body.adwaita-mod-always .titlebar-button-container.mod-right .titlebar-button.mod-minimize svg,
body.adwaita-mod-always .titlebar-button-container.mod-right .titlebar-button.mod-maximize svg,
body.adwaita-mod-always .titlebar-button-container.mod-right .titlebar-button.mod-close svg,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-minimize svg,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-maximize svg,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-close svg {
display: none; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right .titlebar-button::after,
body.adwaita-mod-always .titlebar-button-container.mod-right .titlebar-button::after,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right .titlebar-button::after {
content: '';
background-color: currentColor;
width: 16px;
height: 16px;
margin: auto; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-minimize::after,
body.adwaita-mod-always .titlebar-button-container.mod-right .titlebar-button.mod-minimize::after,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-minimize::after {
-webkit-mask-image: var(--adwaita-icon-window-minimize-symbolic);
mask-image: var(--adwaita-icon-window-minimize-symbolic); }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-maximize::after,
body.adwaita-mod-always .titlebar-button-container.mod-right .titlebar-button.mod-maximize::after,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-maximize::after {
-webkit-mask-image: var(--adwaita-icon-window-maximize-symbolic);
mask-image: var(--adwaita-icon-window-maximize-symbolic); }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-close::after,
body.adwaita-mod-always .titlebar-button-container.mod-right .titlebar-button.mod-close::after,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right .titlebar-button.mod-close::after {
-webkit-mask-image: var(--adwaita-icon-window-close-symbolic);
mask-image: var(--adwaita-icon-window-close-symbolic); }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right .titlebar-button:hover,
body.adwaita-mod-always .titlebar-button-container.mod-right .titlebar-button:hover,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right .titlebar-button:hover {
background: var(--adwaita-mod-background) !important; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .titlebar-button-container.mod-right .titlebar-button svg,
body.adwaita-mod-always .titlebar-button-container.mod-right .titlebar-button svg,
body.adwaita-mod-linux-only.mod-linux .titlebar-button-container.mod-right .titlebar-button svg {
width: 12px;
height: 12px;
margin: auto; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.is-focused .titlebar-button-container.mod-right .titlebar-button,
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.is-focused .modal-close-button,
body.adwaita-mod-always.is-focused .titlebar-button-container.mod-right .titlebar-button,
body.adwaita-mod-always.is-focused .modal-close-button,
body.adwaita-mod-linux-only.mod-linux.is-focused .titlebar-button-container.mod-right .titlebar-button,
body.adwaita-mod-linux-only.mod-linux.is-focused .modal-close-button {
background: var(--adwaita-mod-background-focus);
color: var(--adwaita-mod-foreground-focus); }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.is-focused .titlebar-button-container.mod-right .titlebar-button:hover,
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.is-focused .modal-close-button:hover,
body.adwaita-mod-always.is-focused .titlebar-button-container.mod-right .titlebar-button:hover,
body.adwaita-mod-always.is-focused .modal-close-button:hover,
body.adwaita-mod-linux-only.mod-linux.is-focused .titlebar-button-container.mod-right .titlebar-button:hover,
body.adwaita-mod-linux-only.mod-linux.is-focused .modal-close-button:hover {
background: var(--adwaita-mod-background-hover) !important; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.is-focused .titlebar-button-container.mod-right .titlebar-button:active,
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux.is-focused .modal-close-button:active,
body.adwaita-mod-always.is-focused .titlebar-button-container.mod-right .titlebar-button:active,
body.adwaita-mod-always.is-focused .modal-close-button:active,
body.adwaita-mod-linux-only.mod-linux.is-focused .titlebar-button-container.mod-right .titlebar-button:active,
body.adwaita-mod-linux-only.mod-linux.is-focused .modal-close-button:active {
background: var(--adwaita-mod-background-active) !important; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .modal-close-button,
body.adwaita-mod-always .modal-close-button,
body.adwaita-mod-linux-only.mod-linux .modal-close-button {
height: 24px;
width: 24px;
border-radius: 12px;
color: var(--adwaita-mod-foreground);
background: var(--adwaita-mod-background);
transform: scale(var(--adwaita-mod-scale));
transform-origin: right; }
body:not(.adwaita-mod-always, .adwaita-mod-linux-only, .adwaita-mod-never).mod-linux .modal-close-button:before,
body.adwaita-mod-always .modal-close-button:before,
body.adwaita-mod-linux-only.mod-linux .modal-close-button:before {
content: '';
display: block;
width: 16px;
height: 16px;
margin: auto;
top: 50%;
position: absolute;
transform: translateY(-50%);
-webkit-mask-image: var(--adwaita-icon-window-close-symbolic);
mask-image: var(--adwaita-icon-window-close-symbolic);
background-color: currentColor; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux,
body.adwaita-tabs-always,
body.adwaita-tabs-linux-only.mod-linux {
--tab-radius-active: 4px; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux:not(.adwaita-tabs-short),
body.adwaita-tabs-always:not(.adwaita-tabs-short),
body.adwaita-tabs-linux-only.mod-linux:not(.adwaita-tabs-short) {
--tab-width: 10000px;
/* infinite width */
--tab-max-width: none; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux.theme-dark,
body.adwaita-tabs-always.theme-dark,
body.adwaita-tabs-linux-only.mod-linux.theme-dark {
--tab-background-active: #323232; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux.theme-dark.is-focused,
body.adwaita-tabs-always.theme-dark.is-focused,
body.adwaita-tabs-linux-only.mod-linux.theme-dark.is-focused {
--tab-background-active: #464646; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux.theme-light,
body.adwaita-tabs-always.theme-light,
body.adwaita-tabs-linux-only.mod-linux.theme-light {
--tab-background-active: #f0f0f0; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux.theme-light.is-focused,
body.adwaita-tabs-always.theme-light.is-focused,
body.adwaita-tabs-linux-only.mod-linux.theme-light.is-focused {
--tab-background-active: #d8d8d8; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .workspace-tab-header-container .workspace-tab-header-container-inner,
body.adwaita-tabs-always .workspace-tab-header-container .workspace-tab-header-container-inner,
body.adwaita-tabs-linux-only.mod-linux .workspace-tab-header-container .workspace-tab-header-container-inner {
--tab-outline-width: 0; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .workspace-tab-header-container .workspace-tab-header-new-tab,
body.adwaita-tabs-always .workspace-tab-header-container .workspace-tab-header-new-tab,
body.adwaita-tabs-linux-only.mod-linux .workspace-tab-header-container .workspace-tab-header-new-tab {
margin-right: var(--size-4-1); }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .workspace-tab-header-new-tab,
body.adwaita-tabs-always .workspace-tab-header-new-tab,
body.adwaita-tabs-linux-only.mod-linux .workspace-tab-header-new-tab {
order: 1; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .workspace-tab-header-tab-list,
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .sidebar-toggle-button.mod-right,
body.adwaita-tabs-always .workspace-tab-header-tab-list,
body.adwaita-tabs-always .sidebar-toggle-button.mod-right,
body.adwaita-tabs-linux-only.mod-linux .workspace-tab-header-tab-list,
body.adwaita-tabs-linux-only.mod-linux .sidebar-toggle-button.mod-right {
order: 2; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header,
body.adwaita-tabs-always .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header,
body.adwaita-tabs-linux-only.mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header {
padding: 0;
margin: 5px 3px 5px 2px; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header.is-active,
body.adwaita-tabs-always .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header.is-active,
body.adwaita-tabs-linux-only.mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header.is-active {
color: var(--tab-text-color-focused); }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header:before, body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header:after,
body.adwaita-tabs-always .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header:before,
body.adwaita-tabs-always .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header:after,
body.adwaita-tabs-linux-only.mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header:before,
body.adwaita-tabs-linux-only.mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header:after {
content: none; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header .workspace-tab-header-inner::after,
body.adwaita-tabs-always .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header .workspace-tab-header-inner::after,
body.adwaita-tabs-linux-only.mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header .workspace-tab-header-inner::after {
right: -6px; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header .workspace-tab-header-inner-title,
body.adwaita-tabs-always .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header .workspace-tab-header-inner-title,
body.adwaita-tabs-linux-only.mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header .workspace-tab-header-inner-title {
padding-left: 20px;
text-align: center; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header:last-child .workspace-tab-header-inner::after,
body.adwaita-tabs-always .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header:last-child .workspace-tab-header-inner::after,
body.adwaita-tabs-linux-only.mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header:last-child .workspace-tab-header-inner::after {
content: none; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header .workspace-tab-header-inner-close-button,
body.adwaita-tabs-always .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header .workspace-tab-header-inner-close-button,
body.adwaita-tabs-linux-only.mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header .workspace-tab-header-inner-close-button {
opacity: 0;
display: flex; }
body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header.is-active .workspace-tab-header-inner-close-button, body:not(.adwaita-tabs-always, .adwaita-tabs-linux-only, .adwaita-tabs-never).mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header :hover .workspace-tab-header-inner-close-button,
body.adwaita-tabs-always .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header.is-active .workspace-tab-header-inner-close-button,
body.adwaita-tabs-always .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header :hover .workspace-tab-header-inner-close-button,
body.adwaita-tabs-linux-only.mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header.is-active .workspace-tab-header-inner-close-button,
body.adwaita-tabs-linux-only.mod-linux .mod-root .workspace-tabs:not(.mod-stacked) .workspace-tab-header :hover .workspace-tab-header-inner-close-button {
opacity: 1; }
body:not(.adwaita-font-always, .adwaita-font-linux-only, .adwaita-font-never).mod-linux,
body.adwaita-font-always,
body.adwaita-font-linux-only.mod-linux {
--titlebar-height: 45px;
--font-interface-theme: Cantarell;
--font-ui-small: 15px;
--h1-weight: 900; }
body:not(.adwaita-font-always, .adwaita-font-linux-only, .adwaita-font-never).mod-linux .titlebar-text,
body.adwaita-font-always .titlebar-text,
body.adwaita-font-linux-only.mod-linux .titlebar-text {
top: 10px;
height: auto; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux,
body.adwaita-icons-always,
body.adwaita-icons-linux-only.mod-linux {
--titlebar-height: 45px;
--header-height: 46px; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux svg.logo-wireframe,
body.adwaita-icons-always svg.logo-wireframe,
body.adwaita-icons-linux-only.mod-linux svg.logo-wireframe {
stroke-width: 45; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux.is-frameless:not(.is-hidden-frameless) .app-container,
body.adwaita-icons-always.is-frameless:not(.is-hidden-frameless) .app-container,
body.adwaita-icons-linux-only.mod-linux.is-frameless:not(.is-hidden-frameless) .app-container {
margin-top: -9px;
height: calc(100% + 9px); }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .sidebar-toggle-button,
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header-new-tab,
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header-tab-list,
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .mod-left-split .workspace-tabs .workspace-tab-header-container-inner,
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .mod-right-split .workspace-tabs .workspace-tab-header-container-inner,
body.adwaita-icons-always .sidebar-toggle-button,
body.adwaita-icons-always .workspace-tab-header-new-tab,
body.adwaita-icons-always .workspace-tab-header-tab-list,
body.adwaita-icons-always .mod-left-split .workspace-tabs .workspace-tab-header-container-inner,
body.adwaita-icons-always .mod-right-split .workspace-tabs .workspace-tab-header-container-inner,
body.adwaita-icons-linux-only.mod-linux .sidebar-toggle-button,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header-new-tab,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header-tab-list,
body.adwaita-icons-linux-only.mod-linux .mod-left-split .workspace-tabs .workspace-tab-header-container-inner,
body.adwaita-icons-linux-only.mod-linux .mod-right-split .workspace-tabs .workspace-tab-header-container-inner {
margin-top: 0;
padding-top: 0;
padding-bottom: 0; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .mod-left-split .workspace-tabs .workspace-tab-header,
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .mod-right-split .workspace-tabs .workspace-tab-header,
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .sidebar-toggle-button .clickable-icon,
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tabs.mod-top .workspace-tab-header-container .clickable-icon,
body.adwaita-icons-always .mod-left-split .workspace-tabs .workspace-tab-header,
body.adwaita-icons-always .mod-right-split .workspace-tabs .workspace-tab-header,
body.adwaita-icons-always .sidebar-toggle-button .clickable-icon,
body.adwaita-icons-always .workspace-tabs.mod-top .workspace-tab-header-container .clickable-icon,
body.adwaita-icons-linux-only.mod-linux .mod-left-split .workspace-tabs .workspace-tab-header,
body.adwaita-icons-linux-only.mod-linux .mod-right-split .workspace-tabs .workspace-tab-header,
body.adwaita-icons-linux-only.mod-linux .sidebar-toggle-button .clickable-icon,
body.adwaita-icons-linux-only.mod-linux .workspace-tabs.mod-top .workspace-tab-header-container .clickable-icon {
height: 34px;
min-width: 34px;
margin-top: auto;
margin-bottom: auto; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .sidebar-toggle-button.mod-left .clickable-icon svg,
body.adwaita-icons-always .sidebar-toggle-button.mod-left .clickable-icon svg,
body.adwaita-icons-linux-only.mod-linux .sidebar-toggle-button.mod-left .clickable-icon svg {
display: none; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .sidebar-toggle-button.mod-left .clickable-icon::after,
body.adwaita-icons-always .sidebar-toggle-button.mod-left .clickable-icon::after,
body.adwaita-icons-linux-only.mod-linux .sidebar-toggle-button.mod-left .clickable-icon::after {
content: '';
background-color: currentColor !important;
-webkit-mask-image: var(--adwaita-icon-sidebar-show-symbolic);
mask-image: var(--adwaita-icon-sidebar-show-symbolic);
width: 16px;
height: 16px;
margin: auto; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .sidebar-toggle-button.mod-right .clickable-icon svg,
body.adwaita-icons-always .sidebar-toggle-button.mod-right .clickable-icon svg,
body.adwaita-icons-linux-only.mod-linux .sidebar-toggle-button.mod-right .clickable-icon svg {
display: none; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .sidebar-toggle-button.mod-right .clickable-icon::after,
body.adwaita-icons-always .sidebar-toggle-button.mod-right .clickable-icon::after,
body.adwaita-icons-linux-only.mod-linux .sidebar-toggle-button.mod-right .clickable-icon::after {
content: '';
background-color: currentColor !important;
-webkit-mask-image: var(--adwaita-icon-sidebar-show-right-symbolic);
mask-image: var(--adwaita-icon-sidebar-show-right-symbolic);
width: 16px;
height: 16px;
margin: auto; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header-new-tab .clickable-icon svg,
body.adwaita-icons-always .workspace-tab-header-new-tab .clickable-icon svg,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header-new-tab .clickable-icon svg {
display: none; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header-new-tab .clickable-icon::after,
body.adwaita-icons-always .workspace-tab-header-new-tab .clickable-icon::after,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header-new-tab .clickable-icon::after {
content: '';
background-color: currentColor !important;
-webkit-mask-image: var(--adwaita-icon-tab-new-symbolic);
mask-image: var(--adwaita-icon-tab-new-symbolic);
width: 16px;
height: 16px;
margin: auto; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header-tab-list .clickable-icon svg,
body.adwaita-icons-always .workspace-tab-header-tab-list .clickable-icon svg,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header-tab-list .clickable-icon svg {
display: none; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header-tab-list .clickable-icon::after,
body.adwaita-icons-always .workspace-tab-header-tab-list .clickable-icon::after,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header-tab-list .clickable-icon::after {
content: '';
background-color: currentColor !important;
-webkit-mask-image: var(--adwaita-icon-go-down-symbolic);
mask-image: var(--adwaita-icon-go-down-symbolic);
width: 16px;
height: 16px;
margin: auto; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header-inner-close-button svg,
body.adwaita-icons-always .workspace-tab-header-inner-close-button svg,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header-inner-close-button svg {
display: none; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header-inner-close-button::after,
body.adwaita-icons-always .workspace-tab-header-inner-close-button::after,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header-inner-close-button::after {
content: '';
background-color: currentColor !important;
-webkit-mask-image: var(--adwaita-icon-window-close-symbolic);
mask-image: var(--adwaita-icon-window-close-symbolic);
width: 16px;
height: 16px;
margin: auto; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header[data-type="file-explorer"] .workspace-tab-header-inner-icon svg,
body.adwaita-icons-always .workspace-tab-header[data-type="file-explorer"] .workspace-tab-header-inner-icon svg,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header[data-type="file-explorer"] .workspace-tab-header-inner-icon svg {
display: none; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header[data-type="file-explorer"] .workspace-tab-header-inner-icon::after,
body.adwaita-icons-always .workspace-tab-header[data-type="file-explorer"] .workspace-tab-header-inner-icon::after,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header[data-type="file-explorer"] .workspace-tab-header-inner-icon::after {
content: '';
background-color: currentColor !important;
-webkit-mask-image: var(--adwaita-icon-folder-visiting-symbolic);
mask-image: var(--adwaita-icon-folder-visiting-symbolic);
width: 16px;
height: 16px;
margin: auto; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header[data-type="search"] .workspace-tab-header-inner-icon svg,
body.adwaita-icons-always .workspace-tab-header[data-type="search"] .workspace-tab-header-inner-icon svg,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header[data-type="search"] .workspace-tab-header-inner-icon svg {
display: none; }
body:not(.adwaita-icons-always, .adwaita-icons-linux-only, .adwaita-icons-never).mod-linux .workspace-tab-header[data-type="search"] .workspace-tab-header-inner-icon::after,
body.adwaita-icons-always .workspace-tab-header[data-type="search"] .workspace-tab-header-inner-icon::after,
body.adwaita-icons-linux-only.mod-linux .workspace-tab-header[data-type="search"] .workspace-tab-header-inner-icon::after {
content: '';
background-color: currentColor !important;
-webkit-mask-image: var(--adwaita-icon-folder-saved-search-symbolic);
mask-image: var(--adwaita-icon-folder-saved-search-symbolic);
width: 16px;
height: 16px;
margin: auto; }

239
content/notes/.obsidian/workspace.json vendored Normal file
View File

@@ -0,0 +1,239 @@
{
"main": {
"id": "707cdff055641daf",
"type": "split",
"children": [
{
"id": "4ff646379bdc32f1",
"type": "tabs",
"children": [
{
"id": "41d42d82984d27da",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "Notion/Memory.md",
"mode": "source",
"source": false
},
"icon": "lucide-file",
"title": "Memory"
}
}
]
}
],
"direction": "vertical"
},
"left": {
"id": "8554fcd8146aea7c",
"type": "split",
"children": [
{
"id": "65145a8fc625fc73",
"type": "tabs",
"dimension": 66.13756613756614,
"children": [
{
"id": "3e60316ef665bcea",
"type": "leaf",
"state": {
"type": "file-explorer",
"state": {
"sortOrder": "alphabetical",
"autoReveal": false
},
"icon": "lucide-folder-closed",
"title": "Files"
}
},
{
"id": "66bab8cc98ffff03",
"type": "leaf",
"state": {
"type": "search",
"state": {
"query": "",
"matchingCase": false,
"explainSearch": false,
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical"
},
"icon": "lucide-search",
"title": "Search"
}
},
{
"id": "9febdd5b0820c714",
"type": "leaf",
"state": {
"type": "bookmarks",
"state": {},
"icon": "lucide-bookmark",
"title": "Bookmarks"
}
}
]
},
{
"id": "e6a895c667054857",
"type": "tabs",
"dimension": 33.86243386243386,
"children": [
{
"id": "f7c232306fce05bc",
"type": "leaf",
"state": {
"type": "graph",
"state": {},
"icon": "lucide-git-fork",
"title": "Graph view"
}
}
]
}
],
"direction": "horizontal",
"width": 284.5110321044922
},
"right": {
"id": "65640e3e4a22a762",
"type": "split",
"children": [
{
"id": "c2a2b4ff04865342",
"type": "tabs",
"children": [
{
"id": "5a238d79ee59fbda",
"type": "leaf",
"state": {
"type": "backlink",
"state": {
"file": "binary-operations/index.md",
"collapseAll": true,
"extraContext": false,
"sortOrder": "alphabetical",
"showSearch": false,
"searchQuery": "",
"backlinkCollapsed": false,
"unlinkedCollapsed": true
},
"icon": "links-coming-in",
"title": "Backlinks for index"
}
},
{
"id": "0bf5145fd219badf",
"type": "leaf",
"state": {
"type": "outgoing-link",
"state": {
"linksCollapsed": false,
"unlinkedCollapsed": true
},
"icon": "links-going-out",
"title": "Outgoing links"
}
},
{
"id": "f07e471ad3a546d5",
"type": "leaf",
"state": {
"type": "tag",
"state": {
"sortOrder": "frequency",
"useHierarchy": true,
"showSearch": false,
"searchQuery": ""
},
"icon": "lucide-tags",
"title": "Tags"
}
},
{
"id": "6e617d9f3ccf8c06",
"type": "leaf",
"state": {
"type": "outline",
"state": {
"file": "Notion/Memory.md",
"followCursor": false,
"showSearch": false,
"searchQuery": ""
},
"icon": "lucide-list",
"title": "Outline of Memory"
}
}
],
"currentTab": 2
}
],
"direction": "horizontal",
"width": 218.5
},
"left-ribbon": {
"hiddenItems": {
"switcher:Open quick switcher": false,
"graph:Open graph view": false,
"canvas:Create new canvas": false,
"daily-notes:Open today's daily note": false,
"templates:Insert template": false,
"command-palette:Open command palette": false,
"obsidian-importer:Open Importer": false,
"table-editor-obsidian:Advanced Tables Toolbar": false,
"obsidian-local-images-plus:Local Images Plus 0.16.3\r\nLocalize attachments (plugin folder)": false
}
},
"active": "41d42d82984d27da",
"lastOpenFiles": [
"Notion/CPU Architecture.md",
"Notion/Databases SQL.md",
"macOS.md",
"Notion/Memory.md",
"lua.md",
"tmux/index.md",
"Notion/Text Editor NVIM.md",
"tmux/tmux_design.png",
"tmux",
"transistors/index.md",
"transistors/image4.png",
"transistors/image3.png",
"transistors/image2.png",
"transistors/image1.png",
"transistors",
"assembly.md",
"Notion/Untitled.md",
"binary-operations/index.md",
"linux/index.md",
"linux",
"pass.md",
"git.md",
"flask.md",
"https-ssl-certs.md",
"encryption.md",
"http.md",
"python.md",
"wsl2.md",
"irc.md",
"c-language.md",
"Notion/CSS.md",
"ssh.md",
"html.md",
"compiling.md",
"EXT2.png",
"image 96.png",
"image 95.png",
"image 94.png",
"pngwing.com.png",
"Notion2",
"binary-operations",
"algorithms-and-data",
"C language",
"temp",
"Notion"
]
}

View File

@@ -0,0 +1,165 @@
---
Status: Ready
Created by: Trude EH
tags:
- computer-science
- notes
author: TrudeEH
draft: false
searchHidden: false
showToc: true
title: CPU Architecture
---
## Components
### Registers
We can combine registers to reduce the amount of wires needed.
![[image8.png]]
Using a data bus (wiring at the top) and a binary decoder, we can select which register to read/write to.
### Memory
![[image9.png]]
## Assembly
Assembly is a human-friendly representation of code: binary values that a computer can understand.
![[image10.png]]
An assembler converts ASM instructions into machine code, which is given to the CPU as input.
### Arithmetic Operations
For example, a simple computer architecture could use `00` to represent arithmetic operations.
![[image11.png]]
To decide which type of operation to execute (subtraction, multiplication, addition, etc), the 3rd and 4th bits could be used.
![[image12.png]]
Using a [[binary-operations/index]], we can build an inefficient, but simple circuit to do this.
![[image13.png]]
This type of circuit is an Arithmetic Logic Unit (ALU).
### Memory Operations
Of course, assembly can also provide instructions to store or load values.
![[image14.png]]
#### Load
```Assembly
LOAD R2 1000 ;Load into register 2 the value in the memory address 1000
```
![[image15.png]]
#### Store
```Assembly
STORE R1 0110 ;Store the value in register 1 into the 0110 memory address
```
![[image16.png]]
#### Select Which Instruction to Execute (first 2 bits)
To decide which operation to execute, a binary decoder can be used.
![[image17.png]]
For memory operations, the 3rd and 4th bits are used to select which register to use.
![[image18.png]]
The last 4 bits represent the memory address to read/write to.
![[image19.png]]
### Instruction Register
For the instruction to be given, it is stored in a special register: An Instruction Register.
![[image20.png]]
### Optimization
We can use a single Binary Decoder instead of two, to achieve the same result. (Optimization on the right pane)
![[image21.png]]
Different architectures can have the exact same functionality, while being implemented differently, or even having different instructions. This is why code that is compiled for Intel x64 is not compatible with ARM or RISC-V.
## Control Unit
We can finally add the ALU (Arithmetic Logic Unit) we built before into the new circuit, like so:
![[image22.png]]
The gray trapezoids are multiplexers:
![[image23.png]]
The output value is then stored in a temporary register, before replacing the first operand register's value.
The component we just built to control the `ALU` is part of a `Control Unit`. The full `control unit` is very complex, as it needs to handle every possible instruction. (So far, we have seen how to implement the `ALU` and `RAM`.)
![[image24.png]]
Each register in the `CU` has a specific purpose, unlike `RAM`, which can be used to store any values.
![[image25.png]]
To read the first instruction, the `CU` will **fetch** data from the first address in memory.
![[image26.png]]
After **fetching**, the `CU` will **decode** the instruction: interpret the bit sequence in the `instruction register`, to send the necessary signals to the components that will **execute** the instruction. We can finally load instructions into the instruction register.
![[image27.png]]
Then, the `CU` increments 1 byte, to point the `address register` to the next instruction. (Modern architectures increment different values, as the instruction set is more complex)
If the instruction is an arithmetic operation, the steps are similar. The ALU stores the output in a temporary register, which overwrites the register 0 with the result. The result can then be stored in `RAM`.
![[image28.png]]
## Load a Program Into Memory
So far, we can store instructions in memory, but it is also necessary to store values, besides from the instructions themselves.
For example:
![[image29.png]]
This program uses 2 numeric values. The first 2 instructions load these values into the registers, and then, these values are added together and stored in another memory address. The final instruction, `HALT`, marks the end of the program, to make sure the `CU` does not attempt to read the number 20 as an instruction.
If the program is extended, all memory addresses must be altered. To fix this issue, we can instead store values at the end of the memory stack.
![[image30.png]]
## Conditions and Loops
To create a loop, we can simply jump to a smaller address in memory.
![[image31.png]]
Internally, the `JMP` command overwrites the Address Register, making it so that the next CPU **cycle** *fetches* the chosen memory address, instead of the next one.
![[image32.png]]
### Flags
Sometimes, we might want to loop only if a certain condition is met.
For context, imagine subtracting a number from itself. In this case, the ALU will provide some extra information, using 1 bit registers called `flags`.
![[image33.png]]
| | | |
|---|---|---|
|0|**O**verflow|When a number is too large to fit in the output register.|
|1|**Z**ero|When the result is zero.|
|0|**N**egative|When a number is negative.|
This additional information can be used to make decisions, and make **conditional jumps** possible.
| | | |
|---|---|---|
|`JMP_OFW XXXX`|Jump Overflow|Overwrites the `Address Register` with the value `XXXX` if the `O_FLAG` is **ON**. If the flag is **OFF**, the `Address Register`'s value is incremented by **1**.|
|`JMP_ZRO XXXX`|Jump Zero|Overwrites the `Address Register` with the value `XXXX` if the `Z_FLAG` is **ON**. If the flag is **OFF**, the `Address Register`'s value is incremented by **1**.|
|`JMP_NEG XXXX`|Jump Negative|Overwrites the `Address Register` with the value `XXXX` if the `N_FLAG` is **ON**. If the flag is **OFF**, the `Address Register`'s value is incremented by **1**.|
|`JMP_ABV XXXX`|Jump Above|Overwrites the `Address Register` with the value `XXXX` if **neither** the `Z_FLAG` nor `N_FLAG` are **ON**. If either is **ON,** the `Address Register`'s value is incremented by **1**.|
Comparing two numbers is the same as subtracting them.
$$a - 5 = b$$
| | | |
|---|---|---|
|**b** is negative|**b** is zero|**b** is positive|
|then|then|then|
|a < 5|a == 5|a > 5|
For example:
![[image34.png]]
An `IF` statement works in the exact same way, but without the need to loop:
![[image35.png]]
Note: These instructions are not from any real architecture. These are examples for this simple, custom architecture.
## Clock
The final piece of the puzzle is the clock. A clock can give us time before a circuit loops.
![[image36.png]]
This is necessary, because energy travels extremely quickly, and so, all memory would be reset before we could even use the stored values. Each clock tick corresponds to an action the `CU` performs (fetch, decode and execute).
A `Data FLIP-FLOP`, for example, uses the clock to store data, acting as the manual `RESET` input.
![[image37.png]]
This circuit can be used to build a single bit register.
![[image38.png]]
To generate a clock pulse, we can use a circuit similar to this one:
![[image39.png]]

View File

@@ -0,0 +1,324 @@
---
Status: Ready
Created by: Trude EH
tags:
- notes
- programming
- web
author: TrudeEH
draft: false
searchHidden: false
showToc: true
title: Databases [SQL]
---
## Flat-File Databases
A "table" written into a single file. The most common file type for this purpose is `CSV`.
The `CSV` format reads each line as a row, and each comma-separated value as a column.
The first row on a `CSV` file is used to describe the data in each column. If a `,` is present on the dataset, surround that entry with `"` to 'escape' it.
These files can be read and written to using languages like [[c-language]] and [[python]].
## Relational Databases
Instead of using a single table, a relational database can store data in multiple tables, and then define relationships between them.
Each table must have one column with an unique key that identifies each row.
![[image94.png]]
### Relationships
#### One-to-one Relationship
In this example, `id` in `shows` corresponds to the `show_id` in the `ratings` table.
#### One-to-many Relationship
`shows` has a one-to-many relationship with `genres`, because a single show entry can have many genders.
#### Many-to-many Relationship
Both the `people` and `writers` table have a field shared with `stars`.
## SQL
`SQL` is a language designed specifically for interfacing with relational databases.
To use `SQL`, a database is needed, so, for this example, I will use `sqlite3`.
### Create a Database
```Shell
sqlite3 name.db # Create a db file and initialize it.
```
### `sqlite3` Commands
#### Import a `CSV` Table
```SQL
.mode csv
.import name.csv table_name
```
#### General Commands
```SQL
.schema -- Print all tables and fields (using the commands used for creation)
.schema table -- Show the command used for creating a table
.exit
```
### Base Syntax
```SQL
CREATE TABLE table (column type, ...); -- Create a new table
SELECT columns FROM table; -- Output/Print data
INSERT INTO table (column, ...) VALUES(value, ...); -- Add data
UPDATE table SET column = value WHERE condition; -- Update values
DELETE FROM table WHERE condition; -- Delete data
```
> [!important] In `SQL`, there is **NO WAY** to undo actions. Especially when writing or deleting from the database, do not type `;` unless you know exactly what you are doing!
#### Wildcard
```SQL
SELECT * FROM table; -- Outputs every column in the table (wildcard selector)
```
### Functions
#### Math Functions
- `AVG`
- `COUNT`
- `DISTINCT`
- `LOWER`
- `MAX`
- `MIN`
- `UPPER`
- `LOWER`
- `…`
```SQL
SELECT COUNT(*) FROM table; -- Counts the number of rows in a table
SELECT DISTINCT column from table; -- Show only the unique values in a column
SELECT COUNT(DISTINCT column) FROM table; -- Count the unique values in a column
```
#### Logic Functions
- `GROUP BY`
- `LIKE`
- `LIMIT`
- `ORDER BY`
- `WHERE`
- ``
```SQL
-- Count every instance of a value in a column
SELECT COUNT(*) FROM table WHERE column = 'string';
-- LIKE is used to select using formatting. '%' selects every character after)
SELECT * FROM favorites WHERE prog_language = 'C' AND problem LIKE "Hello, %"
-- Group all individual rows and display their count
SELECT prog_language, COUNT(*) FROM favorites GROUP BY prog_language;
-- Sort values by their count, ascending.
SELECT prog_language, COUNT(*) FROM favorites GROUP BY prog_language ORDER BY COUNT(*);
-- Sort values by their count, descending.
SELECT prog_language, COUNT(*) FROM favorites GROUP BY prog_language ORDER BY COUNT(*) DESC;
-- Limit the output to a single row (showing the most popular language, in this case)
SELECT prog_language, COUNT(*) FROM favorites GROUP BY prog_language ORDER BY COUNT(*) DESC LIMIT 1;
```
#### Operators
- `AND`
- `OR`
```SQL
-- Using the AND operator to select two values
SELECT * FROM table WHERE column1 = 'a' AND column2 = 'b';
-- AND and OR (' is escaped using '' (' twice))
SELECT * FROM table WHERE prog_language = 'C' AND (problem = 'Hello, World' OR problem = 'Hello, It''s Me');
```
#### Aliases
- `AS`
```SQL
-- The column COUNT(*) will be renamed to 'n'.
SELECT prog_language, COUNT(*) AS n FROM favorites GROUP BY prog_language ORDER BY n DESC;
```
#### Conditions
- `IS`
```SQL
-- Delete all values where timestamp1 is a NULL value.
DELETE FROM favorites WHERE timestamp1 IS NULL;
```
### Data Types
- `BLOB`
- `INTEGER`
- `NUMERIC`
- `REAL`
- `TEXT`
- `NULL`
- `NOT NULL`
- `UNIQUE`
- `PRIMARY KEY`
- `FOREIGN KEY`
### Relationships
- `IN`
- `JOIN`
#### One-to-one
```SQL
-- 'shows' table
CREATE TABLE shows (
id INTEGER,
title TEXT NOT NULL,
year NUMERIC,
episodes INTEGER,
PRIMARY KEY(id)
);
-- Table connected with a one-to-one relationship with the 'shows' table
CREATE TABLE ratings (
show_id INTEGER NOT NULL,
rating REAL NOT NULL,
votes INTEGER NOT NULL,
FOREIGN KEY(show_id) REFERENCES shows(id)
);
-- Lists 'show_id', but not the actual names of each show.
SELECT show_id FROM ratings WHERE rating >= 6.0 LIMIT 10;
-- Executes the nested query first, then shows the entries selected on 'shows'
SELECT * FROM shows WHERE id IN
(SELECT show_id FROM ratings WHERE rating >= 6.0)
LIMIT 10;
-- Join both tables
SELECT title, rating FROM shows JOIN
ratings ON shows.id = ratings.show_id WHERE rating >= 6.0
LIMIT 10;
```
#### One-to-many
- `ON`
```SQL
CREATE TABLE genres (
show_id INTEGER NOT NULL,
genre TEXT NOT NULL,
FOREIGN KEY(show_id) REFERENCES shows(id)
);
-- Search for all genres for a show
SELECT genre FROM genres WHERE show_id =
(SELECT id FROM shows WHERE title = 'TitleOfShow');
-- Join tables, to show title alongside genres of a show
SELECT title, genre FROM shows JOIN genres ON shows.id =
genres.show_id WHERE id =
(SELECT id FROM shows WHERE title = 'TitleOfShow');
```
#### Many-to-many
![[image95.png]]
```SQL
-- Select every person who starred in a show
SELECT name FROM people WHERE id IN
(SELECT person_id FROM stars WHERE show_id =
(SELECT id FROM shows WHERE title = 'Some Name'));
-- Joined table with the show name and stars
SELECT title FROM shows JOIN people.name WHERE id IN
(SELECT person_id FROM stars WHERE show_id =
(SELECT id FROM shows WHERE title = 'Some Name'));
-- Another way to join tables
SELECT title FROM shows, stars, people
WHERE shows.id = stars.show_id
AND people.id = stars.person_id
AND name = 'Name';
```
### Indexes
Load an index of the database into RAM to optimize searches.
The underneath algorithm is a `B-Tree`, which takes up more space in memory and slightly slows write speed on the database.
```SQL
CREATE INDEX name ON table (column, ...);
.timer ON -- sqlite3 command to show how long operations take to complete
SELECT * FROM shows WHERE title = 'Name'; -- 0.043s
CREATE INDEX title_index ON shows(title); -- Index title on shows
SELECT * FROM shows WHERE title = 'Name'; -- 0.001s
SELECT name FROM people WHERE id IN
(SELECT person_id FROM stars WHERE show_id =
(SELECT id FROM shows WHERE title = 'Some Name')); -- 0.215s
CREATE INDEX name_index ON people(name);
CREATE INDEX person_index ON stars(person_id);
SELECT name FROM people WHERE id IN
(SELECT person_id FROM stars WHERE show_id =
(SELECT id FROM shows WHERE title = 'Some Name')); -- 0.001s
```
### Race Conditions
When `SQL` is integrated with languages such as `Python`, for example, or is being accessed by multiple instances, race conditions may arise.
For example, consider the following code:
```Python
...
rows = db.execute("SELECT likes FROM posts WHERE id = ?", id);
likes = rows[0]["likes"]
db.execute("UPDATE posts SET likes = ? WHERE id = ?", likes + 1, id);
```
If this code is executed twice at the same time, instead of adding 2 likes to the database, only one will be added, because the program would read the database in the same state, and then add +1 like to that same, previous state.
`SQL` provides solutions to this in the form of **transactions**:
- `BEGIN TRANSACTION`
- `COMMIT`
- `ROLLBACK`
On `Python`, a solution could be:
```Python
db.execute("BEGIN TRANSACTION")
rows = db.execute("SELECT likes FROM posts WHERE id = ?", id);
likes = rows[0]["likes"]
db.execute("UPDATE posts SET likes = ? WHERE id = ?", likes + 1, id);
db.execute("COMMIT")
```
Where the database would be "locked" while the program ran.
### `SQL` Injection Attacks
If a program asks for user input, and that input is then passed over to the database, the user could write special `SQL` syntax to break the query.
For example:
If a program takes an email address as input, some user could type: `email@example.com'--`, which marks a comment.
If the query was similar to the following:
```Python
rows = db.execute(f"SELECT * FROM users WHERE email = '{email}' AND password = {psk}")
```
Replacing values…
```Python
rows = db.execute(f"SELEC * FROM users WHERE email = 'email@example.com'--' AND password = 'password123'")
```
Which would result in the user being able to log in without needing a password.
The solution to this is to use a library which uses placeholders to insert data in queries.
```Python
rows = db.execute("SELECT * FROM users WHERE email = ? AND password = ?", email, psk)
```

View File

@@ -0,0 +1,18 @@
---
Status: Planned
Created by: Trude EH
tags:
- notes
- tools
author: TrudeEH
draft: false
searchHidden: false
showToc: true
title: Debug/Repair Tools
---
Scrcpy
scrcpy —otg
scrcpy
ADB
adb kill-server

View File

@@ -0,0 +1,70 @@
---
Status: Ready
Created by: Trude EH
tags:
- notes
- programming
author: TrudeEH
draft: false
searchHidden: false
showToc: true
title: Debugging [GDB]
---
## GDB Debugging
### Compile with Debug Information
To allow `gdb` access to the source code (Provides debug symbols - Do not share publicly as it contains the source code).
```Shell
gcc -g <file>
```
### Look for / Fix Bugs
First, initialize `gdb` with the executable to debug.
```Shell
gdb ./<executable> --tui
```
After `gdb` is ready, we can use the following commands:
|Command|Description|
|---|---|
|`lay next`|Switch to the next layout (Enables TUI mode if disabled - Allows for reading the code while debugging both in `C` and `ASM`).|
|`ref`|Refresh (if a program prints to the terminal, it can break `gdb`'s interface).`|
|`q`|Quit `gdb`.|
|||
|`b main`|Add a breakpoint at the main function.|
|`b`|Place a breakpoint at the current line.|
|`b <N>`|Place a breakpoint at line `N`.|
|`b +<N>`|Place a breakpoint N lines down.|
|`b <fn>`|Place a breakpoint at `fn` function.|
|`d`|Delete all breakpoints.|
|`d <N>`|Delete breakpoint number `N`.|
|`clear <fn>`|Clear the breakpoint set to `fn` function.|
|||
|`n`|Execute up to the next line in `C`. If a function call is found, execute the function completely.|
|`s`|Execute up to the next line in `C`. (Jump over)|
|`s <N>`|Run `N` lines.|
|`u`|Same as `n`, but if in a loop, execute until the loop exits.|
|`nexti`|Execute up to the next instruction (line in `ASM`).|
|`r`|Run the program until a breakpoint or error is reached.|
|`c`|Continue running the program until a breakpoint or error is reached.|
|||
|`x/i $pc`|Examine the previous instruction (View memory).|
|`info registers`|Read the CPU registers used by the program.|
|`bt`|See the call stack up to the current line. (How we got here, so to speak)|
|`print sizeof(<variable>)`|Check the size of a struct/variable/pointer.|
|`p <var>`|Print variable `var` value.|
|`info break`|List breakpoints.|
## Check for Memory Leaks
Use `valgrind` to check for lost memory.
```Shell
valgrind --leak-check=full ./<executable>
```

View File

@@ -0,0 +1,109 @@
---
Status: Ready
Created by: Trude EH
tags:
- electronics
- notes
author: TrudeEH
draft: false
searchHidden: false
showToc: true
title: Diodes
---
A diode allows current to only flow in one direction in a circuit.
## Schematic
```Plain
Anode (+) --|>|-- Cathode (-)
```
## Examples
```Plain
[Conventional Current (+) -> (-)]
(+)------|>|------(-) Current can flow - The diode is now a conductor.
(+)------|<|------(-) Current can't flow - The diode is now an insulator.
```
## Use Cases
- Protect a circuit (if a battery is connected incorrectly, for example)
- Convert AC to DC current
Fun fact: An LED, for example, is a Light-Emitting Diode.
## How a Diode Works
### Conductors and Insulators
An atom contains the following elements:
- Nucleus (Protons - Neutrons)
- Orbital Shells (Holds the electrons, which orbit around the nucleus)
- Conduction band
The electrons closest to the nucleus hold the most energy.
The outermost shell is the valence shell. A conductor has 1-3 electrons in the valence shell.
If an electron reaches the conduction band, it can break free and move to another atom.
An insulator, however, has a conduction band that is far from the valence shell, making it difficult for an electron to escape.
For example, for copper (a great conductor), the valence shell and conduction band overlap, so it's very easy for an electron to jump between atoms.
Semiconductors have a conduction band close to the valence shell, but have one extra electron in it, making it an insulator. However, given some external energy, some electrons will gain enough energy to reach the conduction band and become free.
### P-Type and N-Type Doping
Silicon is a good semiconductor, having 4 electrons in its valence shell. When close to other `Si` atoms, they share 4 electrons with their neighbors, thus, having 8, each, and becoming stable.
```Plain
Silicon:
Si Si Si Si Si Si Si Si Si Si Si
Si Si Si Si Si Si Si Si Si Si Si
Si Si Si Si Si Si Si Si Si Si Si
Si Si Si Si Si Si Si Si Si Si Si
Si Si Si Si Si Si Si Si Si Si Si
Si Si Si Si Si Si Si Si Si Si Si
```
#### N-Type
Some Phosphorus is added to the Silicon. ==`p`== has one extra electron in its valence shell.
These electrons are not needed, and so, they flow freely from atom to atom.
```Plain
Si Si p Si Si Si Si Si Si Si p
p Si Si Si Si p Si Si Si Si Si
Si Si Si p Si Si Si Si p Si Si
Si p Si Si p Si Si Si Si Si Si
Si Si Si Si Si Si p Si Si p Si
Si p Si Si Si Si Si Si p Si Si
```
#### P-Type
Some Aluminum is added to the Silicon. `Al` is missing one electron, so it can't provide its 4 neighbors with an electron to share.
```Plain
Si Si Al Si Si Si Si Si Si Si Al
Al Si Si Si Si Al Si Si Si Si Si
Si Si Si Al Si Si Si Si Al Si Si
Si Al Si Si Al Si Si Si Si Si Si
Si Si Si Si Si Si Al Si Si Al Si
Si Al Si Si Si Si Si Si Al Si Si
```
### Combining both Types
When an N-Type is combined with a P-Type, some electrons from the N-Type side will move over to the P-Type side and occupy the missing electrons there. This creates a barrier between both types, creating an electric field that prevents more electrons from switching sides.
#### Forward Bias
If energy is provided to the Cathode, the electrons flow, as the voltage is superior to the barrier's.
```Plain
(-)-----[P|N]-----(+)
```
#### Reverse Bias
If energy is provided to the Anode, the electrons can't flow, as the barrier expands.
```Plain
(-)--[P] [N]--(+)
```

View File

@@ -0,0 +1,13 @@
---
Status: Planned
Created by: Trude EH
tags:
- notes
- programming
- web
author: TrudeEH
draft: false
searchHidden: false
showToc: true
title: JavaScript
---

View File

@@ -0,0 +1,199 @@
---
Status: In progress
Created by: Trude EH
tags:
- computer-science
- notes
- os
author: TrudeEH
draft: false
searchHidden: false
showToc: true
title: Linux Architecture
---
## Kernel
Linux is a kernel: the core of an operative system. OSes that use the Linux kernel are called Linux Distros (Distributions).
A Kernel does the following:
- Executes first when the computer boots up and has full access to the hardware.
- Implements drivers to control peripherals, network devices and other resources.
- Runs other programs (userland software) and allows them to communicate with each other and with the hardware.
### Syscalls
To "ask" the kernel to perform a hardware task, or to access the file system or other resources, a program executes a syscall.
For example (x64 assembly):
```Assembly
// sys_write (Print to stdout)
mov rax, 1
mov rdi, 1
lea rsi, [hello_world]
// Buffer length
mov rdx, 14
syscall
```
This snippet implements a syscall that prints text to `stdout`, usually a terminal window.
### Processes
A program is an executable containing machine code. When a computer executes a program, it is first loaded into memory.
![[image5.png]]
A program loaded in memory is a process.
> [!important] Note: For interpreted languages, the interpreter creates a process that executes the code directly.
### Modules
## Devices
### Device Drivers
Once a new device is plugged in, it attempts to call the Kernel, which identifies that device. The Kernel then loads the appropriate driver. Drivers are Kernel Modules used to interact with hardware. Once the required module is loaded, the Kernel calls the `udevadm` program, that creates a device file in the `/dev` directory.
Whenever there is a read/write operation to that device, the Kernel intercepts the request and calls the driver function instead, which implements that operation, and this is why a driver must implement all possible file operations.
Not all devices control hardware. For example, `/dev/random` generates a random number.
In the Linux Kernel, there are **Character Type Devices** and **Block Type Devices.**
A Character Device provides an endless stream or characters that can be read one at a time. This includes a keyboard and sensors, for example. Block Devices provide data as blocks of a defined size. These include disks and USB drives.
The only exceptions are Network Devices. Network data cannot be manipulated with file operations, so they are handled differently in the kernel.
### Network Devices
If a network card is plugged in, like any other device, it communicates with the Kernel, and the Kernel loads the appropriate Kernel Module that contains the driver. After that, the driver adds new entries to the Kernel's `NICs`, which are data structures stored in memory. The driver then creates configuration files in the `/sys/class/net/` directory. These are not device files, just configuration files. Different network cards can have multiple network interfaces, and even multiple ports to connect to an Ethernet cable, for example. Each interface gets its own folder, as they can have different configurations. Editing these files can change device configurations, but the only way to actually use these interfaces is by calling the Kernel directly. The Kernel can, in turn, create a virtual file in memory, which is then passed as an ID to the application. The application still receives it as a regular file ID (File Descriptor), like with any other device, but it works differently from the Kernel's perspective.
A GPU works similarly, and although the Kernel exposes these devices as files, they are not real files in the filesystem, as doing so would slow them down immensely.
### GPUs
At the startup time, a device file is generated for the GPU, like any other device.
When an application attempts to use the GPU, it first searches for a **Graphics API** to use with it. Examples include Vulkan, OpenGL and DirectX.
These APIs are code functions that forward the requests to a library such as `Mesa`.
`Mesa` then calls the Kernel's DRM (Direct Rendering Engine), which then calls the GPU driver to provide GPU capabilities.
The GPU still has a device file, which is used by the Kernel's DRM and Mesa, but most commands are delivered to the GPU driver directly.
## File Systems
> [!important] This section is heavily simplified and only covers `EXT2-4`.
### Concepts
- An `inode` provides the following information:
- Pointer to the file
- Creation date / Modified times
- Permissions
- A `directory (table)` contains the data before the current directory, the directory itself, and every file inside that directory.
- A `block` is the standard data unit for data in a hard drive. (Same size as memory pages. Ex `x86` CPU would use `4 KB` as the block size.)
### EXT2
Uses linked lists to store and lookup data, to keep the implementation of the filesystem itself as simple as possible. A simple filesystem makes it easier to repair (or skip) broken sectors on the hard drive.
#### Partition Layout
![[EXT2.png]]
### EXT3
#### Journal
`EXT3` implements a journal to act as a buffer after a crash. If any operation in the journal fails, because it was logged, the filesystem is able to recover and finish any pending operations quickly, and not lose data. `EXT2` had another issue, where if an opened directory were deleted, its `inode` wouldn't be deleted, leaving an orphaned, empty `inode` on the filesystem. If the program holding it was to be closed, the `inode` would be deleted, but in the event of a crash, the `inode` would be left in the filesystem, with no way to be freed.
#### HTrees
`EXT3` can also use a [[algorithms-and-data/index]] instead of a linked list to store directory entries, making lookup times much faster. To build the HTree, all filenames are hashed and ordered, making the implementation more complex. This feature is disabled by default.
#### Scalability
Before, only one core could write to the *superblock* at a time, but `EXT3` updates `inode` and `block` count at the *block group descrip_t_or* level. The superblock is only updated through a system call: `statfs()`, or if the filesystem is unmounted.
`EXT3` also removed *big kernel locks* (deprecated feature that added the ability to freeze the kernel), and `sleep_on()`, which was replaced with `wait_event()`, preventing infinite loops.
These patches improved multicore performance by over 10x.
#### Preallocation / Reservation
Writing two files simultaneously can create noncontinuous space.
![[image6.png]]
Because `EXT3` was designed to be used with HDDs, and separate portions of a file would slow down read speeds, `EXT3` implemented a preallocation/reservation system.
Inside the block bitmap, a few extra blocks were preallocated, storing both files in separate locations.
![[image7.png]]
Instead of `EXT2`, where errors were corrected directly in the hard drive, `EXT3` reserves space for each specific `inode` in memory. In the event of a crash, all data would be stored in memory, and thus, not corrupting the HDD itself.
#### Online Resizer
`EXT3` also implements a protocol to support `LVM`, which allows for many disks to be used as a single partition. The largest possible space `EXT3` supports without patches is 16 GB.
#### Partition Layout
![[EXT3.png]]
### EXT4
#### Larger FS
`EXT3` can only support up to 16 TB. This is why `EXT4` was created.
Instead of ==32 bits== capacity to count blocks, `EXT4` divides each entry in the block descriptor table in two parts: An upper, and a lower entry. This lower entry extends the upper one, and since each supports up to ==32 bits==, the total supported block count (in the block descriptor table) rises to ==64 bits== (16 TB → 1,000,000,000 TB).
#### Extents
Instead of using block mapping (the filesystem allocates blocks individually for each file), which can lead to fragmentation, `EXT4` uses **extents**, a range of contiguous blocks, allocated to each file.
This uses a 48 bit system, which limits the FS capacity to 1 EB (1,000,000 TB).
Each extent can point to 128 MB of data, or 1 block group.
#### Compatibility
The `EXT4` driver supports `EXT3` as well, and so, the Linux kernel only uses the `EXT2` and `EXT4` drivers. The `EXT3` driver was removed as the new one is more performant.
#### HTrees
HTrees are now enabled by default, allowing up to 10 million subdirectories. However, `EXT4` implements a Three Level HTree, which can be enabled using the `large_dir` flag, and extends this limit to 2 Billion subdirectories.
#### Fast FS Check
The `big_itable_unused` field was added to the block descriptor table, allowing for fast filesystem checks and error correction, as well as some other improvements.
#### Multiblock Allocation
Previously, each block needed one call to be allocated. `EXT4` added support for multi-block allocation, which means that only one call is needed to allocate multiple blocks.
#### Delayed Allocation
Every write command is delayed for as long as possible, making it so that changes can be made in memory before they affect (and possible fragment) the actual drive.
#### Persistent PreAllocaition
The FS can now be called to preallocate an empty extent, so, once that file is populated, it stays as a contiguous space.
#### Metadata Checksums
Metadata is checked often, which helps find any issues with the file system, as each data structure is now properly 'documented'.
#### Better Times
- A creation time was added;
- The time precision was increased to nanoseconds instead of only seconds;
- The maximum supported time was increased as well (the standard UNIX time can only go up to 2038).
#### Extended Attributes
The filesystem can also be customized with new entries at the end of each `inode`.
#### Quotas
`EXT4` also supports adding limits to the size of a file, or even multiple files spread across the filesystem.
#### Barriers
Some hard drives have caches, which impact the journal, sometimes causing it to be written after the cache, which would create conflicts. To fix this issue, `EXT4` creates a 'barrier', preventing the disk from writing data before the journal is written to the drive. This feature impacts performance, but is also very needed.
#### Flexible Block Groups
Groups blocks together, isolating chucks to write data on, which helps make data more contiguous.
#### Meta Block Groups
If the whole filesystem was only a single block group, it would max out at 256 TB of total data. Using meta block groups, this limit is increased to 32 bits of block group descriptor, which makes the **total capacity of the filesystem** ==**512 PB**==.
#### Partition Layout
[https://maplecircuit.dev/linux/fs/ext/ext4.html](https://maplecircuit.dev/linux/fs/ext/ext4.html)

View File

@@ -0,0 +1,125 @@
---
Status: Ready
Created by: Trude EH
tags:
- computer-science
- electronics
- notes
author: TrudeEH
draft: false
searchHidden: false
showToc: true
title: Logic Gates
---
## NOT
Invert the input.
![[image42.png]]
### Truth Table
|**Input**|**Output**|
|---|---|
|0|1|
|1|0|
## AND
Output `1` only when both inputs are `1`.
![[image43.png]]
### Truth Table
|A|**B**|**Output**|
|---|---|---|
|0|0|0|
|0|1|0|
|1|0|0|
|1|1|1|
## OR
Output `1` if at least one input is `1`.
![[image44.png]]
### Truth Table
|A|**B**|**Output**|
|---|---|---|
|0|0|0|
|0|1|1|
|1|0|1|
|1|1|1|
## NAND
An `AND` gate followed by a `NOT` gate.
![[image45.png]]
### Truth Table
|A|**B**|**Output**|
|---|---|---|
|0|0|1|
|0|1|1|
|1|0|1|
|1|1|0|
## NOR
An `OR` gate followed by a `NOT` gate.
![[image46.png]]
### Truth Table
|A|**B**|**Output**|
|---|---|---|
|0|0|1|
|0|1|0|
|1|0|0|
|1|1|0|
## XOR
Either input is `1`, exclusively.
![[image47.png]]
![[image48.png]]
### Truth Table
|A|**B**|**Output**|
|---|---|---|
|0|0|0|
|0|1|1|
|1|0|1|
|1|1|0|
## XNOR
Inverted `XOR`.
![[image49.png]]
### Truth Table
|A|**B**|**Output**|
|---|---|---|
|0|0|1|
|0|1|0|
|1|0|0|
|1|1|1|
## Implementation Examples
### NOT
![[image50.png]]
### AND
![[image51.png]]
![[image52.png]]
### OR
![[image53.png]]

View File

@@ -0,0 +1,72 @@
---
Status: Ready
Created by: Trude EH
tags:
- computer-science
- notes
author: TrudeEH
draft: false
searchHidden: false
showToc: true
title: Memory
---
## Remembering Data
An `OR` gate could be used to store a single bit.
![[image76.png]]
If the input `A` is changed to `1`, the `OR` gate will output `1`, and then receive it.
![[image77.png]]
Even after the input `A` is set to `0`, the output does not change. The `OR` gate "remembers" that, at one point in the past, the `A` input was set to `1`.
![[image78.png]]
The inverse can be done with an `AND` gate.
![[image79.png]]
To remember either a `1` or a `0`, we can do the following:
![[image80.png]]
AND-OR LATCH
The input `A` sets the output to `1`, and the input `B` sets the output to `0`. This circuit is able to store a bit of information, while powered on, even after both inputs are set to `0`.
A slightly more advanced and intuitive version can be built as follows:
![[image81.png]]
GATED LATCH
The input `A` is the value to store, and when `B` is set to `1`, the value is stored.
This is not the only way to store data using logic gates, but it is one of the simplest.
## Registers
A single bit isn't very useful, so we can use the previous circuit to create an 8bit register.
![[image82.png]]
## Binary Decoder
Select which circuit to activate, depending on the task at hand.
![[image83.png]]
## RAM
Registers don't scale well, however, as storing a large amount of data would require millions of wires.
We can organize latches in a matrix instead of a long, horizontal line.
![[image84.png]]
To access a specific latch, binary decoders can be used.
![[image85.png]]
This way, a single, short memory address can select any latch in the matrix.
### Reading and Writing to the Matrix
We can modify the latch to reduce the amount of wires needed.
![[image86.png]]
This new latch uses the same wire for both input and output.
![[image87.png]]
This circuit would store the same value on every latch, which isn't useful. With some modifications, however, we can use the memory address to select which latch to modify.
![[image88.png]]
![[image89.png]]
### Storing Bytes Instead of Bits
![[image90.png]]
In this example, we can provide 1 byte of information, a `write` or `read` signal, and a memory address. Since we are storing a full byte, the same memory address applies for all 8, single bit circuits.
This configuration is more commonly known as **RAM**.
To make it easier to understand, we can abstract these concepts further.
![[image91.png]]
The largest the Address Bus is, the more bits can be managed. This is why a 32bit CPU can't manage more than 4 GB of RAM.
![[image92.png]]
This kind of RAM is Static RAM (**S**RAM), which uses many transistors, making it faster, but more expensive to produce than **D**RAM.

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

View File

@@ -0,0 +1,498 @@
---
tags:
- notes
- programming
- c
author: TrudeEH
draft: false
showToc: true
title: Algorithms & Data Structures
---
## Time Complexity
The amount of steps required for an algorithm to execute.
### Big O Notation
Maximum time for `n` input size. (Upper bound - worst case)
![Big-O Complexity Chart](bigO.png)
### Omega Notation
Minimum time for `n` input size. (Lower bound)
- `Ω(n²)`
- `Ω(n log n)`
- `Ω(n)`
- `Ω(log n)`
- `Ω(1)`
> If both are the same, use `θ`
## Searching Algorithms
|Algorithm|Average Time Complexity|RAM|
|---|---|---|
|Linear Search|O(n) \| Ω(1)|0|
|Binary Search|O(log n) \| Ω(1)|0|
### Linear Search
Check every element until `n` is found.
```C
#include <stdio.h>
int main(void) {
int n = 1; // number to find
int numbers[] = {20, 500, 10, 5, 100, 1, 50};
const int numbersLength = 7;
for (int i = 0; i < numbersLength; i++) {
if (numbers[i] == n) {
printf("Found n\n");
return 0;
}
}
printf("Not found\n");
return 1;
}
```
### Binary Search
```C
#include <stdio.h>
int main()
{
int c;
int n = 10 // Number of elements in array
int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8 ,9}
int search = 2; // Number to find
int first = 0;
int last = n - 1;
int middle = (first+last)/2; // Average
while (first <= last) {
if (array[middle] < search)
first = middle + 1;
else if (array[middle] == search) {
printf("%d found at location %d.\n", search, middle+1);
break;
}
else
last = middle - 1;
middle = (first + last)/2;
}
if (first > last)
printf("Not found! %d isn't present in the list.\n", search);
return 0;
}
```
## Sorting Algorithms
|Algorithm|Average Time Complexity|RAM|Use If|
|---|---|---|---|
|Selection Sort|O(n²) \| Ω(n²)|1 var|Never|
|Bubble Sort|O(n²) \| Ω(n)|0||
|Insertion Sort|O(n²) (Faster if the data is kind of sorted)|0||
|Merge Sort|O(n log n) \| Ω(n log n)|More RAM|Large Arrays|
|Quick Sort|O(n log n)|Less RAM|Small arrays|
## Data Structures
### Queue (Concept)
First In, First Out
- enqueue - Add an item to the end of the line.
- dequeue - Remove an item from the beginning of the line.
### Stack (Concept)
Last In, First Out
The last item added will be used first, so the first ones added might never be used.
- push - Add an item to the top of the stack
- pop - Remove an item from the top of the stack
### Arrays
|Search|O(log n)|
|---|---|
|Multiple data types|No|
|Resizable|No|
|RAM Usage|Low|
```C
double prices[] = {5.0, 3.2, 13.0};
double values[5]; //Initialize an empty array, that can hold 5 items.
printf("%lf€", prices[0]);
printf("%d", sizeof(prices)); //3
```
#### 2D Arrays
```C
int numbers[2][3] = {
{1, 2, 3},
{4, 5, 6}
};
numbers[0][1]; //2
numbers[1][2]; //6
numbers[0][1] = 10; //Set [0][1] to 10.
// Note: Calculate the rows and columns automatically.
int rows = sizeof(numbers)/sizeof(numbers[0]);
int columns = sizeof(numbers[0])/sizeof(numbers[0][0]);
```
#### Array of Strings
```C
char cars[][10] = {"Mustang", "Corvette", "Camaro"};
//cars[0] = "Tesla"; ERROR! String arrays don't support item assignment.
strcpy(cars[0], "Tesla"); //Does the same, but <string.h> must be included.
```
### Resize Array
#### Manually
```C
#include <stdlib.h>
int *list = malloc(3 * sizeof(int));
// Works like an array
list[0] = 1;
list[1] = 2;
list[2] = 3;
//Same as
*list = 1;
*(list + 1) = 2;
*(list + 2) = 3;
// ...
// Add 1 extra byte to the array
int *tmp = malloc(4 * sizeof(int));
if (tmp == NULL) {
free(list);
return 1;
}
for (int i = 0; i < 3; i++){
tmp[i] = list[i];
}
tmp[3] = 4;
free(list);
list = tmp;
// ...
free(list);
return 0;
```
#### Realloc
```C
int *list = malloc(3 * sizeof(int));
list[0] = 1;
list[1] = 2;
list[2] = 3;
// ...
int *tmp = realloc(list, 4 * sizeof(int)); //tmp is only needed to verify if realloc was successful, if realloc was assigned to int and failed, the 3 bytes from the list would be lost as list = NULL.
if (tmp == NULL) {
free(list);
return 1;
}
list = tmp;
list[3] = 4;
// ...
free(list);
return 0;
```
### Linked Lists
| Linked List | TC |
| --------------------- | ------ |
| Add element unordered | O(1) |
| Add element ordered | O(n) |
| Search | O(n) |
| Insert | O(n) |
| Multiple data types | Yes |
| Resizable | Yes |
| RAM Usage | Medium |
Each element has its value, and a pointer to the next element. The last element's pointer is `NULL`. (NULL == 0x0)
```Plain
[N] -> [N] -> [N] -> [N] ...
```
```C
typedef struct node {
int number; // Value
struct node *next; // Pointer to the next node
} node;
```
#### Unordered Linked List Example
Both code blocks are unsafe (if there's no memory, the program won't free)
```C
typedef struct node {
int number;
struct node *next;
} node;
int main(void) {
node *list = NULL;
node *n = malloc(sizeof(node)); // n points at the first node of the linked list.
(*n).number = 1; // First element = 1.
//Or
n->number = 1; // Same.
n->next = NULL; // Point to NULL so it won't point to a garbage value.
list = n;
node *n = malloc(sizeof(node)); // n points at the first node of the linked list.
n->number = 2;
n->next = list;
list = n;
}
```
```C
\#include <stdlib.h>
\#include <stdio.h>
typedef struct node {
int number;
struct node *next;
} node;
int main(void) {
node *list = NULL;
int numbers[] = {1, 2, 3};
// Create linked list with the elements in the array.
for (int i = 0; i < 3; i++) {
node *n = malloc(sizeof(node));
if (n == NULL) return 1;
n->number = number;
n->next = NULL;
n->next = list;
list = n;
}
// Print all elements from linked list.
node *ptr = list;
while (ptr != NULL) {
printf("%i\\n", ptr->number);
ptr = ptr->next; // Borrow the value in the list->n, which has the next node address.
}
// Free the list's memory.
ptr = list;
while (ptr != NULL) {
node *next = ptr->next;
free(ptr);
ptr = next;
}
}
```
### Trees
| Balanced | Unbalanced | TC |
| ------------------- | ---------- | ---- |
| Add element | O(n) | O(n) |
| Search | O(log n) | O(n) |
| Insert | O(log n) | O(n) |
| Multiple data types | Yes | Yes |
| Resizable | Yes | Yes |
| RAM Usage | High | High |
If organized correctly, allows for binary search.
Each node has 2 pointers.
```Plain
[N] - root / parent
/ \\
[N] [N] - parent and children
/ \\ / \\
[N] [N] [N] [N] - leaf / child
```
```C
typedef struct treenode {
int value;
struct treenode *left;
struct treenode *right;
} treenode;
treenode *createnode(int value) {
treenode* result = malloc(sizeof(treenode));
if (result != NULL) {
result->left = NULL;
result->right = NULL;
result->value = value;
}
return result;
}
void printtabs(int numtabs){
for (int i=0; i < numtabs; i++){
printf("\\t");
}
}
void printtree_rec(treenode *root, int level){
if (root == NULL) {
printtabs(level);
printf("----<empty>-----\\n");
return;
}
// Preordered
printtabs(level);
printf("value = %d\\n", root->value);
printtabs(level);
printf("left\\n");
printtree_rec(root->left, level + 1);
printtabs(level);
printf("right\\n");
printtree_rec(root->right, level + 1);
printtabs(level);
printf("done\\n");
}
void printtree(treenode *root) {
printtree_rec(root, 0);
}
int main(void){
treenode *n1 = createnode(10);
treenode *n2 = createnode(11);
treenode *n3 = createnode(12);
treenode *n4 = createnode(13);
treenode *n5 = createnode(14);
// n1 will be the root
n1->left = n2;
n1->right = n3;
n3->left = n4;
n4->right = n5;
printtree(n1);
free(n1);
free(n2);
free(n3);
free(n4);
free(n5);
}
```
### Hash Tables
| Average | Worst | Best |
| ------------------- | --------- | --------- |
| Add element | O(1) | O(n) |
| Search | O(1) | O(n) |
| Insert | O(1) | O(n) |
| Multiple data types | Yes | Yes |
| Resizable | Yes | Yes |
| RAM Usage | Very High | Very High |
An array, in which every element is a linked list.
The array is used to 'choose' a linked list, and the linked list stores a dynamic number of elements.
```C
[0] -> [N] -> [N] -> [N]
[1] -> [N] -> [N]
[2] -> [N]
[3] -> [N] -> [N]
[4] -> [N] -> [N] -> [N]
[5] -> [N] -> [N]
0-5 - Array element
N - Linked list node
```
### Trie
| Trie | Average | Worst |
| ------------------- | -------------- | -------------- |
| Add element | O(1) | O(1) |
| Search | O(1) | O(1) |
| Insert | O(1) | O(1) |
| Multiple data types | Yes | Yes |
| Resizable | Yes | Yes |
| RAM Usage | Extremely High | Extremely High |
Tree, but every node is an array.
Useful to store words. Every element in an array is linked to the next letter.
![Trie](trie.png)
```C
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#define ALPHABET_SIZE 26
struct TrieNode {
struct TrieNode *children[ALPHABET_SIZE];
bool isendofword;
};
typedef struct TrieNode TrieNode;
TrieNode *createNode() {
TrieNode *node = (TrieNode *)malloc(sizeof(TrieNode));
node->isendofword = false;
for (int i = 0; i < ALPHABET_SIZE; i++) {
node->children[i] = NULL;
}
return node;
}
void insert(TrieNode *root, const char *key) {
TrieNode *current = root;
for (int i = 0; i < strlen(key); i++) {
int index = key[i] - 'a';
if (current->children[index] == NULL) {
current->children[index] = createNode();
}
current = current->children[index];
}
current->isendofword = true;
}
bool search(TrieNode *root, const char *key) {
TrieNode *current = root;
for (int i = 0; i < strlen(key); i++) {
int index = key[i] - 'a';
if (current->children[index] == NULL) {
return false;
}
current = current->children[index];
}
return (current != NULL && current->isendofword);
}
bool isempty(TrieNode *root) {
for (int i = 0; i < ALPHABET_SIZE; i++) {
if (root->children[i] != NULL) {
return false;
}
}
return true;
}
TrieNode *deleteHelper(TrieNode *root, const char *key, int depth) {
if (root == NULL) {
return NULL;
}
if (depth == strlen(key)) {
if (root->isendofword) {
root->isendofword = false;
}
if (isempty(root)) {
free(root);
root = NULL;
}
return root;
}
int index = key[depth] - 'a';
root->children[index] = deleteHelper(root->children[index], key, depth + 1);
if (isempty(root) && !root->isendofword) {
free(root);
root = NULL;
}
return root;
}
void deletekey(TrieNode *root, const char *key) {
deleteHelper(root, key, 0);
}
int main() {
TrieNode *root = createNode();
insert(root, "example");
insert(root, "word");
printf("%s\n", search(root, "word") ? "Found" : "Not Found");
printf("%s\n", search(root, "example") ? "Found" : "Not Found");
printf("%s\n", search(root, "trude") ? "Found" : "Not Found");
deletekey(root, "word");
printf("%s\n", search(root, "word") ? "Found" : "Not Found");
return 0;
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

46
content/notes/assembly.md Normal file
View File

@@ -0,0 +1,46 @@
---
tags:
- computer-science
- notes
author: TrudeEH
draft: true
showToc: true
title: Assembly
---
#todo
## Assembler/Compiler
- `gcc` GNU C Compiler (The package includes `as` (assembler) and `ld` (linker))
```Shell
as <file.asm> -o <output.o> # Assemble
gcc -o <output_file> <output.o> -nostdlib -static # Link using gcc
ld <output.o> # Link using ld
```
## Hello World
```Assembly
.global _start
.intel_syntax noprefix
_start:
// sys_write (Print to stdout)
mov rax, 1
mov rdi, 1
lea rsi, [hello_world]
// Buffer length
mov rdx, 14
syscall
// sys_exit (safely end the program with a re turn code)
mov rax, 60
// Exit with code 0
mov rdi, 0
syscall
hello_world:
// ASCII, zero delimited
.asciz "Hello, World!\n"
```
To know which system calls we can execute and which values needed for the registers, refer to [this table](https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/).

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,392 @@
---
tags:
- computer-science
- notes
author: TrudeEH
draft: true
showToc: true
title: Binary Operations
---
#todo
## Binary
Binary is a base-2 numeral system: A simple way to represent numbers using only two states.
|Binary|Decimal|Hexadecimal|
|---|---|---|
|0000|00|00|
|0001|01|01|
|0010|02|02|
|0011|03|03|
|0100|04|04|
|0101|05|05|
|0110|06|06|
|0111|07|07|
|1000|08|08|
|1001|09|09|
|1010|10|0A|
|1011|11|0B|
|1100|12|0C|
|1101|13|0D|
|1110|14|0E|
|1111|15|0F|
![Binary Calculations](binarycalc.png)
### Speaking Binary
> The information in this section is non-standard, and mostly a curiosity.
You may struggle to pronounce large binary numbers, as saying a long list of 0s and 1s is very inefficient. Instead, we can do something like this:
![speaking binary](sb1.png)
To be able to say any binary number, list the number, starting by the last digit:
![speaking binary](sb2.png)
And pronounce the ones that correspond to a `1` bit.
![speaking binary](sb3.png)
#### Pronounce a Binary Number at a Glance
1. Break the number at its largest pair of bits.
![speaking binary](sb4.png)
2. Represent the left and right sides.
![speaking binary](sb5.png)
In this example, there is a `two` in the order of magnitude `hex`.
3. Continue to represent the left and right sides recursively.
![speaking binary](sb6.png)
The last number is `four`.
#### Decode a Spoken Binary Number
Starting with `two hex four`:
1. Find the largest power of two.
![speaking binary](sb7.png)
2. The number is equal to the left side, times the order of magnitude, plus the right side.
![speaking binary](sb8.png)
#### Avoiding Repetition
Repetition can be avoided by combining some very common, small numbers:
![speaking binary](sb9.png)
![speaking binary](sb10.png)
These shortcuts essentially create a quaternary system to pronounce binary, but in this case, the result improves spoken efficiency by a lot.
## Arithmetic Operations
### Addition
Adding two numbers can be done using a simple, manual algorithm: By adding the last bit of both numbers first, carry if necessary, then move on to the next number, and so on.
| + | `.` | `\|` |
| ---- | ---- | ----- |
| `.` | `.` | `\|` |
| `\|` | `\|` | `\|.` |
![addition](addition.png)
> To add numbers more efficiently by hand, you can group bits together and memorize the patters, effectively doubling your speed.
>
> ![hand addition](hand_addition1.png)
>
> To improve calculation speed even further, you can group more bits, and learn those patterns as well.
>
> ![hand addition](hand_addition2.png)
#### Half Adder
Add 2, single-digit binary numbers.
|**A**|**B**|**Carry**|**Sum**|
|---|---|---|---|
|`.`|`.`|`.`|`.`|
|`.`|`\|`|`.`|`\|`|
|`\|`|`.`|`.`|`\|`|
|`\|`|`\|`|`\|`|`.`|
![[/image 14.png|image 14.png]]
#### Full Adder
When adding 2 binary numbers, one operation might return a carry value, which the `half adder` can't accept, as it only has 2 inputs.
![[/image 15.png|image 15.png]]
To solve this issue, a `full adder` accepts 3 inputs.
![[/image 16.png|image 16.png]]
#### 8-Bit Adder
![[/image 17.png|image 17.png]]
### Subtraction
Subtraction can result in negative numbers. Like how additions need a carry, subtraction needs a borrow.
#### Half Subtractor
Subtract 2, single-digit binary numbers.
|**A**|**B**|Diff|**Borrow**|
|---|---|---|---|
|`.`|`.`|`.`|`.`|
|`.`|`\|`|`\|`|`\|`|
|`\|`|`.`|`\|`|`.`|
|`\|`|`\|`|`.`|`.`|
![[/image 18.png|image 18.png]]
#### Full Subtractor
A `full subtractor` accepts the borrow value, allowing us to chain results.
|**A**|**B**|**B**in|**Diff**|**B**out|
|---|---|---|---|---|
|`.`|`.`|`.`|`.`|`.`|
|`.`|`.`|`\|`|`\|`|`\|`|
|`.`|`\|`|`.`|`\|`|`\|`|
|`.`|`\|`|`\|`|`.`|`\|`|
|`\|`|`.`|`.`|`\|`|`.`|
|`\|`|`.`|`\|`|`.`|`.`|
|`\|`|`\|`|`.`|`.`|`.`|
|`\|`|`\|`|`\|`|`\|`|`\|`|
![[/image 19.png|image 19.png]]
#### 8-Bit Subtractor
![[/image 20.png|image 20.png]]
### Multiplication
Multiplication is also similar to its decimal counterpart, but because binary is so small compared to decimal, the steps are also much simpler.
First, multiply the top number to every digit of the bottom one, and then add the results together.
|X|`.`|`\|`|
|---|---|---|
|`.`|`.`|`.`|
|`\|`|`.`|`\|`|
```Plain
||.|
x ||.
....
||.|
+ ||.|
|..|||.
```
#### 2-Bit By 2-Bit Multiplier
![[/image 21.png|image 21.png]]
### Division
1. Find the smallest part of the dividend greater than or equal to the divisor.
```Plain
|.| ||..|
```
2. Write the first digit of ==the answer==, and ==copy the original divisor down==.
```Plain
|
|.| ||..|
|.|
```
3. Subtract ==the aligned dividend digits== by ==the digits under the dividend====.==
```Plain
|
|.| ||..|
|.|
|
```
4. Lower ==the next dividend digit==.
```Plain
|
|.| ||..|
|.|
|.
```
5. Is ==the total== greater or equal to the ==divisor==? If so, add a `1` to the answer. If not, ==add a== ==`0`== ==to the answer== ==and return to step 4==.
```Plain
|.
|.| ||..|
|.|
|.
```
6. Return to step 2, until you reach the end of the number. If you reached the end, you found ==the answer==.
```Plain
|.|
|.| ||..|
|.|
|.|
|.|
.
```
### ASCII
Binary can also be used to represent characters.
| | | | | | |
|---|---|---|---|---|---|
|Dec|Hex|Binary|HTML|Char|Description|
|0|00|00000000|`&#0;`|NUL|Null|
|1|01|00000001|`&#1;`|SOH|Start of Heading|
|2|02|00000010|`&#2;`|STX|Start of Text|
|3|03|00000011|`&#3;`|ETX|End of Text|
|4|04|00000100|`&#4;`|EOT|End of Transmission|
|5|05|00000101|`&#5;`|ENQ|Enquiry|
|6|06|00000110|`&#6;`|ACK|Acknowledge|
|7|07|00000111|`&#7;`|BEL|Bell|
|8|08|00001000|`&#8;`|BS|Backspace|
|9|09|00001001|`&#9;`|HT|Horizontal Tab|
|10|0A|00001010|`&#10;`|LF|Line Feed|
|11|0B|00001011|`&#11;`|VT|Vertical Tab|
|12|0C|00001100|`&#12;`|FF|Form Feed|
|13|0D|00001101|`&#13;`|CR|Carriage Return|
|14|0E|00001110|`&#14;`|SO|Shift Out|
|15|0F|00001111|`&#15;`|SI|Shift In|
|16|10|00010000|`&#16;`|DLE|Data Link Escape|
|17|11|00010001|`&#17;`|DC1|Device Control 1|
|18|12|00010010|`&#18;`|DC2|Device Control 2|
|19|13|00010011|`&#19;`|DC3|Device Control 3|
|20|14|00010100|`&#20;`|DC4|Device Control 4|
|21|15|00010101|`&#21;`|NAK|Negative Acknowledge|
|22|16|00010110|`&#22;`|SYN|Synchronize|
|23|17|00010111|`&#23;`|ETB|End of Transmission Block|
|24|18|00011000|`&#24;`|CAN|Cancel|
|25|19|00011001|`&#25;`|EM|End of Medium|
|26|1A|00011010|`&#26;`|SUB|Substitute|
|27|1B|00011011|`&#27;`|ESC|Escape|
|28|1C|00011100|`&#28;`|FS|File Separator|
|29|1D|00011101|`&#29;`|GS|Group Separator|
|30|1E|00011110|`&#30;`|RS|Record Separator|
|31|1F|00011111|`&#31;`|US|Unit Separator|
|32|20|00100000|`&#32;`|space|Space|
|33|21|00100001|`&#33;`|!|exclamation mark|
|34|22|00100010|`&#34;`|"|double quote|
|35|23|00100011|`&#35;`|#|number|
|36|24|00100100|`&#36;`|$|dollar|
|37|25|00100101|`&#37;`|%|percent|
|38|26|00100110|`&#38;`|&|ampersand|
|39|27|00100111|`&#39;`|'|single quote|
|40|28|00101000|`&#40;`|(|left parenthesis|
|41|29|00101001|`&#41;`|)|right parenthesis|
|42|2A|00101010|`&#42;`|*|asterisk|
|43|2B|00101011|`&#43;`|+|plus|
|44|2C|00101100|`&#44;`|,|comma|
|45|2D|00101101|`&#45;`|-|minus|
|46|2E|00101110|`&#46;`|.|period|
|47|2F|00101111|`&#47;`|/|slash|
|48|30|00110000|`&#48;`|0|zero|
|49|31|00110001|`&#49;`|1|one|
|50|32|00110010|`&#50;`|2|two|
|51|33|00110011|`&#51;`|3|three|
|52|34|00110100|`&#52;`|4|four|
|53|35|00110101|`&#53;`|5|five|
|54|36|00110110|`&#54;`|6|six|
|55|37|00110111|`&#55;`|7|seven|
|56|38|00111000|`&#56;`|8|eight|
|57|39|00111001|`&#57;`|9|nine|
|58|3A|00111010|`&#58;`|:|colon|
|59|3B|00111011|`&#59;`|;|semicolon|
|60|3C|00111100|`&#60;`|<|less than|
|61|3D|00111101|`&#61;`|=|equality sign|
|62|3E|00111110|`&#62;`|>|greater than|
|63|3F|00111111|`&#63;`|?|question mark|
|64|40|01000000|`&#64;`|@|at sign|
|65|41|01000001|`&#65;`|A||
|66|42|01000010|`&#66;`|B||
|67|43|01000011|`&#67;`|C||
|68|44|01000100|`&#68;`|D||
|69|45|01000101|`&#69;`|E||
|70|46|01000110|`&#70;`|F||
|71|47|01000111|`&#71;`|G||
|72|48|01001000|`&#72;`|H||
|73|49|01001001|`&#73;`|I||
|74|4A|01001010|`&#74;`|J||
|75|4B|01001011|`&#75;`|K||
|76|4C|01001100|`&#76;`|L||
|77|4D|01001101|`&#77;`|M||
|78|4E|01001110|`&#78;`|N||
|79|4F|01001111|`&#79;`|O||
|80|50|01010000|`&#80;`|P||
|81|51|01010001|`&#81;`|Q||
|82|52|01010010|`&#82;`|R||
|83|53|01010011|`&#83;`|S||
|84|54|01010100|`&#84;`|T||
|85|55|01010101|`&#85;`|U||
|86|56|01010110|`&#86;`|V||
|87|57|01010111|`&#87;`|W||
|88|58|01011000|`&#88;`|X||
|89|59|01011001|`&#89;`|Y||
|90|5A|01011010|`&#90;`|Z||
|91|5B|01011011|`&#91;`|[|left square bracket|
|92|5C|01011100|`&#92;`|\|backslash|
|93|5D|01011101|`&#93;`|]|right square bracket|
|94|5E|01011110|`&#94;`|^|caret / circumflex|
|95|5F|01011111|`&#95;`|_|underscore|
|96|60|01100000|`&#96;`|`|grave / accent|
|97|61|01100001|`&#97;`|a||
|98|62|01100010|`&#98;`|b||
|99|63|01100011|`&#99;`|c||
|100|64|01100100|`&#100;`|d||
|101|65|01100101|`&#101;`|e||
|102|66|01100110|`&#102;`|f||
|103|67|01100111|`&#103;`|g||
|104|68|01101000|`&#104;`|h||
|105|69|01101001|`&#105;`|i||
|106|6A|01101010|`&#106;`|j||
|107|6B|01101011|`&#107;`|k||
|108|6C|01101100|`&#108;`|l||
|109|6D|01101101|`&#109;`|m||
|110|6E|01101110|`&#110;`|n||
|111|6F|01101111|`&#111;`|o||
|112|70|01110000|`&#112`|p||
|113|71|01110001|`&#113;`|q||
|114|72|01110010|`&#114;`|r||
|115|73|01110011|`&#115;`|s||
|116|74|01110100|`&#116;`|t||
|117|75|01110101|`&#117;`|u||
|118|76|01110110|`&#118;`|v||
|119|77|01110111|`&#119;`|w||
|120|78|01111000|`&#120;`|x||
|121|79|01111001|`&#121;`|y||
|122|7A|01111010|`&#122;`|z||
|123|7B|01111011|`&#123;`|{|left curly bracket|
|124|7C|01111100|`&#124;`|\||vertical bar|
|125|7D|01111101|`&#125;`|}|right curly bracket|
|126|7E|01111110|`&#126;`|~|tilde|
|127|7F|01111111|`&#127;`|DEL|delete|

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

695
content/notes/c-language.md Normal file
View File

@@ -0,0 +1,695 @@
---
tags:
- notes
- programming
- c
author: TrudeEH
showToc: true
title: C Language
description:
draft: false
---
## Tools
- `indent` (format code)
- `gcc` / `clang` (compile code)
- `man <function>` (see function documentation)
- `tldr <command>` (quick command usage examples)
- `valgrind` (Look for memory leaks)
- `valgrind —tool=massif` (check a program's RAM usage)
- View the output with `Massif-Visualizer`
- `gdb` (debugger)
- `gdb —args <program>` (if the program has command line args)
- Type `run` to start debugging, and `backtrace` for error details.
- `file` Check file information and, if it is an executable, compilation details.
- `perf stat -r 10 -d <program>` Benchmark a program.
## Data Types and Variables
The binary length of each data type depends on the CPU, OS, and compiler, but in general, they follow the C specifications. To check the exact values for your platform, see `limits.h`.
| Type | C SPEC | x64 Linux (Example) |
| ------------- | --------- | ------------------- |
| `char` | ≥ 8 bits | 8 bits |
| `short` | ≥ 16 bits | 16 bits |
| `int` | ≥ 16 bits | 32 bits |
| `long` | ≥ 32 bits | 64 bits |
| `long long` | ≥ 64 bits | 64 bits |
| `float` | | 32 bits |
| `double` | | 64 bits |
| `long double` | | 128 bits |
| Unsigned Bytes (8 bits) | Maximum Decimal Value |
| ----------------------- | --------------------------------------------------- |
| 1 | 255 |
| 2 | 65.535 |
| 4 | 4.294.967.295 |
| 8 | 18.446.744.073.709.551.615 |
| 16 | 340.282.366.920.938.463.463.374.607.431.768.211.455 |
| 32 | 1.157 × 10^76 |
Examples
```C
char a = 'C'; // single character %c ''
char b[] = "Trude" // array of characters %s ""
unsigned int // Unsigned. The number must be positive.
int // Signed. Negative and positive numbers.
char f = 100; // %d (number) %c (character)
unsigned char g = 255; // %d (number) %c (character)
short h = 32767; // %d
unsigned short i = 65535; // %d
int j = 2147483647; // %d
unsigned int k = 4294967295; // %u
long long l = ... // %lld
unsigned long long m = ...32U // %llu
float c = 3.141592; // %f
double d = 3.141592653589793; // %lf
```
### Format Specifiers
These format codes indicate which data type is being used. They are needed for `printf` and `scanf`, for example.
| `%` | Description |
| ------ | ------------------------------------------- |
| `%%` | `%` |
| `%-` | left align |
| `%.1` | decimal precision |
| `%1` | minimum field width |
| `%c` | character |
| `%d` | signed integer of base 10 |
| `%e` | scientific notation |
| `%f` | float |
| `%hd` | small decimal (short) |
| `%hhd` | very small decimal (char) |
| `%i` | integer of any base (detects automatically) |
| `%lf` | double |
| `%o` | octal (base 8) |
| `%p` | address/pointer |
| `%s` | string (array of characters) |
| `%u` | unsigned integer of base 10 |
| `%x` | hexadecimal (base 16) |
```C
float item1 = 5.75;
printf("Item1: %-8.2\n", item1);
```
## Numbers
`C` can handle multiple numeric bases.
```C
int x = 255; // Decimal
int y = 0xff; // Hexadecimal
```
### Type Casting
Convert a type into another.
```C
int x = 1, y = 10;
float z = (float) x / (float) y;
```
## Escape Sequences
Escape sequences are used to allow typing characters in a string that would otherwise be interpreted as `C` instructions.
| Seq | Name | Description |
| ------ | ------------------ | -------------------------------------------------------------------------------------- |
| `\a` | Alarm or Beep | It is used to generate a bell sound in the C program. |
| `\b` | Backspace | It is used to move the cursor one place backward. |
| `\f` | Form Feed | It is used to move the cursor to the start of the next logical page. |
| `\n` | New Line | It moves the cursor to the start of the next line. |
| `\r` | Carriage Return | It moves the cursor to the start of the current line. |
| `\t` | Horizontal Tab | It inserts some whitespace to the left of the cursor and moves the cursor accordingly. |
| `\v` | Vertical Tab | It is used to insert vertical space. |
| `\\` | Backlash | Use to insert backslash character. |
| `\'` | Single Quote | It is used to display a single quotation mark. |
| `\"` | Double Quote | It is used to display double quotation marks. |
| `\?` | Question Mark | It is used to display a question mark. |
| `\ooo` | Octal Number | It is used to represent an octal number. |
| `\xhh` | Hexadecimal Number | It represents the hexadecimal number. |
| `\0` | `NULL` | It represents the NULL character. |
| `\e` | Escape sequence | It represents the ASCII escape character. |
| `\s` | Space Character | It represents the ASCII space character. |
| `\d` | Delete Character | It represents the ASCII DEL character. |
## Constants
Add `const` before a variable declaration to prevent the value from being changed.
```C
const float PI 3.14159;
```
Another option is to use `define`.
```C
#define MAX 9
```
This command replaces the 'MAX' word with '9', using the preprocessor (before compiling). No extra memory required.
## Arithmetic Operators
```C
// + (addition)
// - (subtraction)
// * (multiplication)
// / (division)
// % (modulus / remainder)
// ++ (increment)
// -- (decrement)
int x = 1;
int y = 2;
int z = x + y; // 3
// Augmented assignment operators
x++; // x = x + 1
y--; // y = y - 1
x+=2; // x = x + 2
x*=2; // x = x * 2
```
## Control Flow
### Boolean Values
In `C`, there are no `true` or `false` keywords, so integers are used instead.
- `0` generally represents `false`.
- Any non-zero value (`1`, `-1`, etc…) represents `true`.
### IF Statement
```C
if(a == 1) printf("A is 1.\\n");
```
Use `{}` for multiple items.
```C
if(age == 18){
printf("You are 18.");
}
else if(age < 0){
printf("You haven't been born yet.");
}
else{
printf("You are not 18.");
}
```
### Switch Statement
Faster than IF when over 5 cases.
```C
switch(grade){
case 'A':
printf("perfect.\n");
break;
case 'B':
printf("good.\n");
break;
case 'C':
printf("okay.\n");
break;
case 'D':
printf("meh.\n");
break;
case 'F':
printf("failed.\n");
break;
default:
printf("Enter only valied grades.\n");
}
// If break; is missing, the next case is also executed.
```
## Operators
### Logical Operators
#### AND (`&&`)
```C
if(temp >= 0 && temp <= 30){
printf("\nThe weather is good.")
}
```
#### OR (`||`)
```C
if(temp <= 0 || temp >= 30){
printf("\nThe weather is good.")
}
```
#### NOT (`!`)
```C
if(!(temp <= 0 || temp >= 30)){
printf("\nThe weather is bad.")
}
```
##### **NOT** Truth Table
| `condition` | `!(condition)` |
| ----------- | -------------- |
| 1 | 0 |
| 0 | 1 |
### Ternary Operator
Shorthand syntax for if/else when assigning or returning a value.
```C
// (condition) ? value if true : value if false
int max = (x > y) ? x : y;
```
### Bitwise Operators
Special operators used in bit-level programming. (Logic gates)
```C
int x = 6; // 6 = 00000110
int y = 12; // 12 = 00001100
int z = 0; // 0 = 00000000
z = x & y; // AND - 00000100 (4)
z = x | y; // OR - 00001110 (14)
z = x ^ y; // XOR - 00001010 (10)
z = x << 1; // Left Shift - 00001100 (12) (Shift all bits to the left.)
z = x >> 1; // Right Shift - 00000011 (3) (Shift all bits to the right.)
```
## Functions
Functions are snippets of code that can be reused multiple times across the same file. These can receive multiple arguments as input, but can only return a single value.
```C
void myFunction(); // Function Prototype
int main() {
myFunction(); // Call function
return 0;
}
void myFunction() { // Function Definition
//...
}
```
### Arguments
```C
void greet(char x[], int y);
int main() {
char name[] = "Trude";
int age = 132;
greet(name, age);
}
void greet(char x[], int y) {
printf("\nHello %s, you are %d years old.", x, y);
}
```
### Return Values
```C
double square(double x);
int main() {
double x = square(3.14);
printf("%lf", x);
return 0;
}
double square(double x) {
return x * x;
}
```
### Recursion
A function can call itself, creating a loop.
```C
int i = 0;
void plusOne(int n) {
printf("%d", n);
if (n < 10000) plusOne(n);
}
```
### Function Prototypes
Function declaration without a body, before `main()`.
Prototypes ensure that calls to a function are made with the correct arguments, and allow functions to be defined under the function call.
```C
void hello(char[], int); // Function Prototype
int main() {
hello(//...);
return 0;
}
void hello(char name[], int age){
//...
}
```
> **Note:** Many C compilers don't check for parameter matching, so missing arguments can lead to unexpected behavior.
>
> Function prototypes flag errors when arguments are missing.
>
> While not necessary if functions are declared before `main()`, using prototypes first and then declaring functions after `main()` improves readability and aids debugging.
## Loops
### For Loop
Loop through an interval.
```C
for(int i = 0; i < 10; i++){
printf("%d\n", I); //0-9
}
//Multiple initial variables
for(int i = 0, int y = 1; i < 10; i++){
printf("%d\n", I); //0-9
}
```
### While Loop
Loop until a condition is met.
```C
while(test == 1){
printf("Test is not 1.\n");
}
```
### Do While Loop
Run the code once, then repeat until a condition is met.
```C
do {
printf("Enter a number above 0: ");
scanf("%d", &number)
} while (number > 0);
```
### Endless Loop
```C
while (true) {
...
}
```
### Continue & Break Statements
- `continue` - Skips rest of code and forces the next iteration of the loop.
- `break` - Exits a loop/switch.
## Structs
Structs can group values. They are similar to classes, but can't hold methods.
Being able to group variables avoids repetition and name collision (when two variables have the same name).
```C
struct Player {
char name[12];
int score;
};
int main(){
struct Player player1;
struct Player player2;
strcpy(player1.name, "Trude");
player1.score = 4;
strcpy(player2.name, "JCionx");
player2.score = 7;
player1.score; //4
}
```
### Arrays of Structs
```C
struct Student {
char name[12];
float gpa;
};
int main() {
struct Student s1 = {"Peter", 3.0};
struct Student s2 = {"Jean", 4.0};
struct Student s3 = {"David", 2.5};
struct Student students[] = {s1, s2, s3};
printf("%f\n", students[0].gpa); // Print the student 1 gpa.
return 0;
}
```
## Typedef
Create a shortcut for a type of data.
```C
typedef char user[25];
int main() {
user user1 = "Trude";
}
```
Typedef can be used to simplify structs.
```C
typedef struct {
char name[25];
char password[12];
int id;
} User;
int main(){
User user1 = {"Trude", "hello123", 12335};
}
```
## Nul Character
```C
\0 // This character represents 00000000 and marks the end of a string.
// Same as 0x0 and null.
```
## Command-Line Arguments
- `argc` is the number of arguments in `argv`.
- `argv[0]` is the name of the program, all others are the user arguments.
```C
int main(int argc, char argv[]) {
if (argc == 2) {
printf("hello, %s\n", argv[1]);
} else {
printf("You need to add 1 argument.\n");
return 1;
}
return 0;
}
```
## Enums
Enums are a list of constant values that help make programs more readable.
Enums are treated as integers.
```C
// enum Day{Sun, Mon, Tue, Wed, Thu, Fri, Sat}; (This enum starts from 0 to 6.)
enum Day{Sun = 1, Mon = 2, Tue = 3, Wed = 4, Thu = 5, Fri = 6, Sat = 7};
int main(){
enum Day today = Sun;
if(today == Sun || today == Sat){
printf("It's the weekend.");
}
}
```
## Memory Management
- `a` - A variable
- `&a` - The address of the variable `a` in memory. (The format is `%p`)
- `int *p` - A pointer. Holds the memory address of another variable. (8 bits usually, depends on the CPU architecture (max RAM supported).
- `*p` - Dereference a pointer. Returns the value in the address stored. (go to address's variable)
```C
int age = 21;
int *pAge = &age;
int valueOfAge = *pAge;
printf("%p and %p are the same.", &age, pAge);
```
NOTE: A pointer must be `int`, as it points to a memory address.
### Strings
Strings are arrays of characters.
A string can be returned as a memory address.
A string ends in `\0`, the null character.
```C
/* Use char[] when:
- The maximum string length is known.
- No need to modify the whole string.
- No need to pass the string to a function [that modifies it]
*/
char name[] = "Trude"; // 6 bits on stack memory.
name[0] = 'T'; // Elements of an array can be modified.
/* Use char* when:
- The maximum string length is NOT known.
- The string will later be modified.
- The string will be passed to a function [that modifies it].
*/
const char *name = "Trude"; // 8 bits in stack + 6 bits read-only.
name = "TrudeEH"; // Pointers can be overwritten.
name++; // rudeEH - Works because the pointer is shifted to the next value.
peintf("%c\n", *(name+1)); // Prints 'r'.
printf("%c\n", name[1]); // Works with both for reading.
printf("%s\n", name); // Print a string.
// The string in memory:
// [T][r][u][d][e][\\0]
// The memory address of T is stored.
```
### String Operations
#### Compare String
```C
#include <stdio.h>
#include <string.h>
char s* = "Trude";
char t* = "Trude";
if (strcmp(s, t) == 0) {
printf("Same string.");
}
```
#### Copy String (`malloc` example) Manually
```C
#include <stdlib.h>
char *s = "Trude";
char *t = malloc(strlen(s) + 1);
// 2 variables are declared, so strlen isn't called with every iteration.
for (int i = 0, n = strlen(s) + 1; i < n; i++) {
t[i] = s[i];
)
//...
free(t);
```
#### Copy String (string.h)
```C
#include <stdlib.h>
#include <string.h>
char *s = "Trude";
char *t = malloc(strlen(s) + 1);
strcpy(t, s);
//...
free(t);
```
Note: Use `valgrind` to detect memory leaks (lack of `free()`)
> **Always** initialize variables to a value, or random garbage values may be still in the variable's memory address.
### Input
#### Get Integer
```C
#include <stdio.h>
int main(void){
int x;
scanf("%i", &x);
}
```
#### Get String (Length is Known, safe)
`scanf` reads up to a whitespace.
```C
#include <stdio.h>
int main(void){
char s[4];
scanf("%4s", s); //No &, s is an address already.
}
```
`fgets` reads whitespaces.
```C
#include <stdio.h>
#include <string.h>
int age;
char name[25];
printf("What is your name? ");
fgets(name, 25, stdin); // name of variable, max size, input.
name[strlen(name)-1] = '\0'; // removes the line break fgets adds. String library is required.
printf("How old are you? ");
scanf("%d", &age);
```
## Files
### Write to a File
```C
#include <stdio.h>
int main() {
FILE *file = fopen("test.txt", "w"); // w - overwrite / a - append
fprintf(file, "Some Text");
fclose(file);
return 0;
}
```
### Delete a File
```C
#include <stdio.h>
int main() {
if(remove("test.txt") == 0){
printf("File removed.\n");
} else {
printf("Failed to delete file.\n");
}
return 0;
}
```
### Read a File
```C
#include <stdio.h>
int main() {
FILE *pF = fopen("test.txt", "r") // r - read.
char buffer[255]; // Will hold 1 line of the file.
if(pF == NULL){
printf("File does not exist.");
return 1;
}
fgets(buffer, 255, pF);
printf("%s", buffer); // Print first line of file. Use in a while loop to print all of them.
fclose(pF);
return 0;
}
```
File manipulation accepts relative and absolute file paths.

View File

@@ -0,0 +1,38 @@
---
tags:
- notes
- programming
- c
author: TrudeEH
draft: false
showToc: true
title: C Snippets
---
## Cast Strings to Numbers
The `atoi()` function in `stdlib` has a similar implementation to the one below.
ASCII encodes numbers in order, after special characters.
The encoded value for `'0'` is 48, so subtracting any numeric char by 48 outputs its real numerical value.
```C
char number = '7';
int result = number - 48;
int same_result = number - '0';
```
Algorithm to convert strings to numbers:
```C
int str_to_int(char *str) {
int result = 0;
for (int i = 0; str[i] != '\0'; i++) {
if (str[i] < '0' && str[1] > '9') return -1; // Error if NaN
result = (result * 10) + (str[i] - '0');
return result;
}
```
`(result * 10)` is shifting the previous number to the left, as it is an order of magnitude above the following digit.

View File

@@ -0,0 +1,76 @@
---
tags:
- notes
- programming
author: TrudeEH
draft: false
showToc: true
title: Compiling [MAKE / GCC]
---
Convert `C` code into machine code in 4 steps:
1. **Preprocessing** (Convert all preprocessor instructions: `#…`)
2. **Compiling** (Convert `C` code to machine code)
3. **Assembling** (Compile the necessary libraries)
4. **Linking** (Merge the compiled code with the compiled libraries)
## Libraries
Libraries are pre-written collections of code that can be reused in other programs. On **UNIX* systems, they are usually located in the `/lib/` and `/usr/include` directories.
### Math.h
For example, `math.h` is very useful to implement complex arithmetic operations.
```C
#include <math.h>
double A = sqrt(9);
double B = pow(2, 4);
int C = round(3.14);
int D = ceil(3.14);
int E = floor(3.99);
double F = fabs(-100);
double G = log(3);
double H = sin(45);
double I = cos(45);
double J = tan(45);
```
### Using Libraries
To use a library, we first have to include it in the `C` code.
```C
#include <cs50.h> // cs50.h library will be included.
```
Then, the library must be linked at compile time.
```Shell
gcc -o hello hello.c -lcs50
./hello
```
## Optimization Flags
- `-O2` Optimize for speed
- `-O3` Optimize for speed aggressively
- `-Os` Optimize for size
- `-Og` Optimize for debugging
- `-Oz` Optimize for size aggressively
## Make
`Make` Is a build automation tool that automates the process of compiling, linking and building executables.
An example `Makefile` could look like the following:
```Makefile
hello:
gcc -o hello hello.c -lcs50
clean:
rm -f hello
```
```Shell
make #Compiles hello.c
make clean #Removes the executable (hello) generated by the make command.
```

117
content/notes/encryption.md Normal file
View File

@@ -0,0 +1,117 @@
---
tags:
- networking
- notes
- tools
author: TrudeEH
draft: false
showToc: true
title: Encryption [GPG]
---
## Symmetric Encryption
- User A sends a password to user B.
- The password is used to encrypt the messages.
- A secure way to share the password is required.
## Asymmetric Encryption
- Users A and B have a public key and a private key.
- The public keys are shared, and they are used to encrypt the messages.
- The users can use their private keys to decrypt the messages.
## GPG
### Create a Set of Keys
```Shell
gpg --full-gen-key
Select ECC (sign and encrypt) - The most secure option
Select default curve
```
### Encrypt a File
```Shell
gpg --encrypt -r email@example.org <file> # Encrypt with the recipient (-r) key.
```
### Decrypt a File
```Shell
gpg --decrypt --output <file-output> <file> # Use the private key to decrypt a file.
```
### Encrypt a Message
```Shell
echo "Very safe message" | --encrypt --armor -r email@example.org
```
- `-armor` Saves the encrypted info in plain text. (Great for blog posts or copying/pasting)
### Decrypt a Message
GPG automatically figures out which private key to use. The encrypted file includes some metadata.
```Shell
cat encrypted-message.txt | gpg --decrypt
```
### Sign a Message
Uses a public key to sign a message, making sure that the contents are not tampered with.
```Shell
echo "Very important message" | gpg --clearsign -u email@example.org
```
- `-clearsign` Is used to sign plain (clear) text.
### Sign a File
The signature is embedded in the file
```Shell
gpg --sign -u email@example.org <file>
```
The signature is separate from the file
```Shell
gpg --detach-sign -u email@example.org <file>
```
### Verify Signed message/file
```Shell
gpg --verify signed-message.txt
# or, if detached
gpg --verify <file.sig> <file>
```
### Import
```Shell
gpg --import public.pgp
gpg --import private.pgp
# To be able to use the key for encryption, it must be trusted.
gpg --edit-key email@example.com
> trust
> 5
```
### Export
```Shell
gpg --output public.pgp --armor --export email@example.com
gpg --output private.pgp --armor --export-secret-keys email@example.com
```
### List Keys
```Shell
gpg --list-keys # Same as gpg -k
gpg --list-secret-keys
```

345
content/notes/flask.md Normal file
View File

@@ -0,0 +1,345 @@
---
tags:
- notes
- programming
- web
author: TrudeEH
draft: false
showToc: true
title: Flask
---
Flask is a web framework for Python. It facilitates the creation of web apps (dynamic web pages).
## Run Flask
Flask comes with its own server for debugging purposes, which can be started with:
```Bash
flask run
```
## Folder Structure
```Bash
app.py # main code
requirements.txt # required libraries
static/ # files that never change
templates/ # dynamic files
```
## "Hello, name" — Example App
**templates/index.html**
```HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta name = "viewport" content="initial-scale=1, width=device-width">
<title>Hello</title>
</head>
<body>
hello, {{ name_placeholder }} <!-- Jinja template -->
</body>
</html>
```
**app.py**
`http://website.domain/?name=Trude`
```Python
from flask import Flask, render_template, request
app = Flask(__name__)
# When user visits / (the website root), load index.html.
# If the key name exists, store the value in a variable. If not, store world.
@app.route("/")
def index():
name = request.args.get("name", "world")
return render_template("index.html", name_placeholder=name)
```
## HTML Form
### Sample App
**templates/index.html**
```HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta name = "viewport" content="initial-scale=1, width=device-width">
<title>Hello</title>
</head>
<body>
<form>
<input autocomplete="off" autofocus name="name" placeholder="Name" type="text">
<button type="submit">Greet</button>
</form>
</body>
</html>
```
**app.py**
`http://website.domain/?name=Trude`
```Python
from flask import Flask, render_template, request
app = Flask(__name__)
# When user visits / (the website root), load index.html.
# If the key name exists, store the value in a variable. If not, store world.
@app.route("/")
def index():
name = request.args.get("name", "world")
return render_template("index.html", name_placeholder=name)
```
### Custom Route
Both the form and /greet works.
**templates/index.html**
```HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta name = "viewport" content="initial-scale=1, width=device-width">
<title>Hello</title>
</head>
<body>
<form action="/greet" method="get">
<input autocomplete="off" autofocus name="name" placeholder="Name" type="text">
<button type="submit">Greet</button>
</form>
</body>
</html>
```
**templates/greet.html**
```HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta name = "viewport" content="initial-scale=1, width=device-width">
<title>Hello</title>
</head>
<body>
hello,{{name}}
</body>
</html>
```
**app.py**
`http://website.domain/?name=Trude`
```Python
from flask import Flask, render_template, request
app = Flask(__name__)
# When user visits / (the website root), load index.html.
# If the key name exists, store the value in a variable. If not, store world.
@app.route("/")
def index():
name = request.args.get("name", "world")
return render_template("index.html", name_placeholder=name)
@app.route("/greet")
def greet():
return render_template("greet.html", name=request.args.get("name", "world"))
```
### Avoid HTML Repetition
Use a layout instead of copying blocks.
**templates/index.html**
```HTML
{% extends "layout.html" %}
{% block body %}
<form action="/greet" method="get">
<input autocomplete="off" autofocus name="name" placeholder="Name" type="text">
<button type="submit">Greet</button>
</form>
{% endblock %}
```
**templates/greet.html**
```HTML
{% extends "layout.html" %}
{% block body %}
hello, {{name}}
{% endblock %}
```
**templates/layout.html**
```HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta name = "viewport" content="initial-scale=1, width=device-width">
<title>Hello</title>
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
```
**app.py**
`http://website.domain/?name=Trude`
```Python
from flask import Flask, render_template, request
app = Flask(__name__)
# When user visits / (the website root), load index.html.
# If the key name exists, store the value in a variable. If not, store world.
@app.route("/")
def index():
name = request.args.get("name", "world")
return render_template("index.html", name_placeholder=name)
@app.route("/greet")
def greet():
return render_template("greet.html", name=request.args.get("name", "world"))
```
### Hide Sensitive Requests from the URL
Use post instead of get.
**templates/index.html**
```HTML
{% extends "layout.html" %}
{% block body %}
<form action="/greet" method="post">
<input autocomplete="off" autofocus name="name" placeholder="Name" type="text">
<button type="submit">Greet</button>
</form>
{% endblock %}
```
**templates/greet.html**
```HTML
{% extends "layout.html" %}
{% block body %}
hello, {{name}}
{% endblock %}
```
**templates/layout.html**
```HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta name = "viewport" content="initial-scale=1, width=device-width">
<title>Hello</title>
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
```
**app.py**
`http://website.domain/greet`
The name doesn't appear in the URL anymore.
```Python
from flask import Flask, render_template, request
app = Flask(__name__)
# When user visits / (the website root), load index.html.
# If the key name exists, store the value in a variable. If not, store world.
@app.route("/")
def index():
name = request.args.get("name", "world")
return render_template("index.html", name_placeholder=name)
@app.route("/greet", methods=["POST"])
def greet():
return render_template("greet.html", name=request.form.get("name", "world"))
```
### Combine Routes to save Resources
GET is always the default.
POST is used to send information to the server.
**templates/index.html**
```HTML
{% extends "layout.html" %}
{% block body %}
<form action="/" method="post">
<input autocomplete="off" autofocus name="name" placeholder="Name" type="text">
<button type="submit">Greet</button>
</form>
{% endblock %}
```
**templates/greet.html**
```HTML
{% extends "layout.html" %}
{% block body %}
hello, {{name}}
{% endblock %}
```
**templates/layout.html**
```HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta name = "viewport" content="initial-scale=1, width=device-width">
<title>Hello</title>
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
```
**app.py**
`http://website.domain/`
```Python
from flask import Flask, render_template, request
app = Flask(__name__)
# When user visits / (the website root), load index.html.
# If the key name exists, store the value in a variable. If not, store world.
@app.route("/", methods=["GET, POST"])
def index():
if request.method == "GET":
return render_template("index.html")
elif request.method == "POST":
return render_template("greet.html", name=request.form.get("name", "world"))
```
## Cookies - Session
Used to store data and to recognize the user.
- Server → Client
- `Set-Cookie session=value`
- Client → Server
- `Cookie session`
```Python
from flask import session
# Configure app
app = Flask(__name__)
# Configure session
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)
# Redirect to login if no cookie exists
@app.route("/")
def index():
if not session.get("name"):
return redirect("/login")
return render_template("index.html")
# EXAMPLES
# session is a dictionary
session["cart"] = []
books = db.execute("SELECT * FROM books WHERE id IN (?)", session["cart"])
```

358
content/notes/git.md Normal file
View File

@@ -0,0 +1,358 @@
---
tags:
- notes
- programming
- tools
author: TrudeEH
draft: false
showToc: true
title: Version Control [GIT]
---
Git is a version control system first developed by Linus Torvalds. It facilitates collaboration on large projects, keeps track of changes, and allows mistakes to be rolled back into a previous state.
## Configure Git
Git uses a hierarchy of configuration files:
- **System**: (`/etc/gitconfig`) Configuration for all users in a system.
- **Global**: (`~/.gitconfig`) Configure Git for all project of the current user.
- **Local**: (`.git/config`) Configure Git for the current project.
- **Worktree**: (`.git/config.worktree`) Configure part of a project.
```Shell
# Check if user name and email are set.
git config --get user.name
git config --get user.email
# If not, set those values.
git config --add --global user.name "username"
git config --add --global user.email "email@example.com"
git config --add --global init.defaultBranch main # GitHub's default
git config --unset example.key # Remove a configuration value
git config --unset-all example.key # Remove all instances of a configuration key
git config --remove-section section # Remove an entire section
# Rebase on pull by default to keep a linear history
git config --global pull.rebase true
```
## Create a Repository
Git stores all project information in the `.git` directory. This includes branches, commits, and metadata.
```Shell
mkdir project && cd project
git init
```
## Status
A file can be in one of several states in a Git repository.
- `untracked`: Not being tracked by Git
- `staged`: Marked to be included in the next commit
- `committed`: Saved to the repository's history
```Shell
git status # Shows he state of a repository.
```
## Staging
Untracked files need to be indexed before being committed.
```Shell
git add filename.ext # Add a file
git add . # Add every file in the current directory, recursively.
```
## Commit
A commit is a snapshot of the entire repository at a given point in time. Each commit has a message that describes the changes made in that commit.
To commit all staged files:
```Shell
git commit -m "message" # Commit all staged files
git commit --amend -m "message" # Replace the last commit's message
```
## Git Log
The `git log` command shows the history of commits in a repository. It provides information on who made a commit, when it was made, and what files were changed.
Each commit also has a unique identifier (commit hash).
For example, this is a valid commit hash: `46a4b5904d4ad737447052fed90c754ce8c616b6`.
Since these identifiers are very long, they are often shortened to their first `7` characters (`46a4b59` in this example).
```Shell
git log # Show the log in an interactive pager
git --no-pager log -n 10 # Show the last 10 lines from the log, without using the pager
git log -1 # Fetch the header of the first commit
git log --decorate=full # Shows the full pointer to a commit
git log --decorate=no # Don't show branch names
git log --oneline # Show each commit in a single line. ("compact" mode)
git reflog # History of actions. Commits, clone, pull, etc.
```
## Git Diff
Show differences:
```Shell
git diff # Differences between the working tree and the last commit
git diff HEAD~1 # Same, but includes the last commit and uncommitted changes
git diff COMMIT_HASH_1 COMMIT_HASH_2 # Differences between two commits
```
## Git Tags
A tag is a name linked to a commit that doesn't move between commits. Useful to mark versions.
```Shell
git tag # List the current tag
git tag -a "tag name" -m "tag message" # Add a new tag
git tag -a v3.10.2 -m "Fixed a lil bug" # Example marking a release
```
### Semantic Versioning (Semver)
Naming convention for versioning software.
```Plain
v3.12.5
| | |
| | Patch (safe bug fixes)
| Minor (safe features)
Major (breaking changes)
```
## Branch
A Git branch allows you to keep track of different changes separately.
```Plain
D - E other_branch
/
A - B - C main
```
```Shell
git branch # Check which branches are available, and which one is selected
git branch -m oldname newname # Rename a branch
git branch my_new_branch # Create a new branch
git switch -c my_new_branch # Create a new branch and switch to it immediately
git switch branch_name # Switch to an existing branch
git checkout branch_name # Deprecated alternative to git switch
git branch -d branch_name # Delete a branch
```
### Merge
After modifying a new branch, all commits performed on it can be merged into the main branch.
```Plain
A - B - C - F main
\ /
D - E other_branch
```
```Shell
git log --oneline --graph --all # Show an ASCII representation of the commit history
git log --oneline --decorate --graph --parents # Also display any parent branches
git merge branch_name # Merge a branch into the current branch
```
### Rebase
After a branch is created, it might fall behind its origin. A rebase includes the new changes from the origin into the current branch, without leaving a merge message behind. While merging can often accomplish the same task, a rebase keeps history linear and makes it easier to read. It's recommended to use it on the main branch, for example, when updating smaller ones.
Before a rebase, the commit history might have the following structure:
```Plain
A - B - C main
\
D - E feature_branch
```
After a rebase, the target branch is updated against its origin:
```Plain
A - B - C main
\
D - E feature_branch
```
```Shell
git rebase origin_name # Rebase against the origin
```
> You should *never* rebase a public branch (like `main`) onto anything else, to not break commit history.
### Conflicts
If a modified is pushed to another branch where that same file has been modified as well, a conflict arises. These can be fixed manually by editing text, or using Git commands.
```Shell
git checkout --theirs path/to/file # Discard the current branch's changes and accept the target's changes
git checkout --ours path/to/file # Discard the target changes and replace with the ones in the current branch
git reset --soft HEAD~1 # Undo an accidental conflict resolution
```
### Squash
Combine various commits into one:
1. Start an interactive rebase with the command `git rebase -i HEAD~n`, where `n` is the number of commits you want to squash.
2. Git will open your default editor with a list of commits. Change the word `pick` to `squash` for all but the first commit.
3. Save and close the editor.
> If the squashed commits already existed in the remote repository, it might be needed to push using: `git push origin main --force`.
### Stash
`git stash` saves the state of the current working directory and the index (staging area), then returns the repository to `HEAD`. This allows you to work on a different issue, and then resume your previous task.
```Shell
git stash
git stash -m "message" # It's also possible to stash with a message
git stash list # List all stashes
git stash pop # Apply the most recent stash to the working directory
git stash apply # Same as before, but doesn't delete the stash after applying
git stash drop # Discard a stash without applying changes
git stash apply stash@{2} # Apply the third most recent stash
```
### Worktrees
The directory where the code tracked with Git lives. (And where the `.git` directory is located).
Use instead of a `stash` if the current worktree is too busy, or for long-lived changes. This acts like cloning the repo again and working there, except it doesn't take up space on the host machine.
Any change done on a linked worktree is reflected on the main one instantly. Think of it as a different view of the main worktree.
```Shell
git worktree list # Lists worktrees
git worktree add <path> [<branch>] # Create a worktree linked to the main one
git worktree remove WORKTREE_NAME # Remove a worktree
git worktree prune # Remove an empty worktree if its directories were removed
```
### Bisect
Find a specific commit with binary tree search.
For example, if trying to find a bug in 100 commits, `git bisect` allows it to be found with only `7` attempts.
1. `git bisect start`
2. Use: `git bisect good <commitish>` to select a commit where the bug wasn't introduced yet.
3. Select a commit where the bug exists using: `git bisect bad <commitish>`.
4. Git will checkout a commit between the good and bad commits for you to test to see if the bug is present.
5. Execute `git bisect good` or `git bisect bad`.
6. Loop back to step 4 (until `git bisect` completes)
7. Exit the bisect mode with `git bisect reset`
```Shell
git bisect start
git bisect good <commitish> # Select a commit where the bug wasn't introduced yet.
git bisect bad <commitish> # Select a commit where the bug exists
```
#### Automated Bisect
If you have a script that can tell if the current source code is good or bad, you can bisect by issuing the command:
```Shell
git bisect run <script> <arguments>
```
The script should exit with code `0` if the current source code is good/old, and exit with a code between `1` and `127` (inclusive), except `125`, if the current source code is bad/new.
### Cherry-Pick
Apply only the selected commit to the working directory.
```Shell
git cherry-pick <commit-hash>
```
## Undo Changes
```Shell
git reset --soft COMMITHASH # Undo the last commit, but keep its changes staged (does not delete files)
git reset --hard COMMITHASH # Undo the last commit and discard all changes (deletes files).
git reset --hard a1b2c3d # Rollback to an earlier commit, deleting all changes up to that point.
git revert COMMITHASH # Create a new commit that does the opposite of the one provided. (Reset, but keeps history)
```
### Recover a Deleted Commit
`HEAD` always keeps track of every change, including rollbacks, so it can be used to recover lost files.
```Shell
git merge HEAD@{1}
```
## Git Remote
'Remotes' are eternal repositories with a similar Git history to our local one. GitHub, for example, is a remote repository. It is not part of Git, but is often used as the "source of truth" for convenience.
If a repository is considered to be the project's "true" source, it should be named `origin`.
```Shell
git remote add <name> <uri> # Add a remote repository (local folder or external url)
git fetch # Download a copy of the origin's metadata (.git/objects)
git log remote/branch # See the log of a remote branch after fetching data
git merge remote/branch # Merge between local and remote repos
git push origin main # Push (send) local changes to the selected remote
git push origin <localbranch>:<remotebranch> # Push a local branch to a remote, with a different name
git push origin :<remotebranch> # Push an empty branch to delete the remote branch
git pull [<remote>/<branch>] # Update local repo with remote changes (downloads files).
```
### Pull Requests
Propose changes to a repository, before they are actually applies. A pull request is typically accepted by a maintainer or other team members.
### GitHub
GitHub serves several purposes:
- As a backup of all your code on the cloud in case something happens to your computer
- As a central place to share your code and collaborate on it with others
- As a public portfolio for your coding projects
```Shell
# Install GitHub CLI either through a package manager, or using the command:
curl -sS https://webi.sh/gh | sh
# Login through the browser
gh auth login
# Add a remote from GitHub
git remote add origin https://github.com/your-username/repo-name.git
# List remote repos
git ls-remote
```
#### Forks
On GitHub (and similar platforms), a repository can be forked, or, copied, to serve as the base for a future pull request.
The steps to submit a PR are usually as follows:
1. Fork their repo into your account
2. Clone your fork to your local machine
3. Create a new branch (let's call it `your_feature`)
4. Make changes
5. Commit and push changes to your fork's remote `your_feature` branch
6. Create a pull request to `original_owner/repo` `main` from `your_username/repo` `your_feature`
## `.gitignore`
Prevents the specified files from being tracked by git.
```Shell
folder_name # Ignores all directories with that name, even subdirectories of different directories
file.txt # Ignores a specific file in the current directory
folder/file.txt # Ignores a file inside a subdirectory
*.txt # Ignore all text files
/main.py # Ignore a file only in the current directory, not subdirectories
!important.txt # Track a file that would previously be ignored
```
If a file was already staged or committed, it won't be ignored, however. Use the following command to remove it from cache and ignore it on the next commit:
```Shell
git rm --cached file
```
> It's common to have `.gitignore` files in subdirectories. These only affect the directories they are inside of.
**Which files should be ignored?**
1. Ignore things that can be *generated* (e.g. compiled code, minified files, etc.)
2. Ignore dependencies (e.g. `node_modules`, `venv`, `packages`, etc.)
3. Ignore things that are personal or specific to how you like to work (e.g. editor settings)
4. Ignore things that are sensitive or dangerous (e.g. `.env` files, passwords, API keys, etc.)

200
content/notes/html.md Normal file
View File

@@ -0,0 +1,200 @@
---
tags:
- notes
- web
author: TrudeEH
draft: false
showToc: true
title: HTML
---
*HTML* is a markup language: The foundation of every website, as it structures content and provides information such as text, images and other media to the browser.
## Hello World
*HTML* is not a programming language, only formatting to write a document as. The following 'code' is valid *HTML.*
```HTML
Hello, world.
```
A more complete solution, however, would be to define a structure for the document.
```HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<p>Hello, world.</p>
</body>
</html>
```
*HTML* uses tags to define a hierarchy. The `<head>` tag defines metadata for the site, such as the page's title, encoding types, and any external resources. The `<body>` tag is the content itself: any paragraphs (`<p>`), images, forms and scripts, to name a few.
> When reading *HTML*, the browser applies a set of default styles to make it more readable. *HTML* is **not** the place to style content, however. For example, a common mistake is to use headings based on their size or font weight, instead of their meaning. Everything can all be styled using *CSS* later, so try to ignore the design when writing *HTML*, and focus on the content instead.
> Not all tags hold content, but for those that do, the end of that content is defined with a closing tag: `</tagname>`.
## Basic Tags
|Tag|Description|
|---|---|
|`<!DOCTYPE>`|Document type.|
|`<html>`|Defines an HTML document.|
|`<head>`|Contains metadata/information for the page.|
|`<title>`|Title for the page.|
|`<body>`|Defines the document's body.|
|`<h1> to <h6>`|Defines HTML headings (titles). `<h1>` is the page's title, `<h2>` is the subtitle, and so on.|
|`<p>`|Paragraph.|
|`<br>`|Inserts a single line break.|
|`<hr>`|Defines a thematic change in the content.|
|`<!--...-->`|Comment.|
## Formatting
|Tag|Description|
|---|---|
|`<abbr>`|Abbreviation or acronym.|
|`<address>`|Contact information for the author/owner of a document/article.|
|`<b>`|Bold text.|
|`<bdi>`|Isolates a part of text that might be formatted in a different direction from other text outside it.|
|`<bdo>`|Overrides the current text direction.|
|`<blockquote>`|Defines a section that is quoted from another source.|
|`<cite>`|Defines the title of a work.|
|`<code>`|Block of code.|
|`<del>`|Defines text that has been deleted from a document.|
|`<dfn>`|Specifies a term that is going to be defined within the content.|
|`<em>`|Emphasized text.|
|`<i>`|Defines a part of text in an alternate voice or mood.|
|`<ins>`|Defines a text that has been inserted into a document.|
|`<kbd>`|Keyboard input.|
|`<mark>`|Marked/highlighted text.|
|`<meter>`|Defines a scalar measurement within a known range (a gauge).|
|`<pre>`|Preformatted text.|
|`<progress>`|Represents the progress of a task.|
|`<q>`|Short quotation.|
|`<rp>`|Defines what to show in browsers that do not support ruby annotations.|
|`<rt>`|Defines an explanation/pronunciation of characters (for East Asian typography).|
|`<ruby>`|Defines a ruby annotation (for East Asian typography).|
|`<s>`|Defines text that is no longer correct.|
|`<samp>`|Defines sample output from a computer program.|
|`<small>`|Smaller text.|
|`<strong>`|Important text.|
|`<sub>`|Subscripted text: `2₂`.|
|`<sup>`|Superscripted text: `2²`.|
|`<template>`|Defines a container for content that should be hidden when the page loads.|
|`<time>`|Defines a specific time (or datetime).|
|`<u>`|Defines some text that is unarticulated and styled differently from normal text.|
|`<var>`|Variable.|
|`<wbr>`|Defines a possible line-break.|
## Forms and Input
|Tag|Description|
|---|---|
|`<form>`|Defines an HTML form for user input.|
|`<input>`|Defines an input control.|
|`<textarea>`|Defines a multiline input control (text area).|
|`<button>`|Clickable button.|
|`<select>`|Drop-down list.|
|`<optgroup>`|Defines a group of related options in a drop-down list.|
|`<option>`|Defines an option in a drop-down list.|
|`<label>`|Defines a label for an `<input>` element.|
|`<fieldset>`|Groups related elements in a form.|
|`<legend>`|Defines a caption for a `<fieldset>` element.|
|`<datalist>`|List of pre-defined options for input controls.|
|`<output>`|Defines the result of a calculation.|
## Media
|Tag|Description|
|---|---|
|`<img>`|Image.|
|`<map>`|Defines a client-side image map.|
|`<area>`|Defines an area inside an image map.|
|`<canvas>`|Used to draw graphics in real time, via scripting (usually JavaScript).|
|`<figcaption>`|Defines a caption for a `<figure>` element.|
|`<figure>`|Specifies self-contained content.|
|`<picture>`|Defines a container for multiple image resources.|
|`<svg>`|Defines a container for SVG graphics.|
|`<audio>`|Sound content.|
|`<source>`|Defines multiple media resources for media elements (`<video>`, `<audio>` and `<picture>`).|
|`<track>`|Defines text tracks for media elements (`<video>` and `<audio>`).|
|`<video>`|Video or movie.|
## Links
|Tag|Description|
|---|---|
|`<iframe>`|Defines an inline frame.|
|`<a>`|Defines a hyperlink.|
|`<link>`|Defines the relationship between a document and an external resource (most used to link to style sheets).|
|`<nav>`|Navigation links.|
## Lists
|Tag|Description|
|---|---|
|`<menu>`|Alternative unordered list.|
|`<ul>`|Unordered list.|
|`<ol>`|Ordered list.|
|`<li>`|Defines a list item.|
|`<dl>`|Description list|
|`<dt>`|Defines a term/name in a description list.|
|`<dd>`|Defines a description of a term/name in a description list.|
## Tables
|Tag|Description|
|---|---|
|`<table>`|Table.|
|`<caption>`|Defines a table caption.|
|`<th>`|Defines a header cell in a table.|
|`<tr>`|Defines a row in a table.|
|`<td>`|Defines a cell in a table.|
|`<thead>`|Groups the header content in a table.|
|`<tbody>`|Groups the body content in a table.|
|`<tfoot>`|Groups the footer content in a table.|
|`<col>`|Specifies column properties for each column within a `<colgroup>` element.|
|`<colgroup>`|Specifies a group of one or more columns in a table for formatting.|
## Styles and Semantics
|Tag|Description|
|---|---|
|`<style>`|Defines style information for a document.|
|`<div>`|Defines a section in a document.|
|`<span>`|Defines a section in a document.|
|`<header>`|Defines a header for a document or section.|
|`<hgroup>`|Defines a header and related content.|
|`<footer>`|Defines a footer for a document or section.|
|`<main>`|Specifies the main content of a document.|
|`<section>`|Defines a section in a document.|
|`<search>`|Search section.|
|`<article>`|Article.|
|`<aside>`|Defines content aside from the page content.|
|`<details>`|Defines additional details that the user can view or hide.|
|`<dialog>`|Dialog box or window.|
|`<summary>`|Defines a visible heading for the `<details>` element.|
|`<data>`|Adds a machine-readable translation of a given content.|
## Meta
|Tag|Description|
|---|---|
|`<head>`|Contains information for the browser.|
|`<meta>`|Contains metadata for the webpage.|
|`<base>`|Specifies the base URL/target for all relative URLs in a document.|
## Programming
|Tag|Description|
|---|---|
|`<script>`|Client-side script.|
|`<noscript>`|Defines an alternate content for users that do not support client-side scripts.|
|`<object>`|Container for an external resource.|
|`<param>`|Defines a parameter for an object.|

141
content/notes/http.md Normal file
View File

@@ -0,0 +1,141 @@
---
tags:
- networking
- notes
- tools
- web
author: TrudeEH
draft: false
showToc: true
title: HTTP [curl]
---
## HTTP
HTTP (Hypertext Transfer Protocol) is a communication protocol used to send messages between the client and server, mainly used for the web. It's stateless, meaning each request is independent, which is why web browsers often use cookies to save state.
### Request Structure
1. **Request Line**: Method, URI, HTTP version (e.g., `GET /index.html HTTP/1.1`).
2. **Headers**: Metadata about the request.
3. **Body (Optional)**: Data for `POST`, `PUT`, `PATCH` requests.
### Response Structure
1. **Status Line**: HTTP version, status code, reason phrase (e.g., `HTTP/1.1 200 OK`).
2. **Headers**: Metadata about the response.
3. **Body (Optional)**: Response data (HTML, JSON, etc.).
### Methods
- **GET**: Retrieve a resource. Should only retrieve data and not have side effects.
- **POST**: Submit data to be processed.
- **PUT**: Replace a resource.
- **DELETE**: Delete a resource.
- **PATCH**: Partially modify a resource.
- **HEAD**: Retrieve headers only.
- **OPTIONS**: Describe communication options.
### HTTP Headers
**HTTP headers** are key-value pairs providing additional information about requests and responses.
#### Header Categories
- **General Headers**: Apply to both requests and responses.
- **Request Headers**: Information about the request context.
- **Response Headers**: Information about the response context.
- **Entity Headers**: Describe the body of the request or response.
#### General Headers
```Bash
Cache-Control: max-age=3600 # Specifies caching directives. (1 hour)
Connection: keep-alive # Controls whether the network connection stays open.
Date: Tue, 09 Jul 2024 12:00:00 GMT # Date and time of the message.
Transfer-Encoding: chunked # Encoding for safe transfer.
Upgrade: HTTP/2 # Request to upgrade to another protocol.
Via: 1.1 proxy.example.com # Indicates intermediate protocols and proxies.
```
#### **Request Headers**
```Bash
Accept: text/html, application/json # MIME types the client can handle.
Accept-Encoding: gzip, deflate # Supported encoding algorithms.
Accept-Language: en-US, en;q=0.9 # Preferred languages.
Authorization: Basic <credentials> # Authentication credentials.
Cookie: sessionid=123456789 # HTTP cookies.
Host: www.example.com # Domain name of the server.
Referer: https://www.example.com/page.html # URL of the linking page.
User-Agent: Mozilla/5.0 ... # Client software identifier.
```
#### Response Headers
```Bash
Access-Control-Allow-Origin: * # Indicates whether the response can be shared with the given origin.
Content-Type: application/json # MIME type of the response body.
Content-Length: 1024 # Size of the response body in bytes.
Content-Encoding: gzip # Encoding used for the data.
Location: https://www.example.com/new-page # Redirect URL.
Server: Apache/2.4.41 (Ubuntu) # Server software identifier.
Set-Cookie: sessionid=987654321; Path=/; HttpOnly # Sends a cookie from the server to the client.
```
#### Entity Headers
```Bash
Allow: GET, POST, PUT, DELETE # Supported methods.
Content-Language: en-US # Language(s) intended for the audience.
Content-Location: /index.htm # URL where the entity was obtained.
```
#### Custom Headers
Custom headers can be defined for application-specific purposes, typically prefixed with `X-` (e.g., `X-Custom-Header: custom-value`).
## Common HTTP Error Codes
- `200` OK
- `301` Redirect (Moved to another location)
- `302` Found
- `304` Not Modified
- `307` Temporary Redirect
- `401` Unauthorized
- `403` Forbidden
- `404` Not Found
- `418` I'm a Teapot
- `500` Internal Server Error
- `503` Service Unavailable
## CURL
`curl` is a command-line tool used for transferring data with URLs. It supports a wide range of protocols, including HTTP, HTTPS, FTP, SFTP, and more.
### Usage
```Shell
# Fetches the content of <https://example.com> and prints it to standard output
curl https://example.com
# Saves the content to a file named output.html
curl -o output.html https://example.com
# Makes a POST request with URL-encoded data
curl -X POST -d "param1=value1&param2=value2" https://example.com/api
# Makes a POST request with JSON data
curl -X POST -H "Content-Type: application/json" -d '{"param1": "value1", "param2": "value2"}' https://example.com/api
# Makes a PUT request with JSON data
curl -X PUT -H "Content-Type: application/json" -d '{"key": "new_value"}' https://api.example.com/resource/123
# Sets an Authorization header for API authentication
curl -H "Authorization: Bearer YOUR_API_KEY" https://example.com/api
# Tells curl to follow HTTP redirects
curl -L https://example.com/redirecting-url
# Saves cookies received from the server to cookies.txt
curl -c cookies.txt https://example.com
# Sends cookies from cookies.txt to the server
curl -b cookies.txt https://example.com
# Provides basic authentication credentials (username:password)
curl -u username:password https://example.com/protected-resource
# Sets the maximum time to wait for a connection and the entire operation
curl --connect-timeout 10 --max-time 60 https://example.com
```

View File

@@ -0,0 +1,64 @@
---
tags:
- networking
- notes
- web
author: TrudeEH
draft: false
showToc: true
title: HTTPS and SSL Certificates
---
## HTTP(s)
The `http` protocol sends data as plaintext, which is an issue when sharing sensitive data such as messages and passwords.
`https` uses `TLS` to encrypt sensitive traffic between the client and server, creating a secure connection between the two.
## TLS
TLS is a form of [[encryption]], used to secure HTTPS connections.
TLS replaces SSL (a deprecated protocol), however, the term SSL is still used often.
### Handshake
To establish a secure connection, a 'handshake' is performed between the client and the server.
1. The client send a message with browser and OS info, and all supported encryption algorithms.
2. The server selects the strongest supported algorithm, and responds with some server info, the selected algorithm, and an SSL Certificate (contains the domain name, certificate authority and public key).
3. The client checks the certificate to ensure that it is valid and signed by a valid certificate authority.
4. If the certificate is valid, the client generates a random session key, and encrypts it with the server's public key.
5. The session key is sent to the server.
6. The server decrypts the session key, using its own private key. If the key is valid, the server sends a finish message back to the client.
7. The client sends its own finish message, and a secure connection is established.
### SSL Certificates
SSL Certificates are needed because without them, a malicious actor could intercept the client's first handshake message, and establish a secure connection with the client, obtaining its secrets.
A trusted third party is needed to validate that the public key sent to the client matches the server's actual public key.
[Lets Encrypt](https://letsencrypt.org) is a non-profit organization that signs certificates for free.
#### Certbot
The easiest way to generate a *Let's Encrypt* certificate is through `certbot`, which is available as a snap package.
```Shell
sudo apt install snapd
sudo snap install core && sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
```
> If you use a firewall, open port 80, as it is required for `certbot` to verify your domain information.
> Once `certbot` is installed, you can either generate a standalone certificate (for example, to use for IRC), or follow the [official instructions](https://certbot.eff.org/instructions) for any web service that you already own.
For example, for an IRC server, run the following command:
```Shell
sudo certbot certonly --standalone --preferred-challenges http -d irc.example.com
```
Replace `irc.example.com` with your actual domain.
The certificate will be stored as two files …
- `/etc/letsencrypt/live/irc.example.com/fullchain.pem`
- `/etc/letsencrypt/live/irc.example.com/privkey.pem`
… which you can copy to any location you need.
These files will be renewed every 90 days, so remember to either update them manually, or add a `crontab` entry to automate the process.

207
content/notes/irc.md Normal file
View File

@@ -0,0 +1,207 @@
---
tags:
- networking
- notes
author: TrudeEH
draft: false
showToc: true
title: IRC
---
## The IRC Protocol
IRC is a very simple communication protocol that allows users to chat in real time. IRC is **very lightweight**, but does **not encrypt** messages by default.
## Using IRC
### Server
To be able to communicate, users must connect to a server. Each server has its own rules, bots and commands. The IRC protocol itself does not implement encryption, however, [[https-ssl-certs]] can be used to establish a secure connection **with the server**.
Every message sent **can be read by the server**, including **private messages** between users.
Separate IRC instances can communicate. This concept is often called **server federation**. This allows for users in different servers to send messages to each other.
### Client
To connect to a server, every user needs a client. Because IRC is an open protocol, there are many clients one can use, however, I am currently using [halloy](https://halloy.squidowl.org/index.html).
For example, *halloy* can be configured as follows:
```TOML
# Example without encryption
[servers.trude_unsafe]
nickname = "trude"
server = "server.trude.dev"
port = 6667
use_tls = false
channels = ["\#general"]
# Example with encryption (TLS)
[servers.trude]
nickname = "trude"
server = "server.trude.dev"
port = 6697
use_tls = true
channels = ["\#general"]
```
### Modes (user roles)
- `@user` - Admin / Operator
- `+user` - Voiced user
- `user` - Regular user
### Channels
A `#channel` is a room where users can communicate. Channels can be public or invite-only.
### DMs
Two users can send private messages (aka, direct messages) to each other outside channels. However, the server is always able to read and log these messages due to the lack of encryption.
### [Commands](https://docs.inspircd.org/4/commands/)
Users are able to perform actions with simple text commands.
#### Basic Commands
|Command|Action|
|---|---|
|`/join #channel`|Join a channel.|
|`/part #channel [message]`|Leave a channel with an optional goodbye message.|
|`/msg nickname message`|Send a DM to one or more users.|
|`/quit [message]`|Leave the server with an optional goodbye message.|
|`/motd`|Read the server's "message of the day".|
|`/nick nickname`|Change your nickname. (The name other people see when messaging you; the `/whois` command can still reveal your real name).|
|`/whois nickname`|Get information about an user. By default, this includes: <br>- Hostname <br>- Real name <br>- IP Address <br>- Joined channels <br>- Last message/Login time <br>- User modes <br>- Origin server|
|`/whowas nickname`|Same as whois, but for nicknames that were recently used. Can also reveal previous login times for connected users.|
|`/me action`|Send a message as an action (third-person). (Usually for role playing purposes; only changes formatting).|
|`/topic <#channel> <?text>`|View or set the topic for the channel. (Description of the channel).|
|`/names #channel`|List all users in a channel.|
|`/list`|List all available channels.|
|`/ping`|Check connection with the server.|
|`/admin`|Display administrative information about the server.|
|`/time`|Display the current time on the server.|
#### Operator Commands
|Command|Description|
|---|---|
|`/kick nickname [reason]`|Removes a user from the channel.|
|`/ban nickname`|Bans a user from the channel (usually combined with a kick).|
|`/mode #channel +mode`|Changes channel modes (e.g., `/mode #chat +i` makes it invite-only).|
|`/invite nickname #channel`|Invites a user to join a private or invite-only channel.|
|`/op nickname`|Grants operator status to a user (if you are an operator).|
|`/deop nickname`|Removes operator status from a user.|
#### User Modes
|Command|Description|
|---|---|
|`/mode nickname +mode`|Sets user modes (e.g., `/mode yourname +i` to become invisible).|
|`/mode #channel +mode`|Sets modes for a channel (e.g., `/mode #chat +m` to make it moderated).|
|`/away [message]`|Sets your status to "away" with an optional message.|
|`/back`|Removes your "away" status. (Some servers use `/away` as a toggle, instead.|
|Common channel modes|Description|
|---|---|
|`+i`|Makes the channel invite-only.|
|`+m`|Moderates the channel (only operators or voiced users can speak).|
|`+n`|Prevents messages from users not in the channel.|
|`+t`|Only operators can change the topic.|
|`+k`|Requires a password to join the channel.|
|Common user modes|Description|
|---|---|
|`+i`|Makes your user "invisible" (hides you from `/who`).|
|`+o`|Grants operator privileges.|
|`+v`|Gives a user the ability to speak in a moderated channel
### Bots
A bot is an automated user (program/script) that can respond to commands, monitor chat or automate activities.
Commands to bots are often prefixed with `!`, though, this is not always the case.
## Hosting an IRC Server
There are many ways to host an IRC server, and the exact steps vary depending on your platform, server software and encryption standards.
### Docker
One of the easiest ways to launch an IRC server is through Docker, using `inspircd`.
For example, this `docker compose` file allows you to run a simple server.
```YAML
name: inspircd
services:
main_app:
cpu_shares: 50
command: []
container_name: inspircd
deploy:
resources:
limits:
memory: 2048M # Max RAM usage
environment:
- INSP_SERVER_NAME=irc.local
- INSPIRCD_ADMIN_EMAIL=nomail@example.com
- INSPIRCD_ADMIN_NAME=admin
hostname: inspircd
image: inspircd/inspircd-docker:latest
ports:
- target: 6667
published: "6667"
- target: 6697
published: "6697"
restart: unless-stopped
volumes:
- type: bind
source: /DATA/AppData/irc_server # Config directory
target: /inspircd/conf
devices: []
cap_add: []
network_mode: host
privileged: false
```
To properly configure your server, be sure to read the [containers documentation](https://hub.docker.com/r/inspircd/inspircd-docker/).
This container generates a self-signed SSL certificate for secure connections, however, it won't be accepted by actual clients. Refer to my [[https-ssl-certs]] to generate a real certificate for TLS to work. After generating your certificate, simply replace the old one with it.
### Linux
On Linux, the process is only a little more involved.
First, install `inspircd` using your distro's package manager. (IRC server)
> If you use a firewall, enable ports 22, 6667 and 6697 (for TLS) before continuing.
```Shell
sudo apt update
sudo apt install inspircd -y
```
Then, edit the configuration file to your liking.
```Shell
sudoedit /etc/inspircd/inspircd.conf
```
Finally, start `inspircd`.
```Shell
sudo systemctl start inspircd
```
To enable TLS, refer to my [[https-ssl-certs]]. After generating your certificate, copy it to `inspircd`'s ssl directory.
```Shell
sudo cp /etc/letsencrypt/live/irc.example.com/fullchain.pem /etc/inspircd/ssl/cert.pem
sudo cp /etc/letsencrypt/live/irc.example.com/privkey.pem /etc/inspircd/ssl/key.pem
```
And add the following block to your `ispircd` configuration:
```JSON
<bind address="" port="6697" type="clients" ssl="gnutls">
<gnutls
certfile="/etc/inspircd/ssl/cert.pem"
keyfile="/etc/inspircd/ssl/key.pem"
priority="SECURE192:-VERS-SSL3.0">
<module name="m_ssl_gnutls.so">
```

View File

@@ -0,0 +1,61 @@
---
tags:
- notes
- os
author: TrudeEH
draft: true
showToc: true
title: Linux
---
#todo
## Troubleshooting
- Read error logs from the last session
```Shell
sudo journalctl -b -1 -r -p err
```
## Disk Encryption
### Full Disk Encryption
The exact steps to fully encrypt a disk varies depending on the distribution, and can only be done at the install time.
On Ubuntu, for example, you can enable it in the "Advanced Features" toggle, at the disk selection stage.
![[image93.png]]
### Encrypt Home Directory
```Bash
sudo apt install ecryptfs-utils cryptsetup # Install dependencies
# Create temporary admin account
sudo adduser temp_user # Add new user
sudo usermod -aG sudo temp_user # Give the new user sudo perms
```
Now, log out of the current user and switch to `temp_user`.
> [!important] Do not "switch accounts", the current user cannot be active while its home directory is being encrypted.
On the `temp_user` account, run the following command, then, log out and return to your user.
```Bash
sudo ecryptfs-migrate-home -u <username>
```
After logging in, you might be greeted with a pop-up with the title "Update Information". Click on "Run this action now" and provide your password.
If you already closed the pop-up, run the command below, and provide your password.
```Bash
encryptfs-unwrap-passphrase
```
You will receive a string of text. This will be your recovery password, needed to mount the home folder from another machine.
### Encrypt Swap
```Bash
swapon -s # Check if you have a swap partition
sudo ecryptfs-setup-swap # Encrypt swap
```
You may get an error: `swapon: cannot open /dev/mapper/cryptswap1: No such file or directory`. If you do, reboot and check if the swap partition is encrypted with the `swapon -s` command.

191
content/notes/lua.md Normal file
View File

@@ -0,0 +1,191 @@
---
Status: Planned
Created by: Trude EH
tags:
- notes
- programming
author: TrudeEH
draft: true
searchHidden: false
showToc: true
title: Lua
---
Embedded language.
#todo
## Comments
```Lua
-- One-Line comment
--[[ Multi-line
comment
--]]
```
## Simple Literals
```Lua
local number = 5
local string = "hello, world"
local single = 'same as using \"'
local multiline = [[ Multi
line
string ]]
local yes, no = true, false
local nothing = nil
```
## Functions
Functions can be stored as values.
```Lua
local function hello(name)
print("Hello", name)
end
local greet = function(name)
-- .. is string concaternation
print("Hello " .. name .. "!")
end
-- Calling a function
greet("Trude")
greet "Trude"
```
Functions can also return other functions.
```Lua
local high = function(value)
return function(value2)
return value + value2
end
end
local add_one = high(1)
print("1 + 2 -> ", add_one(2))
```
Functions can return multiple values.
```Lua
local return_four_values = function()
return 1, 2, 3, 4
end
first, second, third = return_four_values() -- "4" was discarded.
```
Variable arguments.
```Lua
local variable_arguments = function( ... )
local arguments = { ... }
for i, v in ipairs({ ... }) do print(i, v) end
end
print(variable_arguments("this", "is", "a", "test"))
```
## Tables
Lua's only data structure. (Also used for maps and lists)
### As lists…
```Lua
local list = { "first", 2, false, function() print("Fourth") end }
print("Lua is 1-indexed:", list[1])
```
### As maps…
```Lua
local t = {
literal_key = "a string",
["an expression"] = "also works",
[function() end] = true
}
print("literal_key : ", t.literal_key)
print("an expression : ", t["an expression"]
print("function() end : ", t[function() end]) -- nothing will be printed here, because each function definition points to a different memory address.
```
### Colon Functions
```Lua
local T = {}
function T.something(self, ... ) end
function T:something( ... ) end -- Same as the previous line
```
### Metatables
```Lua
local vector_mt = {}
vector_mt.__add = function(left, right)
return setmetatable({
left[1] + right[1],
left[2] + right[2],
left[3] + right[3]
}, vector_mt)
end
local v1 = setmetatable({ 3, 1, 5 }, vector_mt)
local v2 = setmetatable({ -3, 2, 2}, vector_mt)
local v3 = v1 + v2 -- normally would produce an error, but doesn't, since the __add keyword was used.
print(v3[1], v3[2], v3[3])
```
## Control Flow
### For
#### Lists
```Lua
local favs = { "ThePrimeagen", "ctt", "NoBoilerplate" }
for index = 1, \#favs do -- # is the length operator (does not work on maps!)
print(index, favs[index])
end
for index, value in ipairs(favs) do -- ipairs return the index and values of that index
print(index, value)
end
```
#### Maps
```Lua
local favs = { ThePrimeagen = 9.5, NoBoilerplate = "N/A" }
for key, value in pairs(favs) do -- pairs return the index and values of that key
print(key, value)
end
```
### If
```Lua
local function action(visit_page)
if visit_page then
print("Opening new tab...")
else
print("Skipping...")
end
end
-- "falsey": nil, false
action() -- Same as: action(nil)
action(false)
-- Everything else is "truthy"
action(true)
action(0)
action({})
```
## Modules
Modules are just files.
```Lua
-- module.lua
local M = {}
M.some_function = function() end
return M
-- main.lua
local something = require("module")
something.some_function()
```

62
content/notes/macOS.md Normal file
View File

@@ -0,0 +1,62 @@
---
Status: In progress
Created by: Trude EH
tags:
- notes
- os
author: TrudeEH
draft: true
searchHidden: false
showToc: true
title: macOS
---
#todo
## System Data
System data is anything in the following locations:
- `/Library`
- `/System`
- `~Library`
- `/usr`
- `.hidden_files`
## Memory
- Physical Memory - Total system memory
- Memory Used
- App Memory - Memory used for apps
- Wired Memory - System memory
- Compressed - Memory used by apps, but compressed as it is not immediately needed
- Cached Files - Files saved in memory for faster launching
- Swap Used - Memory stored in the SSD
### Memory Pressure
A measurement of how well macOS is managing the available memory.
- Green/Low: Normal function; No tricks needed.
- Yellow/Medium: There is not enough memory as-is, so macOS is actively compressing and decompressing memory as needed.
- Red/High: Aside from compression, macOS is using the swap heavily.
## Troubleshooting
### System and Apps
|Description|Fix|
|---|---|
|Fix "App X is damaged and can't be opened."|`xattr -c <path/to/application.app>`|
|Disable the Dock autohide delay|Fix: <br> <br>`defaults write com.apple.dock autohide-delay -float 0; defaults write com.apple.dock autohide-time-modifier -int 0;killall Dock` <br> <br>Restore defaults: <br> <br>`defaults delete com.apple.Dock autohide-delay; killall Dock`|
|||
|||
### Gaming
|Issue / Error / Description|Fix|
|---|---|
|Improve Terraria performance (and some other games)|Add `/gldevice:Vulkan` as a launch argument (on Steam).|
|||
### Flash IMG File to Disk
1. `diskutil list` → Find the path to the device (`/dev/XXX`)
2. `diskutil unmount /dev/XXX` → Unmount the disk
3. `sudo dd if=image.img of=/dev/XXX bs=1M oflag=direct,sync status=progress`

118
content/notes/pass.md Normal file
View File

@@ -0,0 +1,118 @@
---
tags:
- networking
- notes
- tools
author: TrudeEH
draft: false
showToc: true
title: Password Manager [PASS]
---
## Password Managers
A password manager is a program responsible for saving all your passwords.
You could have a single password and use it for everything, but if an attacker gets a hold of your password on just one service, they would have access to all of your accounts. Different services may have different requirements for passwords, too. To mitigate these issues, it's recommended to use a password manager, and a unique password for each service.
There are many options available, however, *pass* is one of the simplest ones.
## Pass
*Pass* uses *[[encryption]]* to encrypt your passwords. If you don't have one already, use *GPG* to generate a personal key.
Besides from allowing you to read your passwords, *pass* can be scripted, providing your passwords to scripts and other programs securely.
Instead of a database, *pass* stores every password in separate files, inside a directory called `password-store`. You can use *pass* to organize passwords just like regular files in the filesystem.
Pass also integrates with [[git]], allowing you to undo changes, rollback to a previous state, and set a remote repository to save them on.
### Initialize Pass
#### Create a New `password-store` Directory
Your saved (encrypted) passwords will be stored here.
```Shell
pass init email@example.com
```
#### Import an Existing Password Set
```Shell
pass import <path_to_csv> # Import decrypted passwords
gpg --decrypt passwords.pgp | pass import # Decrypt pass export file
```
#### Clone a `password-store` Repository
```Shell
git clone <url> .password-store
```
### Manage Passwords
```Shell
pass add <name> # Store a password in the root directory with a name
pass add <category/name> # Store the password in a subpath
pass generate <name> # Generate a new password
pass # List all saved password names
pass <name> # Output a password with its metadata
pass <name> | head -n 1 # Output the password only
pass -c <name> # Copy password to clipboard
pass find <name> # Search for a password's name
pass grep <name> # Search for a password or metadata
pass edit <name> # Edit an entry
pass rm <name> # Delete password
```
### Metadata
Any lines under the password are read as metadata. Use the `pass edit` command to add any metadata after the password itself.
```Shell
pass edit <name>
```
…an editor window will be opened:
```Shell
PASSWORD-HERE
metadata: You can write anything.
username: some_username
Some note.
```
The `pass -c` command ignores metadata, but typing `pass <name>` still shows that data.
To only show the first line, which contains the password, use the following command:
```Shell
pass <name> | head -n 1
```
### Git
You can run any git command on the password-store directory.
For example:
```Shell
pass git revert HEAD # Undo the last commit (restore a deleted password)
pass git remote add origin <url> # Add a remote origin
pass push origin main # Push the local repo onto the remote origin
```
### OTP Codes / 2FA
Online services might provide you with an `otpauth://` URL, or with a QR code.
If a QR code is provided, you can decode it using `zbarimg`:
```Shell
zbarimg -q <qr.png>
```
Then, create a new OTP entry and paste in the `otpauth://` path that you acquired.
```Shell
pass otp add <name>
```
To generate an OTP code, use the following command:
```Shell
pass otp <name>
```

1144
content/notes/python.md Normal file

File diff suppressed because it is too large Load Diff

123
content/notes/ssh.md Normal file
View File

@@ -0,0 +1,123 @@
---
tags:
- networking
- notes
author: TrudeEH
draft: false
showToc: true
title: SSH
---
*SSH* is a protocol for accessing a terminal remotely.
For *SSH* to work, the remote machine needs to have an *OpenSSH* instance running and listening for connections, and port 22 must be allowed through any VPNs or firewalls between the client and host machines. An *SSH* client is also needed, be it any UNIX system (using the `ssh` command), or a Windows server using a client such as *PuTTY*.
## OpenSSH Client
### Connect to a Remote Server
#### Connect Using a Password
```Shell
ssh <user>@<ip>
> <password>
ssh root@192.168.1.133
> Ctrl+D # Disconnect
```
> After connecting to a server for the first time, the fingerprint of that server is stored in the `~/.ssh/known-hosts` file.
>
> This is a security measure to prevent MitM attacks. (The client is notified if the server's fingerprint changes).
#### Connect Using an SSH Key
First, it is necessary to generate a private and public key to use with SSH. Always use a passphrase to keep your private key secure in case your machine is compromised in the future.
```Shell
ssh-keygen # Create a private/public key pair.
```
> Make sure to back up your keys! Running the above command and saving the new keys would overwrite the previous ones, possibly locking you out of your servers.
> After generating your keys, send the public key to your network administrator.
#### Managing Multiple Keys
Having separate SSH keys can ensure that if one of them leaks, not all machines it has access to would be compromised.
```Shell
ssh-keygen -C "Comment" # The comment is optional, and defauls to your user/hostname
> $HOME/.ssh/<name>
# After sending the public key to the administrator...
ssh -i <path_to_private_key> <user>@<host>
```
This method requires you to type your key's passphrase every time an SSH connection is started.
To load the key into memory, an `ssh-agent` is needed.
```Shell
eval "$(ssh-agent)" # Temporarily start the ssh-agent (already present if GUI)
ssh-add <path_to_private_key> # Load the key into memory
ssh -i <path_to_private_key> <user>@<host> # The password won't be asked again
```
### Configure The Client
Edit the `~/.ssh/config` file to configure the client.
#### Aliases
```Shell
Host <alias>
Hostname <ip>
Port 22
User <remote user>
```
Now, connecting to the server is as simple as typing:
```Shell
ssh <alias>
```
## OpenSSH Server
Check whether the ssh server is running.
```Shell
systemctl status sshd / ssh
```
### Read Connection Logs
```Shell
su root
tail -f /var/log/auth.log
journalctl -fu ssh / sshd # Preferred way to read logs
```
### Configure SSH Keys
By default, the *OpenSSH* server is configured to support both passwords and keys.
#### Add a Client's Public Key
```Shell
echo "PUBLIC_KEY" >> /home/<user>/.ssh/authorized_keys
```
If password login is enabled (or you are uploading someone else's key), there is a dedicated command to add a public key to the server, directly from the client:
```Shell
ssh-copy-id -i ~/.ssh/id_rsa.pub <user>@<server>
```
### Configure The Server
`/etc/ssh/sshd_config`
```Shell
# Changing the port can help security slightly, but is less convenient
Port 22
# Disable ssh into root (only after you have another user with sudo access)
PermitRootLogin false
# Disable password authentication (use keys exclusively)
PasswordAuthentication no
```

BIN
content/notes/temp/EXT2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

BIN
content/notes/temp/EXT3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Some files were not shown because too many files have changed in this diff Show More