Merge remote-tracking branch 'origin/main'
4
.obsidian/app.json
vendored
@ -2,11 +2,13 @@
|
||||
"vimMode": true,
|
||||
"promptDelete": false,
|
||||
"pdfExportSettings": {
|
||||
"includeName": true,
|
||||
"pageSize": "Letter",
|
||||
"landscape": false,
|
||||
"margin": "0",
|
||||
"downscalePercent": 100
|
||||
},
|
||||
"spellcheck": true,
|
||||
"focusNewTab": false
|
||||
"focusNewTab": false,
|
||||
"alwaysUpdateLinks": true
|
||||
}
|
6
.obsidian/community-plugins.json
vendored
@ -1,3 +1,7 @@
|
||||
[
|
||||
"obsidian-git"
|
||||
"obsidian-git",
|
||||
"d2-obsidian",
|
||||
"execute-code",
|
||||
"better-export-pdf",
|
||||
"obsidian-excalidraw-plugin"
|
||||
]
|
4
.obsidian/file-recovery.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"intervalMinutes": 5,
|
||||
"keepDays": 7
|
||||
}
|
29
.obsidian/plugins/better-export-pdf/data.json
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"showTitle": true,
|
||||
"maxLevel": "6",
|
||||
"displayHeader": true,
|
||||
"displayFooter": true,
|
||||
"headerTemplate": "<div style=\"width: 100vw;font-size:10px;text-align:center;\"><span class=\"title\"></span></div>",
|
||||
"footerTemplate": "<div style=\"width: 100vw;font-size:10px;text-align:center;\"><span class=\"pageNumber\"></span> / <span class=\"totalPages\"></span></div>",
|
||||
"printBackground": false,
|
||||
"generateTaggedPDF": false,
|
||||
"displayMetadata": false,
|
||||
"debug": false,
|
||||
"isTimestamp": false,
|
||||
"enabledCss": false,
|
||||
"prevConfig": {
|
||||
"pageSize": "A4",
|
||||
"marginType": "1",
|
||||
"showTitle": true,
|
||||
"open": true,
|
||||
"scale": 100,
|
||||
"landscape": false,
|
||||
"marginTop": "10",
|
||||
"marginBottom": "10",
|
||||
"marginLeft": "10",
|
||||
"marginRight": "10",
|
||||
"displayHeader": true,
|
||||
"displayFooter": true,
|
||||
"cssSnippet": "0"
|
||||
}
|
||||
}
|
21223
.obsidian/plugins/better-export-pdf/main.js
vendored
Normal file
11
.obsidian/plugins/better-export-pdf/manifest.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "better-export-pdf",
|
||||
"name": "Better Export PDF",
|
||||
"version": "1.9.2",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Export your notes to PDF, support export preview, add bookmarks outline and header/footer.",
|
||||
"author": "l1xnan",
|
||||
"authorUrl": "https://github.com/l1xnan",
|
||||
"fundingUrl": "https://www.buymeacoffee.com/l1xnan",
|
||||
"isDesktopOnly": true
|
||||
}
|
52
.obsidian/plugins/better-export-pdf/styles.css
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
#better-export-pdf {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 75vh;
|
||||
}
|
||||
|
||||
#better-export-pdf .pdf-preview {
|
||||
flex: auto;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
align-content: flex-start;
|
||||
}
|
||||
|
||||
#better-export-pdf .pdf-preview .webview-wrapper {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#better-export-pdf .pdf-preview .print-size {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
top: 8px;
|
||||
z-index: 99;
|
||||
font-size: 0.6rem;
|
||||
white-space: pre-wrap;
|
||||
text-align: right;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#better-export-pdf .pdf-preview > div {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#better-export-pdf .pdf-preview .filename {
|
||||
font-size: 0.75rem;
|
||||
color: var(--color-base-60);
|
||||
}
|
||||
#better-export-pdf .pdf-preview .filename:not(:first-child) {
|
||||
padding-top: calc(var(--p-spacing));
|
||||
}
|
||||
|
||||
#better-export-pdf webview {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
533
.obsidian/plugins/d2-obsidian/main.js
vendored
Normal file
@ -0,0 +1,533 @@
|
||||
/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source, please visit the github repository of this plugin: https://github.com/terrastruct/d2-obsidian
|
||||
*/
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// node_modules/lodash.debounce/index.js
|
||||
var require_lodash = __commonJS({
|
||||
"node_modules/lodash.debounce/index.js"(exports, module2) {
|
||||
var FUNC_ERROR_TEXT = "Expected a function";
|
||||
var NAN = 0 / 0;
|
||||
var symbolTag = "[object Symbol]";
|
||||
var reTrim = /^\s+|\s+$/g;
|
||||
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
||||
var reIsBinary = /^0b[01]+$/i;
|
||||
var reIsOctal = /^0o[0-7]+$/i;
|
||||
var freeParseInt = parseInt;
|
||||
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
||||
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
||||
var root = freeGlobal || freeSelf || Function("return this")();
|
||||
var objectProto = Object.prototype;
|
||||
var objectToString = objectProto.toString;
|
||||
var nativeMax = Math.max;
|
||||
var nativeMin = Math.min;
|
||||
var now = function() {
|
||||
return root.Date.now();
|
||||
};
|
||||
function debounce2(func, wait, options) {
|
||||
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
||||
if (typeof func != "function") {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
wait = toNumber(wait) || 0;
|
||||
if (isObject(options)) {
|
||||
leading = !!options.leading;
|
||||
maxing = "maxWait" in options;
|
||||
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
||||
trailing = "trailing" in options ? !!options.trailing : trailing;
|
||||
}
|
||||
function invokeFunc(time) {
|
||||
var args = lastArgs, thisArg = lastThis;
|
||||
lastArgs = lastThis = void 0;
|
||||
lastInvokeTime = time;
|
||||
result = func.apply(thisArg, args);
|
||||
return result;
|
||||
}
|
||||
function leadingEdge(time) {
|
||||
lastInvokeTime = time;
|
||||
timerId = setTimeout(timerExpired, wait);
|
||||
return leading ? invokeFunc(time) : result;
|
||||
}
|
||||
function remainingWait(time) {
|
||||
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
|
||||
return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
|
||||
}
|
||||
function shouldInvoke(time) {
|
||||
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
|
||||
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
||||
}
|
||||
function timerExpired() {
|
||||
var time = now();
|
||||
if (shouldInvoke(time)) {
|
||||
return trailingEdge(time);
|
||||
}
|
||||
timerId = setTimeout(timerExpired, remainingWait(time));
|
||||
}
|
||||
function trailingEdge(time) {
|
||||
timerId = void 0;
|
||||
if (trailing && lastArgs) {
|
||||
return invokeFunc(time);
|
||||
}
|
||||
lastArgs = lastThis = void 0;
|
||||
return result;
|
||||
}
|
||||
function cancel() {
|
||||
if (timerId !== void 0) {
|
||||
clearTimeout(timerId);
|
||||
}
|
||||
lastInvokeTime = 0;
|
||||
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
||||
}
|
||||
function flush() {
|
||||
return timerId === void 0 ? result : trailingEdge(now());
|
||||
}
|
||||
function debounced() {
|
||||
var time = now(), isInvoking = shouldInvoke(time);
|
||||
lastArgs = arguments;
|
||||
lastThis = this;
|
||||
lastCallTime = time;
|
||||
if (isInvoking) {
|
||||
if (timerId === void 0) {
|
||||
return leadingEdge(lastCallTime);
|
||||
}
|
||||
if (maxing) {
|
||||
timerId = setTimeout(timerExpired, wait);
|
||||
return invokeFunc(lastCallTime);
|
||||
}
|
||||
}
|
||||
if (timerId === void 0) {
|
||||
timerId = setTimeout(timerExpired, wait);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
debounced.cancel = cancel;
|
||||
debounced.flush = flush;
|
||||
return debounced;
|
||||
}
|
||||
function isObject(value) {
|
||||
var type = typeof value;
|
||||
return !!value && (type == "object" || type == "function");
|
||||
}
|
||||
function isObjectLike(value) {
|
||||
return !!value && typeof value == "object";
|
||||
}
|
||||
function isSymbol(value) {
|
||||
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
|
||||
}
|
||||
function toNumber(value) {
|
||||
if (typeof value == "number") {
|
||||
return value;
|
||||
}
|
||||
if (isSymbol(value)) {
|
||||
return NAN;
|
||||
}
|
||||
if (isObject(value)) {
|
||||
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
||||
value = isObject(other) ? other + "" : other;
|
||||
}
|
||||
if (typeof value != "string") {
|
||||
return value === 0 ? value : +value;
|
||||
}
|
||||
value = value.replace(reTrim, "");
|
||||
var isBinary = reIsBinary.test(value);
|
||||
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
||||
}
|
||||
module2.exports = debounce2;
|
||||
}
|
||||
});
|
||||
|
||||
// src/main.ts
|
||||
var main_exports = {};
|
||||
__export(main_exports, {
|
||||
default: () => D2Plugin
|
||||
});
|
||||
module.exports = __toCommonJS(main_exports);
|
||||
var import_obsidian3 = require("obsidian");
|
||||
|
||||
// src/settings.ts
|
||||
var import_obsidian = require("obsidian");
|
||||
|
||||
// src/constants.ts
|
||||
var LAYOUT_ENGINES = {
|
||||
DAGRE: {
|
||||
value: "dagre",
|
||||
label: "dagre"
|
||||
},
|
||||
ELK: {
|
||||
value: "elk",
|
||||
label: "ELK"
|
||||
},
|
||||
TALA: {
|
||||
value: "tala",
|
||||
label: "TALA"
|
||||
}
|
||||
};
|
||||
var RecompileIcon = `
|
||||
<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M8.33325 83.3334V58.3334H33.3333" stroke="#2E3346" stroke-width="8.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M91.6667 16.6666V41.6666H66.6667" stroke="#2E3346" stroke-width="8.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M14.6249 37.5004C16.7381 31.5287 20.3296 26.1896 25.0644 21.9813C29.7991 17.773 35.5227 14.8328 41.7011 13.4348C47.8795 12.0369 54.3114 12.2268 60.3965 13.987C66.4817 15.7471 72.0218 19.02 76.4999 23.5004C80.978 27.9808 91.6666 41.667 91.6666 41.667M8.33325 58.3337C8.33325 58.3337 19.0218 72.02 23.4999 76.5004C27.978 80.9808 33.5181 84.2537 39.6033 86.0138C45.6884 87.774 52.1203 87.9639 58.2987 86.566C64.4771 85.168 70.2007 82.2277 74.9355 78.0195C79.6702 73.8112 83.2617 68.4721 85.3749 62.5004" stroke="#2E3346" stroke-width="8.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
// src/settings.ts
|
||||
var DEFAULT_SETTINGS = {
|
||||
layoutEngine: "dagre",
|
||||
debounce: 500,
|
||||
theme: 0,
|
||||
apiToken: "",
|
||||
d2Path: "",
|
||||
pad: 100,
|
||||
sketch: false,
|
||||
containerHeight: 800
|
||||
};
|
||||
var D2SettingsTab = class extends import_obsidian.PluginSettingTab {
|
||||
constructor(app, plugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
addTALASettings() {
|
||||
const talaSettings = this.containerEl.createEl("div");
|
||||
talaSettings.createEl("h3", {
|
||||
text: "TALA settings"
|
||||
});
|
||||
new import_obsidian.Setting(talaSettings).setName("API token").setDesc('To use TALA, copy your API token here or in ~/.local/state/tstruct/auth.json under the field "api_token"').addText((text) => text.setPlaceholder("tstruct_...").setValue(this.plugin.settings.apiToken).setDisabled(this.plugin.settings.layoutEngine !== LAYOUT_ENGINES.TALA.value).onChange(async (value) => {
|
||||
if (value && !value.startsWith("tstruct_")) {
|
||||
new import_obsidian.Notice("Invalid API token");
|
||||
} else {
|
||||
this.plugin.settings.apiToken = value;
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
}));
|
||||
this.talaSettings = talaSettings;
|
||||
}
|
||||
display() {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
containerEl.createEl("h1", { text: "D2 plugin settings" });
|
||||
new import_obsidian.Setting(containerEl).setName("Layout engine").setDesc('Available layout engines include "dagre", "ELK", and "TALA" (TALA must be installed separately from D2)').addDropdown((dropdown) => {
|
||||
dropdown.addOption(LAYOUT_ENGINES.DAGRE.value, LAYOUT_ENGINES.DAGRE.label).addOption(LAYOUT_ENGINES.ELK.value, LAYOUT_ENGINES.ELK.label).addOption(LAYOUT_ENGINES.TALA.value, LAYOUT_ENGINES.TALA.label).setValue(this.plugin.settings.layoutEngine).onChange(async (value) => {
|
||||
var _a;
|
||||
this.plugin.settings.layoutEngine = value;
|
||||
await this.plugin.saveSettings();
|
||||
if (value === LAYOUT_ENGINES.TALA.value) {
|
||||
this.addTALASettings();
|
||||
} else {
|
||||
(_a = this.talaSettings) == null ? void 0 : _a.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
new import_obsidian.Setting(containerEl).setName("Theme ID").setDesc("Available themes are located at https://github.com/terrastruct/d2/tree/master/d2themes").addText((text) => text.setPlaceholder("Enter a theme ID").setValue(String(this.plugin.settings.theme)).onChange(async (value) => {
|
||||
if (!isNaN(Number(value)) || value === "") {
|
||||
this.plugin.settings.theme = Number(value || DEFAULT_SETTINGS.theme);
|
||||
await this.plugin.saveSettings();
|
||||
} else {
|
||||
new import_obsidian.Notice("Please specify a valid number");
|
||||
}
|
||||
}));
|
||||
new import_obsidian.Setting(containerEl).setName("Pad").setDesc("Pixels padded around the rendered diagram").addText((text) => text.setPlaceholder(String(DEFAULT_SETTINGS.pad)).setValue(String(this.plugin.settings.pad)).onChange(async (value) => {
|
||||
if (isNaN(Number(value))) {
|
||||
new import_obsidian.Notice("Please specify a valid number");
|
||||
this.plugin.settings.pad = Number(DEFAULT_SETTINGS.pad);
|
||||
} else if (value === "") {
|
||||
this.plugin.settings.pad = Number(DEFAULT_SETTINGS.pad);
|
||||
} else {
|
||||
this.plugin.settings.pad = Number(value);
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
new import_obsidian.Setting(containerEl).setName("Sketch mode").setDesc("Render the diagram to look like it was sketched by hand").addToggle((toggle) => toggle.setValue(this.plugin.settings.sketch).onChange(async (value) => {
|
||||
this.plugin.settings.sketch = value;
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
new import_obsidian.Setting(containerEl).setName("Container height").setDesc("Diagram max render height in pixels (Requires d2 v0.2.2 and up)").addText((text) => text.setPlaceholder(String(DEFAULT_SETTINGS.containerHeight)).setValue(String(this.plugin.settings.containerHeight)).onChange(async (value) => {
|
||||
if (isNaN(Number(value))) {
|
||||
new import_obsidian.Notice("Please specify a valid number");
|
||||
this.plugin.settings.containerHeight = Number(DEFAULT_SETTINGS.containerHeight);
|
||||
} else if (value === "") {
|
||||
this.plugin.settings.containerHeight = Number(DEFAULT_SETTINGS.containerHeight);
|
||||
} else {
|
||||
this.plugin.settings.containerHeight = Number(value);
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
new import_obsidian.Setting(containerEl).setName("Debounce").setDesc("How often should the diagram refresh in milliseconds (min 100)").addText((text) => text.setPlaceholder(String(DEFAULT_SETTINGS.debounce)).setValue(String(this.plugin.settings.debounce)).onChange(async (value) => {
|
||||
if (isNaN(Number(value))) {
|
||||
new import_obsidian.Notice("Please specify a valid number");
|
||||
this.plugin.settings.debounce = Number(DEFAULT_SETTINGS.debounce);
|
||||
} else if (value === "") {
|
||||
this.plugin.settings.debounce = Number(DEFAULT_SETTINGS.debounce);
|
||||
} else if (Number(value) < 100) {
|
||||
new import_obsidian.Notice("The value must be greater than 100");
|
||||
this.plugin.settings.debounce = Number(DEFAULT_SETTINGS.debounce);
|
||||
} else {
|
||||
this.plugin.settings.debounce = Number(value);
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
new import_obsidian.Setting(containerEl).setName("Path (optional)").setDesc("Customize the local path to the directory `d2` is installed in (ex. if d2 is located at `/usr/local/bin/d2`, then the path is `/usr/local/bin`). This is only necessary if `d2` is not found automatically by the plugin (but is installed).").addText((text) => {
|
||||
text.setPlaceholder("/usr/local/Cellar").setValue(this.plugin.settings.d2Path).onChange(async (value) => {
|
||||
this.plugin.settings.d2Path = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
if (this.plugin.settings.layoutEngine === LAYOUT_ENGINES.TALA.value) {
|
||||
this.addTALASettings();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// src/processor.ts
|
||||
var import_obsidian2 = require("obsidian");
|
||||
var import_child_process = require("child_process");
|
||||
var import_path = require("path");
|
||||
var import_lodash = __toESM(require_lodash());
|
||||
var import_os = __toESM(require("os"));
|
||||
var D2Processor = class {
|
||||
constructor(plugin) {
|
||||
this.attemptExport = async (source, el, ctx) => {
|
||||
var _a;
|
||||
el.createEl("h6", {
|
||||
text: "Generating D2 diagram...",
|
||||
cls: "D2__Loading"
|
||||
});
|
||||
const pageContainer = ctx.containerEl;
|
||||
let pageID = pageContainer.dataset.pageID;
|
||||
if (!pageID) {
|
||||
pageID = Math.floor(Math.random() * Date.now()).toString();
|
||||
pageContainer.dataset.pageID = pageID;
|
||||
}
|
||||
let debouncedFunc = this.debouncedMap.get(pageID);
|
||||
if (!debouncedFunc) {
|
||||
await this.export(source, el, ctx);
|
||||
debouncedFunc = (0, import_lodash.default)(this.export, this.plugin.settings.debounce, {
|
||||
leading: true
|
||||
});
|
||||
this.debouncedMap.set(pageID, debouncedFunc);
|
||||
return;
|
||||
}
|
||||
(_a = this.abortControllerMap.get(pageID)) == null ? void 0 : _a.abort();
|
||||
const newAbortController = new AbortController();
|
||||
this.abortControllerMap.set(pageID, newAbortController);
|
||||
await debouncedFunc(source, el, ctx, newAbortController.signal);
|
||||
};
|
||||
this.isValidUrl = (urlString) => {
|
||||
let url;
|
||||
try {
|
||||
url = new URL(urlString);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return url.protocol === "http:" || url.protocol === "https:";
|
||||
};
|
||||
this.formatLinks = (svgEl) => {
|
||||
const links = svgEl.querySelectorAll("a");
|
||||
links.forEach((link) => {
|
||||
var _a;
|
||||
const href = (_a = link.getAttribute("href")) != null ? _a : "";
|
||||
if (!this.isValidUrl(href)) {
|
||||
link.classList.add("internal-link");
|
||||
link.setAttribute("data-href", href);
|
||||
link.setAttribute("target", "_blank");
|
||||
link.setAttribute("rel", "noopener");
|
||||
}
|
||||
});
|
||||
};
|
||||
this.sanitizeSVGIDs = (svgEl, docID) => {
|
||||
const overrides = svgEl.querySelectorAll("marker, mask, filter");
|
||||
const overrideIDs = [];
|
||||
overrides.forEach((override) => {
|
||||
const id = override.getAttribute("id");
|
||||
if (id) {
|
||||
overrideIDs.push(id);
|
||||
}
|
||||
});
|
||||
return overrideIDs.reduce((svgHTML, overrideID) => {
|
||||
return svgHTML.replaceAll(overrideID, [overrideID, docID].join("-"));
|
||||
}, svgEl.outerHTML);
|
||||
};
|
||||
this.export = async (source, el, ctx, signal) => {
|
||||
try {
|
||||
const image = await this.generatePreview(source, signal);
|
||||
if (image) {
|
||||
el.empty();
|
||||
this.prevImage = image;
|
||||
this.insertImage(image, el, ctx);
|
||||
const button = new import_obsidian2.ButtonComponent(el).setClass("Preview__Recompile").setIcon("recompile").onClick((e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
el.empty();
|
||||
this.attemptExport(source, el, ctx);
|
||||
});
|
||||
button.buttonEl.createEl("span", {
|
||||
text: "Recompile"
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
el.empty();
|
||||
const errorEl = el.createEl("pre", {
|
||||
cls: "markdown-rendered pre Preview__Error"
|
||||
});
|
||||
errorEl.createEl("code", {
|
||||
text: "D2 Compilation Error:",
|
||||
cls: "Preview__Error--Title"
|
||||
});
|
||||
errorEl.createEl("code", {
|
||||
text: err.message
|
||||
});
|
||||
if (this.prevImage) {
|
||||
this.insertImage(this.prevImage, el, ctx);
|
||||
}
|
||||
} finally {
|
||||
const pageContainer = ctx.containerEl;
|
||||
this.abortControllerMap.delete(pageContainer.dataset.id);
|
||||
}
|
||||
};
|
||||
this.plugin = plugin;
|
||||
this.debouncedMap = /* @__PURE__ */ new Map();
|
||||
this.abortControllerMap = /* @__PURE__ */ new Map();
|
||||
}
|
||||
insertImage(image, el, ctx) {
|
||||
const parser = new DOMParser();
|
||||
const svg = parser.parseFromString(image, "image/svg+xml");
|
||||
const containerEl = el.createDiv();
|
||||
const svgEl = svg.documentElement;
|
||||
svgEl.style.maxHeight = `${this.plugin.settings.containerHeight}px`;
|
||||
svgEl.style.maxWidth = "100%";
|
||||
svgEl.style.height = "fit-content";
|
||||
svgEl.style.width = "fit-content";
|
||||
this.formatLinks(svgEl);
|
||||
containerEl.innerHTML = this.sanitizeSVGIDs(svgEl, ctx.docId);
|
||||
}
|
||||
async generatePreview(source, signal) {
|
||||
var _a, _b;
|
||||
const pathArray = [process.env.PATH, "/opt/homebrew/bin", "/usr/local/bin"];
|
||||
if (import_os.default.platform() === "win32") {
|
||||
pathArray.push(`C:Program FilesD2`);
|
||||
} else {
|
||||
pathArray.push(`${process.env.HOME}/.local/bin`);
|
||||
}
|
||||
let GOPATH = "";
|
||||
try {
|
||||
GOPATH = (0, import_child_process.execSync)("go env GOPATH", {
|
||||
env: {
|
||||
...process.env,
|
||||
PATH: pathArray.join(import_path.delimiter)
|
||||
}
|
||||
}).toString();
|
||||
} catch (error) {
|
||||
}
|
||||
if (GOPATH) {
|
||||
pathArray.push(`${GOPATH.replace("\n", "")}/bin`);
|
||||
}
|
||||
if (this.plugin.settings.d2Path) {
|
||||
pathArray.push(this.plugin.settings.d2Path);
|
||||
}
|
||||
const options = {
|
||||
...process.env,
|
||||
env: {
|
||||
PATH: pathArray.join(import_path.delimiter)
|
||||
},
|
||||
signal
|
||||
};
|
||||
if (this.plugin.settings.apiToken) {
|
||||
options.env.TSTRUCT_TOKEN = this.plugin.settings.apiToken;
|
||||
}
|
||||
let args = [
|
||||
`d2`,
|
||||
"-",
|
||||
`--theme=${this.plugin.settings.theme}`,
|
||||
`--layout=${this.plugin.settings.layoutEngine}`,
|
||||
`--pad=${this.plugin.settings.pad}`,
|
||||
`--sketch=${this.plugin.settings.sketch}`,
|
||||
"--bundle=false",
|
||||
"--scale=1"
|
||||
];
|
||||
const cmd = args.join(" ");
|
||||
const child = (0, import_child_process.exec)(cmd, options);
|
||||
(_a = child.stdin) == null ? void 0 : _a.write(source);
|
||||
(_b = child.stdin) == null ? void 0 : _b.end();
|
||||
let stdout;
|
||||
let stderr;
|
||||
if (child.stdout) {
|
||||
child.stdout.on("data", (data) => {
|
||||
if (stdout === void 0) {
|
||||
stdout = data;
|
||||
} else {
|
||||
stdout += data;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (child.stderr) {
|
||||
child.stderr.on("data", (data) => {
|
||||
if (stderr === void 0) {
|
||||
stderr = data;
|
||||
} else {
|
||||
stderr += data;
|
||||
}
|
||||
});
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
child.on("error", reject);
|
||||
child.on("close", (code) => {
|
||||
if (code === 0) {
|
||||
resolve(stdout);
|
||||
return;
|
||||
} else if (stderr) {
|
||||
console.error(stderr);
|
||||
reject(new Error(stderr));
|
||||
} else if (stdout) {
|
||||
console.error(stdout);
|
||||
reject(new Error(stdout));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// src/main.ts
|
||||
var D2Plugin = class extends import_obsidian3.Plugin {
|
||||
async onload() {
|
||||
(0, import_obsidian3.addIcon)("recompile", RecompileIcon);
|
||||
await this.loadSettings();
|
||||
this.addSettingTab(new D2SettingsTab(this.app, this));
|
||||
const processor = new D2Processor(this);
|
||||
this.registerMarkdownCodeBlockProcessor("d2", processor.attemptExport);
|
||||
this.processor = processor;
|
||||
}
|
||||
onunload() {
|
||||
const abortControllers = this.processor.abortControllerMap.values();
|
||||
Array.from(abortControllers).forEach((controller) => {
|
||||
controller.abort();
|
||||
});
|
||||
}
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
}
|
||||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
};
|
10
.obsidian/plugins/d2-obsidian/manifest.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "d2-obsidian",
|
||||
"name": "D2",
|
||||
"version": "1.1.4",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "The official D2 plugin for Obsidian. D2 is a modern diagram scripting language that turns text to diagrams.",
|
||||
"author": "Terrastruct",
|
||||
"authorUrl": "https://d2lang.com",
|
||||
"isDesktopOnly": true
|
||||
}
|
49
.obsidian/plugins/d2-obsidian/styles.css
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
.D2__Loading {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.Preview__Error--Title {
|
||||
color: #be0b41 !important;
|
||||
}
|
||||
|
||||
.Preview__Error {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
white-space: pre;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.Preview__Recompile {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: 4px;
|
||||
height: 24px;
|
||||
padding: 6px;
|
||||
background-color: white !important;
|
||||
color: #2e3346;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
box-shadow: none !important;
|
||||
border: 1px solid #dee1eb;
|
||||
filter: drop-shadow(1px 1px 4px rgba(31, 36, 58, 0.08));
|
||||
}
|
||||
|
||||
.Preview__Recompile:hover {
|
||||
filter: drop-shadow(2px 2px 16px rgba(31, 36, 58, 0.12));
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.Preview__Recompile > .svg-icon {
|
||||
height: 12px !important;
|
||||
width: 12px !important;
|
||||
}
|
||||
|
||||
.block-language-d2 {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.Preview__Recompile {
|
||||
display: none;
|
||||
}
|
||||
}
|
169
.obsidian/plugins/execute-code/data.json
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
{
|
||||
"lastOpenLanguageTab": "c",
|
||||
"timeout": 10000,
|
||||
"allowInput": true,
|
||||
"wslMode": false,
|
||||
"shellWSLMode": false,
|
||||
"onlyCurrentBlock": false,
|
||||
"nodePath": "node",
|
||||
"nodeArgs": "",
|
||||
"jsFileExtension": "js",
|
||||
"jsInject": "",
|
||||
"tsPath": "ts-node",
|
||||
"tsArgs": "",
|
||||
"tsInject": "",
|
||||
"leanPath": "lean",
|
||||
"leanArgs": "",
|
||||
"leanInject": "",
|
||||
"luaPath": "lua",
|
||||
"luaArgs": "",
|
||||
"luaFileExtension": "lua",
|
||||
"luaInject": "",
|
||||
"dartPath": "dart",
|
||||
"dartArgs": "",
|
||||
"dartFileExtension": "dart",
|
||||
"dartInject": "",
|
||||
"csPath": "dotnet-script",
|
||||
"csArgs": "",
|
||||
"csFileExtension": "csx",
|
||||
"csInject": "",
|
||||
"pythonPath": "python",
|
||||
"pythonArgs": "",
|
||||
"pythonEmbedPlots": true,
|
||||
"pythonFileExtension": "py",
|
||||
"pythonInject": "",
|
||||
"shellPath": "bash",
|
||||
"shellArgs": "",
|
||||
"shellFileExtension": "sh",
|
||||
"shellInject": "",
|
||||
"batchPath": "call",
|
||||
"batchArgs": "",
|
||||
"batchFileExtension": "bat",
|
||||
"batchInject": "",
|
||||
"groovyPath": "groovy",
|
||||
"groovyArgs": "",
|
||||
"groovyFileExtension": "groovy",
|
||||
"groovyInject": "",
|
||||
"golangPath": "go",
|
||||
"golangArgs": "run",
|
||||
"golangFileExtension": "go",
|
||||
"goInject": "",
|
||||
"javaPath": "java",
|
||||
"javaArgs": "-ea",
|
||||
"javaFileExtension": "java",
|
||||
"javaInject": "",
|
||||
"maxPrologAnswers": 15,
|
||||
"prologInject": "",
|
||||
"powershellPath": "powershell",
|
||||
"powershellArgs": "-file",
|
||||
"powershellFileExtension": "ps1",
|
||||
"powershellInject": "$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding",
|
||||
"powershellEncoding": "latin1",
|
||||
"cargoPath": "cargo",
|
||||
"cargoEvalArgs": "",
|
||||
"rustInject": "",
|
||||
"cppRunner": "cling",
|
||||
"cppFileExtension": "cpp",
|
||||
"cppInject": "",
|
||||
"cppArgs": "",
|
||||
"cppUseMain": false,
|
||||
"clingPath": "gcc",
|
||||
"clingArgs": "",
|
||||
"clingStd": "c++17",
|
||||
"rustFileExtension": "rs",
|
||||
"RPath": "Rscript",
|
||||
"RArgs": "",
|
||||
"REmbedPlots": true,
|
||||
"RFileExtension": "R",
|
||||
"rInject": "",
|
||||
"kotlinPath": "kotlinc",
|
||||
"kotlinArgs": "-script",
|
||||
"kotlinFileExtension": "kts",
|
||||
"kotlinInject": "",
|
||||
"swiftPath": "swift",
|
||||
"swiftArgs": "",
|
||||
"swiftFileExtension": "swift",
|
||||
"swiftInject": "",
|
||||
"runghcPath": "runghc",
|
||||
"ghcPath": "ghc",
|
||||
"ghciPath": "ghci",
|
||||
"useGhci": false,
|
||||
"haskellInject": "",
|
||||
"mathematicaPath": "wolframscript",
|
||||
"mathematicaArgs": "-file",
|
||||
"mathematicaFileExtension": "wls",
|
||||
"mathematicaInject": "",
|
||||
"scalaPath": "scala",
|
||||
"scalaArgs": "",
|
||||
"scalaFileExtension": "scala",
|
||||
"scalaInject": "",
|
||||
"racketPath": "racket",
|
||||
"racketArgs": "",
|
||||
"racketFileExtension": "rkt",
|
||||
"racketInject": "#lang racket",
|
||||
"fsharpPath": "dotnet",
|
||||
"fsharpArgs": "",
|
||||
"fsharpInject": "",
|
||||
"fsharpFileExtension": "fsx",
|
||||
"cArgs": "",
|
||||
"cUseMain": true,
|
||||
"cInject": "",
|
||||
"rubyPath": "ruby",
|
||||
"rubyArgs": "",
|
||||
"rubyFileExtension": "rb",
|
||||
"rubyInject": "",
|
||||
"sqlPath": "psql",
|
||||
"sqlArgs": "-d <database> -U <user> -f",
|
||||
"sqlInject": "",
|
||||
"octavePath": "octave",
|
||||
"octaveArgs": "-q",
|
||||
"octaveFileExtension": "m",
|
||||
"octaveInject": "figure('visible','off') # Necessary to embed plots",
|
||||
"maximaPath": "maxima",
|
||||
"maximaArgs": "-qb",
|
||||
"maximaFileExtension": "mx",
|
||||
"maximaInject": "",
|
||||
"applescriptPath": "osascript",
|
||||
"applescriptArgs": "",
|
||||
"applescriptFileExtension": "scpt",
|
||||
"applescriptInject": "",
|
||||
"zigPath": "zig",
|
||||
"zigArgs": "run",
|
||||
"zigInject": "",
|
||||
"ocamlPath": "ocaml",
|
||||
"ocamlArgs": "",
|
||||
"ocamlInject": "",
|
||||
"jsInteractive": true,
|
||||
"tsInteractive": false,
|
||||
"csInteractive": false,
|
||||
"leanInteractive": false,
|
||||
"luaInteractive": false,
|
||||
"dartInteractive": false,
|
||||
"pythonInteractive": true,
|
||||
"cppInteractive": false,
|
||||
"prologInteractive": false,
|
||||
"shellInteractive": false,
|
||||
"batchInteractive": false,
|
||||
"bashInteractive": false,
|
||||
"groovyInteractive": false,
|
||||
"rInteractive": false,
|
||||
"goInteractive": false,
|
||||
"rustInteractive": false,
|
||||
"javaInteractive": false,
|
||||
"powershellInteractive": false,
|
||||
"kotlinInteractive": false,
|
||||
"swiftInteractive": false,
|
||||
"mathematicaInteractive": false,
|
||||
"haskellInteractive": false,
|
||||
"scalaInteractive": false,
|
||||
"fsharpInteractive": false,
|
||||
"cInteractive": false,
|
||||
"racketInteractive": false,
|
||||
"rubyInteractive": false,
|
||||
"sqlInteractive": false,
|
||||
"octaveInteractive": false,
|
||||
"maximaInteractive": false,
|
||||
"applescriptInteractive": false,
|
||||
"zigInteractive": false,
|
||||
"ocamlInteractive": false
|
||||
}
|
13328
.obsidian/plugins/execute-code/main.js
vendored
Normal file
10
.obsidian/plugins/execute-code/manifest.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "execute-code",
|
||||
"name": "Execute Code",
|
||||
"version": "1.12.0",
|
||||
"minAppVersion": "1.2.8",
|
||||
"description": "Allows to execute code snippets within a note. Supported programming languages: C, CPP, Dart, Golang, Groovy, Kotlin, Java, JavaScript, TypeScript, Lean, Lua, CSharp, Prolog, Rust, Python, R, Ruby, Wolfram Mathematica, Haskell, Scala, Racket, F#, Batch, Shell & Powershell.",
|
||||
"author": "twibiral",
|
||||
"authorUrl": "https://www.github.com/twibiral",
|
||||
"isDesktopOnly": true
|
||||
}
|
218
.obsidian/plugins/execute-code/styles.css
vendored
Normal file
@ -0,0 +1,218 @@
|
||||
/* @settings
|
||||
|
||||
name: Execute Code Settings
|
||||
id: obsidian-execute-code
|
||||
settings:
|
||||
-
|
||||
id: color-section-title
|
||||
title: Color Settings
|
||||
type: heading
|
||||
level: 3
|
||||
-
|
||||
id: use-custom-output-color
|
||||
title: Custom Code Output Color
|
||||
description: Use a custom color for the output of code blocks
|
||||
type: class-toggle
|
||||
default: false
|
||||
-
|
||||
id: code-output-text-color
|
||||
title: Output Text Color
|
||||
type: variable-color
|
||||
format: hex
|
||||
opacity: false
|
||||
default: '#FFFFFF'
|
||||
-
|
||||
id: use-custom-error-color
|
||||
title: Custom Code Error Color
|
||||
description: Use a custom color for the error output of code blocks
|
||||
type: class-toggle
|
||||
default: false
|
||||
-
|
||||
id: code-error-text-color
|
||||
title: Error Text Color
|
||||
type: variable-color
|
||||
format: hex
|
||||
opacity: false
|
||||
default: '#FF0000'
|
||||
*/
|
||||
|
||||
button.run-code-button {
|
||||
display: none;
|
||||
color: var(--text-muted);
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
margin: 5px;
|
||||
padding: 5px 20px 5px 20px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
button.clear-button {
|
||||
display: none;
|
||||
color: var(--text-muted);
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
margin: 5px;
|
||||
padding: 5px 20px 5px 20px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
pre:hover .run-code-button, pre:hover .clear-button {
|
||||
display: block;
|
||||
}
|
||||
|
||||
pre:hover .run-button-disabled, pre:hover .clear-button-disabled {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.run-button-disabled, .clear-button-disabled {
|
||||
display: none;
|
||||
}
|
||||
|
||||
pre:hover code.language-output {
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
:not(.use-custom-output-color) code.language-output span.stdout {
|
||||
color: var(--text-muted) !important;
|
||||
}
|
||||
|
||||
.use-custom-output-color code.language-output span.stdout {
|
||||
color: var(--code-output-text-color) !important;
|
||||
}
|
||||
|
||||
:not(.use-custom-error-color) code.language-output span.stderr {
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
.use-custom-error-color code.language-output span.stderr {
|
||||
color: var(--code-error-text-color) !important;
|
||||
}
|
||||
|
||||
code.language-output hr {
|
||||
margin: 0 0 1em;
|
||||
}
|
||||
|
||||
.settings-code-input-box textarea, .settings-code-input-box input {
|
||||
min-width: 400px;
|
||||
min-height: 100px;
|
||||
font-family: monospace;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
input.interactive-stdin {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.manage-executors-view h3 {
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
.manage-executors-view ul {
|
||||
margin: 1em;
|
||||
padding: 0;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.manage-executors-view ul li {
|
||||
padding: 0.5em;
|
||||
background: var(--background-primary-alt);
|
||||
border-radius: 4px;
|
||||
display: grid;
|
||||
flex-direction: column;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.manage-executors-view small {
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
letter-spacing: 0.1ch;
|
||||
grid-row: 1;
|
||||
}
|
||||
|
||||
.manage-executors-view .filename {
|
||||
grid-row: 2;
|
||||
}
|
||||
|
||||
.manage-executors-view li button {
|
||||
grid-column: 2;
|
||||
grid-row: 1 / 3;
|
||||
margin: 0;
|
||||
padding: 0.25em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--text-muted);
|
||||
background: none;
|
||||
}
|
||||
|
||||
.manage-executors-view li button:hover {
|
||||
background: var(--background-tertiary);
|
||||
color: var(--icon-color-hover);
|
||||
}
|
||||
|
||||
.manage-executors-view > div {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.manage-executors-view .empty-state {
|
||||
color: var(--text-muted);
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
.has-run-code-button {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.has-run-code-button pre {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.load-state-indicator {
|
||||
position: absolute;
|
||||
top: 0.1em;
|
||||
left: -2em;
|
||||
width: 2em;
|
||||
height: 2em;
|
||||
background: var(--background-primary-alt);
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
color: var(--tx1);
|
||||
transform: translateX(2em);
|
||||
transition: transform 0.25s, opacity 0.25s;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.load-state-indicator svg {
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
margin: 0.25em;
|
||||
}
|
||||
|
||||
.load-state-indicator.visible {
|
||||
transform: translateX(0);
|
||||
transform: translateX(var(--folding-offset, 0));
|
||||
opacity: 1;
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.load-state-indicator::before {
|
||||
content: "";
|
||||
box-shadow: -1em 0 1em -0.75em inset var(--background-modifier-box-shadow);
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform: translateX(-2em);
|
||||
opacity: 0;
|
||||
transition: transform 0.25s, opacity 0.25s;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.load-state-indicator.visible::before {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
799
.obsidian/plugins/obsidian-excalidraw-plugin/data.json
vendored
Normal file
@ -0,0 +1,799 @@
|
||||
{
|
||||
"folder": "Excalidraw",
|
||||
"cropFolder": "",
|
||||
"annotateFolder": "",
|
||||
"embedUseExcalidrawFolder": false,
|
||||
"templateFilePath": "Excalidraw/Template.excalidraw",
|
||||
"scriptFolderPath": "Excalidraw/Scripts",
|
||||
"fontAssetsPath": "Excalidraw/CJK Fonts",
|
||||
"loadChineseFonts": false,
|
||||
"loadJapaneseFonts": false,
|
||||
"loadKoreanFonts": false,
|
||||
"compress": true,
|
||||
"decompressForMDView": false,
|
||||
"onceOffCompressFlagReset": true,
|
||||
"onceOffGPTVersionReset": true,
|
||||
"autosave": true,
|
||||
"autosaveIntervalDesktop": 60000,
|
||||
"autosaveIntervalMobile": 30000,
|
||||
"drawingFilenamePrefix": "Drawing ",
|
||||
"drawingEmbedPrefixWithFilename": true,
|
||||
"drawingFilnameEmbedPostfix": " ",
|
||||
"drawingFilenameDateTime": "YYYY-MM-DD HH.mm.ss",
|
||||
"useExcalidrawExtension": true,
|
||||
"cropPrefix": "cropped_",
|
||||
"annotatePrefix": "annotated_",
|
||||
"annotatePreserveSize": false,
|
||||
"previewImageType": "SVGIMG",
|
||||
"renderingConcurrency": 3,
|
||||
"allowImageCache": true,
|
||||
"allowImageCacheInScene": true,
|
||||
"displayExportedImageIfAvailable": false,
|
||||
"previewMatchObsidianTheme": false,
|
||||
"width": "400",
|
||||
"height": "",
|
||||
"overrideObsidianFontSize": false,
|
||||
"dynamicStyling": "colorful",
|
||||
"isLeftHanded": false,
|
||||
"iframeMatchExcalidrawTheme": true,
|
||||
"matchTheme": false,
|
||||
"matchThemeAlways": false,
|
||||
"matchThemeTrigger": false,
|
||||
"defaultMode": "normal",
|
||||
"defaultPenMode": "never",
|
||||
"penModeDoubleTapEraser": true,
|
||||
"penModeSingleFingerPanning": true,
|
||||
"penModeCrosshairVisible": true,
|
||||
"renderImageInMarkdownReadingMode": false,
|
||||
"renderImageInHoverPreviewForMDNotes": false,
|
||||
"renderImageInMarkdownToPDF": false,
|
||||
"allowPinchZoom": false,
|
||||
"allowWheelZoom": false,
|
||||
"zoomToFitOnOpen": true,
|
||||
"zoomToFitOnResize": true,
|
||||
"zoomToFitMaxLevel": 2,
|
||||
"linkPrefix": "📍",
|
||||
"urlPrefix": "🌐",
|
||||
"parseTODO": false,
|
||||
"todo": "☐",
|
||||
"done": "🗹",
|
||||
"hoverPreviewWithoutCTRL": false,
|
||||
"linkOpacity": 1,
|
||||
"openInAdjacentPane": true,
|
||||
"showSecondOrderLinks": true,
|
||||
"focusOnFileTab": true,
|
||||
"openInMainWorkspace": true,
|
||||
"showLinkBrackets": true,
|
||||
"allowCtrlClick": true,
|
||||
"forceWrap": false,
|
||||
"pageTransclusionCharLimit": 200,
|
||||
"wordWrappingDefault": 0,
|
||||
"removeTransclusionQuoteSigns": true,
|
||||
"iframelyAllowed": true,
|
||||
"pngExportScale": 1,
|
||||
"exportWithTheme": true,
|
||||
"exportWithBackground": true,
|
||||
"exportPaddingSVG": 10,
|
||||
"exportEmbedScene": false,
|
||||
"keepInSync": false,
|
||||
"autoexportSVG": false,
|
||||
"autoexportPNG": false,
|
||||
"autoExportLightAndDark": false,
|
||||
"autoexportExcalidraw": false,
|
||||
"embedType": "excalidraw",
|
||||
"embedMarkdownCommentLinks": true,
|
||||
"embedWikiLink": true,
|
||||
"syncExcalidraw": false,
|
||||
"experimentalFileType": false,
|
||||
"experimentalFileTag": "✏️",
|
||||
"experimentalLivePreview": true,
|
||||
"fadeOutExcalidrawMarkup": false,
|
||||
"loadPropertySuggestions": true,
|
||||
"experimentalEnableFourthFont": false,
|
||||
"experimantalFourthFont": "Virgil",
|
||||
"addDummyTextElement": false,
|
||||
"zoteroCompatibility": false,
|
||||
"fieldSuggester": true,
|
||||
"compatibilityMode": false,
|
||||
"drawingOpenCount": 0,
|
||||
"library": "deprecated",
|
||||
"library2": {
|
||||
"type": "excalidrawlib",
|
||||
"version": 2,
|
||||
"source": "https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/2.8.3",
|
||||
"libraryItems": []
|
||||
},
|
||||
"imageElementNotice": true,
|
||||
"mdSVGwidth": 500,
|
||||
"mdSVGmaxHeight": 800,
|
||||
"mdFont": "Virgil",
|
||||
"mdFontColor": "Black",
|
||||
"mdBorderColor": "Black",
|
||||
"mdCSS": "",
|
||||
"scriptEngineSettings": {},
|
||||
"defaultTrayMode": true,
|
||||
"previousRelease": "2.8.3",
|
||||
"showReleaseNotes": true,
|
||||
"showNewVersionNotification": true,
|
||||
"latexBoilerplate": "\\color{blue}",
|
||||
"latexPreambleLocation": "preamble.sty",
|
||||
"taskboneEnabled": false,
|
||||
"taskboneAPIkey": "",
|
||||
"pinnedScripts": [],
|
||||
"customPens": [
|
||||
{
|
||||
"type": "default",
|
||||
"freedrawOnly": false,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 0,
|
||||
"roughness": 0,
|
||||
"penOptions": {
|
||||
"highlighter": false,
|
||||
"constantPressure": false,
|
||||
"hasOutline": false,
|
||||
"outlineWidth": 1,
|
||||
"options": {
|
||||
"thinning": 0.6,
|
||||
"smoothing": 0.5,
|
||||
"streamline": 0.5,
|
||||
"easing": "easeOutSine",
|
||||
"start": {
|
||||
"cap": true,
|
||||
"taper": 0,
|
||||
"easing": "linear"
|
||||
},
|
||||
"end": {
|
||||
"cap": true,
|
||||
"taper": 0,
|
||||
"easing": "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "highlighter",
|
||||
"freedrawOnly": true,
|
||||
"strokeColor": "#FFC47C",
|
||||
"backgroundColor": "#FFC47C",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"roughness": null,
|
||||
"penOptions": {
|
||||
"highlighter": true,
|
||||
"constantPressure": true,
|
||||
"hasOutline": true,
|
||||
"outlineWidth": 4,
|
||||
"options": {
|
||||
"thinning": 1,
|
||||
"smoothing": 0.5,
|
||||
"streamline": 0.5,
|
||||
"easing": "linear",
|
||||
"start": {
|
||||
"taper": 0,
|
||||
"cap": true,
|
||||
"easing": "linear"
|
||||
},
|
||||
"end": {
|
||||
"taper": 0,
|
||||
"cap": true,
|
||||
"easing": "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "finetip",
|
||||
"freedrawOnly": false,
|
||||
"strokeColor": "#3E6F8D",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 0.5,
|
||||
"roughness": 0,
|
||||
"penOptions": {
|
||||
"highlighter": false,
|
||||
"hasOutline": false,
|
||||
"outlineWidth": 1,
|
||||
"constantPressure": true,
|
||||
"options": {
|
||||
"smoothing": 0.4,
|
||||
"thinning": -0.5,
|
||||
"streamline": 0.4,
|
||||
"easing": "linear",
|
||||
"start": {
|
||||
"taper": 5,
|
||||
"cap": false,
|
||||
"easing": "linear"
|
||||
},
|
||||
"end": {
|
||||
"taper": 5,
|
||||
"cap": false,
|
||||
"easing": "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "fountain",
|
||||
"freedrawOnly": false,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 2,
|
||||
"roughness": 0,
|
||||
"penOptions": {
|
||||
"highlighter": false,
|
||||
"constantPressure": false,
|
||||
"hasOutline": false,
|
||||
"outlineWidth": 1,
|
||||
"options": {
|
||||
"smoothing": 0.2,
|
||||
"thinning": 0.6,
|
||||
"streamline": 0.2,
|
||||
"easing": "easeInOutSine",
|
||||
"start": {
|
||||
"taper": 150,
|
||||
"cap": true,
|
||||
"easing": "linear"
|
||||
},
|
||||
"end": {
|
||||
"taper": 1,
|
||||
"cap": true,
|
||||
"easing": "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "marker",
|
||||
"freedrawOnly": true,
|
||||
"strokeColor": "#B83E3E",
|
||||
"backgroundColor": "#FF7C7C",
|
||||
"fillStyle": "dashed",
|
||||
"strokeWidth": 2,
|
||||
"roughness": 3,
|
||||
"penOptions": {
|
||||
"highlighter": false,
|
||||
"constantPressure": true,
|
||||
"hasOutline": true,
|
||||
"outlineWidth": 4,
|
||||
"options": {
|
||||
"thinning": 1,
|
||||
"smoothing": 0.5,
|
||||
"streamline": 0.5,
|
||||
"easing": "linear",
|
||||
"start": {
|
||||
"taper": 0,
|
||||
"cap": true,
|
||||
"easing": "linear"
|
||||
},
|
||||
"end": {
|
||||
"taper": 0,
|
||||
"cap": true,
|
||||
"easing": "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "thick-thin",
|
||||
"freedrawOnly": true,
|
||||
"strokeColor": "#CECDCC",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 0,
|
||||
"roughness": null,
|
||||
"penOptions": {
|
||||
"highlighter": true,
|
||||
"constantPressure": true,
|
||||
"hasOutline": false,
|
||||
"outlineWidth": 1,
|
||||
"options": {
|
||||
"thinning": 1,
|
||||
"smoothing": 0.5,
|
||||
"streamline": 0.5,
|
||||
"easing": "linear",
|
||||
"start": {
|
||||
"taper": 0,
|
||||
"cap": true,
|
||||
"easing": "linear"
|
||||
},
|
||||
"end": {
|
||||
"cap": true,
|
||||
"taper": true,
|
||||
"easing": "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "thin-thick-thin",
|
||||
"freedrawOnly": true,
|
||||
"strokeColor": "#CECDCC",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 0,
|
||||
"roughness": null,
|
||||
"penOptions": {
|
||||
"highlighter": true,
|
||||
"constantPressure": true,
|
||||
"hasOutline": false,
|
||||
"outlineWidth": 1,
|
||||
"options": {
|
||||
"thinning": 1,
|
||||
"smoothing": 0.5,
|
||||
"streamline": 0.5,
|
||||
"easing": "linear",
|
||||
"start": {
|
||||
"cap": true,
|
||||
"taper": true,
|
||||
"easing": "linear"
|
||||
},
|
||||
"end": {
|
||||
"cap": true,
|
||||
"taper": true,
|
||||
"easing": "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "default",
|
||||
"freedrawOnly": false,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 0,
|
||||
"roughness": 0,
|
||||
"penOptions": {
|
||||
"highlighter": false,
|
||||
"constantPressure": false,
|
||||
"hasOutline": false,
|
||||
"outlineWidth": 1,
|
||||
"options": {
|
||||
"thinning": 0.6,
|
||||
"smoothing": 0.5,
|
||||
"streamline": 0.5,
|
||||
"easing": "easeOutSine",
|
||||
"start": {
|
||||
"cap": true,
|
||||
"taper": 0,
|
||||
"easing": "linear"
|
||||
},
|
||||
"end": {
|
||||
"cap": true,
|
||||
"taper": 0,
|
||||
"easing": "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "default",
|
||||
"freedrawOnly": false,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 0,
|
||||
"roughness": 0,
|
||||
"penOptions": {
|
||||
"highlighter": false,
|
||||
"constantPressure": false,
|
||||
"hasOutline": false,
|
||||
"outlineWidth": 1,
|
||||
"options": {
|
||||
"thinning": 0.6,
|
||||
"smoothing": 0.5,
|
||||
"streamline": 0.5,
|
||||
"easing": "easeOutSine",
|
||||
"start": {
|
||||
"cap": true,
|
||||
"taper": 0,
|
||||
"easing": "linear"
|
||||
},
|
||||
"end": {
|
||||
"cap": true,
|
||||
"taper": 0,
|
||||
"easing": "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "default",
|
||||
"freedrawOnly": false,
|
||||
"strokeColor": "#000000",
|
||||
"backgroundColor": "transparent",
|
||||
"fillStyle": "hachure",
|
||||
"strokeWidth": 0,
|
||||
"roughness": 0,
|
||||
"penOptions": {
|
||||
"highlighter": false,
|
||||
"constantPressure": false,
|
||||
"hasOutline": false,
|
||||
"outlineWidth": 1,
|
||||
"options": {
|
||||
"thinning": 0.6,
|
||||
"smoothing": 0.5,
|
||||
"streamline": 0.5,
|
||||
"easing": "easeOutSine",
|
||||
"start": {
|
||||
"cap": true,
|
||||
"taper": 0,
|
||||
"easing": "linear"
|
||||
},
|
||||
"end": {
|
||||
"cap": true,
|
||||
"taper": 0,
|
||||
"easing": "linear"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"numberOfCustomPens": 0,
|
||||
"pdfScale": 4,
|
||||
"pdfBorderBox": true,
|
||||
"pdfFrame": false,
|
||||
"pdfGapSize": 20,
|
||||
"pdfGroupPages": false,
|
||||
"pdfLockAfterImport": true,
|
||||
"pdfNumColumns": 1,
|
||||
"pdfNumRows": 1,
|
||||
"pdfDirection": "right",
|
||||
"pdfImportScale": 0.3,
|
||||
"gridSettings": {
|
||||
"DYNAMIC_COLOR": true,
|
||||
"COLOR": "#000000",
|
||||
"OPACITY": 50
|
||||
},
|
||||
"laserSettings": {
|
||||
"DECAY_LENGTH": 50,
|
||||
"DECAY_TIME": 1000,
|
||||
"COLOR": "#ff0000"
|
||||
},
|
||||
"embeddableMarkdownDefaults": {
|
||||
"useObsidianDefaults": false,
|
||||
"backgroundMatchCanvas": false,
|
||||
"backgroundMatchElement": true,
|
||||
"backgroundColor": "#fff",
|
||||
"backgroundOpacity": 60,
|
||||
"borderMatchElement": true,
|
||||
"borderColor": "#fff",
|
||||
"borderOpacity": 0,
|
||||
"filenameVisible": false
|
||||
},
|
||||
"markdownNodeOneClickEditing": false,
|
||||
"canvasImmersiveEmbed": true,
|
||||
"startupScriptPath": "",
|
||||
"openAIAPIToken": "",
|
||||
"openAIDefaultTextModel": "gpt-3.5-turbo-1106",
|
||||
"openAIDefaultVisionModel": "gpt-4o",
|
||||
"openAIDefaultImageGenerationModel": "dall-e-3",
|
||||
"openAIURL": "https://api.openai.com/v1/chat/completions",
|
||||
"openAIImageGenerationURL": "https://api.openai.com/v1/images/generations",
|
||||
"openAIImageEditsURL": "https://api.openai.com/v1/images/edits",
|
||||
"openAIImageVariationURL": "https://api.openai.com/v1/images/variations",
|
||||
"modifierKeyConfig": {
|
||||
"Mac": {
|
||||
"LocalFileDragAction": {
|
||||
"defaultAction": "image-import",
|
||||
"rules": [
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "image-import"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": true,
|
||||
"meta_ctrl": false,
|
||||
"result": "link"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "image-url"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": true,
|
||||
"meta_ctrl": false,
|
||||
"result": "embeddable"
|
||||
}
|
||||
]
|
||||
},
|
||||
"WebBrowserDragAction": {
|
||||
"defaultAction": "image-url",
|
||||
"rules": [
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "image-url"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": true,
|
||||
"meta_ctrl": false,
|
||||
"result": "link"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": true,
|
||||
"meta_ctrl": false,
|
||||
"result": "embeddable"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "image-import"
|
||||
}
|
||||
]
|
||||
},
|
||||
"InternalDragAction": {
|
||||
"defaultAction": "link",
|
||||
"rules": [
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "link"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": true,
|
||||
"result": "embeddable"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "image"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": true,
|
||||
"result": "image-fullsize"
|
||||
}
|
||||
]
|
||||
},
|
||||
"LinkClickAction": {
|
||||
"defaultAction": "new-tab",
|
||||
"rules": [
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "active-pane"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "new-tab"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": true,
|
||||
"meta_ctrl": false,
|
||||
"result": "new-pane"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": true,
|
||||
"meta_ctrl": false,
|
||||
"result": "popout-window"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": true,
|
||||
"result": "md-properties"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Win": {
|
||||
"LocalFileDragAction": {
|
||||
"defaultAction": "image-import",
|
||||
"rules": [
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "image-import"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "link"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "image-url"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "embeddable"
|
||||
}
|
||||
]
|
||||
},
|
||||
"WebBrowserDragAction": {
|
||||
"defaultAction": "image-url",
|
||||
"rules": [
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "image-url"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "link"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "embeddable"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "image-import"
|
||||
}
|
||||
]
|
||||
},
|
||||
"InternalDragAction": {
|
||||
"defaultAction": "link",
|
||||
"rules": [
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "link"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "embeddable"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "image"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": true,
|
||||
"meta_ctrl": false,
|
||||
"result": "image-fullsize"
|
||||
}
|
||||
]
|
||||
},
|
||||
"LinkClickAction": {
|
||||
"defaultAction": "new-tab",
|
||||
"rules": [
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": false,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "active-pane"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": false,
|
||||
"result": "new-tab"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": true,
|
||||
"meta_ctrl": false,
|
||||
"result": "new-pane"
|
||||
},
|
||||
{
|
||||
"shift": true,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": true,
|
||||
"meta_ctrl": false,
|
||||
"result": "popout-window"
|
||||
},
|
||||
{
|
||||
"shift": false,
|
||||
"ctrl_cmd": true,
|
||||
"alt_opt": false,
|
||||
"meta_ctrl": true,
|
||||
"result": "md-properties"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"slidingPanesSupport": false,
|
||||
"areaZoomLimit": 1,
|
||||
"longPressDesktop": 500,
|
||||
"longPressMobile": 500,
|
||||
"doubleClickLinkOpenViewMode": true,
|
||||
"isDebugMode": false,
|
||||
"rank": "Bronze",
|
||||
"modifierKeyOverrides": [
|
||||
{
|
||||
"modifiers": [
|
||||
"Mod"
|
||||
],
|
||||
"key": "Enter"
|
||||
},
|
||||
{
|
||||
"modifiers": [
|
||||
"Mod"
|
||||
],
|
||||
"key": "k"
|
||||
},
|
||||
{
|
||||
"modifiers": [
|
||||
"Mod"
|
||||
],
|
||||
"key": "G"
|
||||
}
|
||||
],
|
||||
"showSplashscreen": true,
|
||||
"pdfSettings": {
|
||||
"pageSize": "A4",
|
||||
"pageOrientation": "portrait",
|
||||
"fitToPage": 1,
|
||||
"paperColor": "white",
|
||||
"customPaperColor": "#ffffff",
|
||||
"alignment": "center",
|
||||
"margin": "normal"
|
||||
}
|
||||
}
|
10
.obsidian/plugins/obsidian-excalidraw-plugin/main.js
vendored
Normal file
12
.obsidian/plugins/obsidian-excalidraw-plugin/manifest.json
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.8.3",
|
||||
"minAppVersion": "1.1.6",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
"authorUrl": "https://www.zsolt.blog",
|
||||
"fundingUrl": "https://ko-fi.com/zsolt",
|
||||
"helpUrl": "https://github.com/zsviczian/obsidian-excalidraw-plugin#readme",
|
||||
"isDesktopOnly": false
|
||||
}
|
1
.obsidian/plugins/obsidian-excalidraw-plugin/styles.css
vendored
Normal file
2
.obsidian/plugins/obsidian-git/data.json
vendored
@ -5,7 +5,7 @@
|
||||
"autoSaveInterval": 5,
|
||||
"autoPushInterval": 0,
|
||||
"autoPullInterval": 5,
|
||||
"autoPullOnBoot": false,
|
||||
"autoPullOnBoot": true,
|
||||
"disablePush": false,
|
||||
"pullBeforePush": true,
|
||||
"disablePopups": false,
|
||||
|
27
.obsidian/types.json
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"types": {
|
||||
"aliases": "aliases",
|
||||
"cssclasses": "multitext",
|
||||
"tags": "tags",
|
||||
"excalidraw-plugin": "text",
|
||||
"excalidraw-export-transparent": "checkbox",
|
||||
"excalidraw-mask": "checkbox",
|
||||
"excalidraw-export-dark": "checkbox",
|
||||
"excalidraw-export-padding": "number",
|
||||
"excalidraw-export-pngscale": "number",
|
||||
"excalidraw-export-embed-scene": "checkbox",
|
||||
"excalidraw-link-prefix": "text",
|
||||
"excalidraw-url-prefix": "text",
|
||||
"excalidraw-link-brackets": "checkbox",
|
||||
"excalidraw-onload-script": "text",
|
||||
"excalidraw-linkbutton-opacity": "number",
|
||||
"excalidraw-default-mode": "text",
|
||||
"excalidraw-font": "text",
|
||||
"excalidraw-font-color": "text",
|
||||
"excalidraw-border-color": "text",
|
||||
"excalidraw-css": "text",
|
||||
"excalidraw-autoexport": "text",
|
||||
"excalidraw-embeddable-theme": "text",
|
||||
"excalidraw-open-md": "checkbox"
|
||||
}
|
||||
}
|
5
.stfolder/syncthing-folder-5e8747.txt
Normal file
@ -0,0 +1,5 @@
|
||||
# This directory is a Syncthing folder marker.
|
||||
# Do not delete.
|
||||
|
||||
folderID: lpro7-6ejs3
|
||||
created: 2024-07-05T11:40:35-06:00
|
@ -0,0 +1,17 @@
|
||||
Hairpin NAT enables a device on the LAN to access another device on the LAN via the public IP
|
||||
|
||||
https://help.mikrotik.com/docs/display/ROS/NAT#NAT-HairpinNAT
|
||||
|
||||
From the RouterOS CLI, enter NAT configuration mode:
|
||||
```
|
||||
/ip firewall nat
|
||||
```
|
||||
|
||||
Configure NAT to forward any traffic from the LAN net that's directed at the WAN IP to forward that traffic back to the the server in question (You can only forward to a single IP):
|
||||
```
|
||||
|
||||
```
|
||||
I first tried `add action=masquerade chain=srcnat dst-address=192.168.0.6 out-interface=LAN protoco ol=tcp src-address=192.168.0.0/24`, but was getting the error `input does not match any value of interface`.
|
||||
|
||||
Following the advice from <https://superuser.com/questions/1242353/routeros-hairpin-nat-produces-input-does-not-match-any-value-of-interface>, I changed `out-interface` to `out-interface-list`, and the command completed without any errors.
|
||||
|
84
IT/Hashicorp Nomad.md
Normal file
@ -0,0 +1,84 @@
|
||||
|
||||
# Terminology
|
||||
## Cluster Terms
|
||||
|
||||
| Phrase | Definition |
|
||||
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| agent | A process running in server or client mode. |
|
||||
| client/node | A Nomad client is responsible for running tasks assigned to it. A client registers itself with servers and watches for work to be assigned. When running the agent, the client may be referred to as a *node*. |
|
||||
| server | A Nomad server manages all jobs and clients, monitors tasks, and controls which tasks get placed on which nodes. |
|
||||
| dev_agent | The development agent is an agent configuration that provides useful defaults for running a single node cluster of nomad. |
|
||||
|
||||
## Work terms
|
||||
| Phrase | Definition |
|
||||
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| task | The smallest unit of work in Nomad. Tasks are executed by task drivers like `docker` or `exec`, which allows Nomad to be flexible in the types of tasks it supports. Tasks specify their required task driver, configuration for the driver, constraints, and resources required. |
|
||||
| task driver | Task drivers are used by nomad clients to execute a task and provide resource isolation. |
|
||||
| group | A series of tasks that run on the same Nomad client. |
|
||||
| job | The core unit of *control* for Nomad and defines the application and its configuration. It can contain one or many tasks |
|
||||
| service job | A long lived service that runs until explicitly stopped |
|
||||
| batch job | Short lived jobs that run until they exit successfully |
|
||||
| job_specification/jobspec | A job specification, also known as a jobspec defines the schema for nomad jobs. This describes the type of the job, the tasks and resources necessary for the job to run, job information like which clients it can run on, or more. |
|
||||
| allocation | An allocation is a mapping between a task group in a job and a client node. When a job is run, Nomad will chose a client capable of running it and allocates resources on the machine for the ask(s) in the task group defined for the job. |
|
||||
| workload artifact | The runnable blob to be scheduled on a task driver. Examples include docker images, raw binaries, java applications, and VMs using QEMU. |
|
||||
|
||||
# Typical Workflow
|
||||
Running a task is generally done by:
|
||||
1. *Define a job specification for your task(s):* it'll contain info like where the workload artifact is located, ports used by the service, the number of instances desired, and more.
|
||||
2. *Deploying the job*: The jobspec is submitted to Nomad and it schedules an allocation for the job on one or more clients.
|
||||
3. Updating and redploying the job.
|
||||
|
||||
# Deployment
|
||||
## Installing the CLI
|
||||
https://developer.hashicorp.com/nomad/tutorials/get-started/gs-install#install-the-nomad-cli
|
||||
|
||||
## Creating a single node cluster
|
||||
<https://stackoverflow.com/questions/56112422/nomad-configuration-for-single-node-to-act-as-production-server-and-client>
|
||||
1. Install the `nomad` binary.
|
||||
2. Create a config file with in `/etc/nomad.d` named `config.hcl`:
|
||||
```hcl
|
||||
# https://developer.hashicorp.com/nomad/docs/configuration
|
||||
# The client block configures the Nomad agent to accept jobs as assigned
|
||||
# by the server.
|
||||
# https://developer.hashicorp.com/nomad/docs/configuration/client
|
||||
client {
|
||||
enabled = true
|
||||
}
|
||||
# https://developer.hashicorp.com/nomad/docs/configuration/server
|
||||
server {
|
||||
enabled = true
|
||||
# The number of server nodes to wait for before bootstrapping.
|
||||
bootstrap_expect = 1
|
||||
}
|
||||
# The local directory where agent state is stored.
|
||||
data_dir = "/opt/nomad"
|
||||
name = "YOUR_NOMAD_NAME_HERE"
|
||||
```
|
||||
3. Create a Linux service `nomad.service` inside `/etc/systemd/system`:
|
||||
```systemd
|
||||
[Unit]
|
||||
Description=Nomad
|
||||
Documentation=https://nomadproject.io/docs/
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
ExecStart=/usr/local/bin/nomad agent -config /etc/nomad.d
|
||||
KillMode=process
|
||||
KillSignal=SIGINT
|
||||
LimitNOFILE=infinity
|
||||
LimitNPROC=infinity
|
||||
Restart=on-failure
|
||||
RestartSec=2
|
||||
StartLimitBurst=3
|
||||
TasksMax=infinity
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
4. Load the service file with `sudo systemctl daemon-reload`, then start the service with `sudo systemctl enable nomad && sudo systemctl start nomad`.
|
||||
# Resources
|
||||
- <https://developer.hashicorp.com/nomad/tutorials/get-started/gs-overview>
|
||||
- <https://developer.hashicorp.com/nomad/docs/drivers>
|
||||
- https://developer.hashicorp.com/nomad/docs/configuration
|
@ -0,0 +1,20 @@
|
||||
1. Suppose that the following declarations are in effect:....
|
||||
a. `14`
|
||||
b. `34`
|
||||
c. `4`
|
||||
d. `true`
|
||||
e. `false`
|
||||
|
||||
2. Suppose that `high`, `low`, and `middle` are all pointer variables of the same type, and the `low` and `high` point to elements of an array. Why is the following statement illegal, and how could it be fixed?
|
||||
```c
|
||||
middle = (low + high) / 2
|
||||
```
|
||||
The above statement is illegal because you can't add an `int *` to an `int *`. The below operation is legal because you can perform pointer subtraction, and because `low` is defined on the left hand side of the equation, then adding a long to a pointer is valid.
|
||||
```c
|
||||
middle = low + (high - low) / 2;
|
||||
```
|
||||
|
||||
3. What will be the contents of the `a` array after the following statements are executed?
|
||||
```c
|
||||
{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
|
||||
```
|
136
education/computer engineering/ECE1400/C.md
Normal file
@ -0,0 +1,136 @@
|
||||
# Compilation Steps
|
||||
|
||||
1. Preprocessing: The preprocessor obeys commands that begin with #, also known as directives
|
||||
Commands for the preprocessor are called directives. Directives begin with a pound sign, and they do not end with a semicolon.
|
||||
|
||||
Example:
|
||||
```c
|
||||
#include <stdio.h>
|
||||
```
|
||||
2. Compiling. A compiler translates then translates the program into machine instructions.
|
||||
3. Linking: The generated objects are combined to create a complete executable.
|
||||
|
||||
The preprocessor is typically integrated with the compiler.
|
||||
|
||||
# Types
|
||||
## Strings
|
||||
A string literal is characters enclosed in double quotation marks.
|
||||
|
||||
A newline can be inserted using `\n`.
|
||||
|
||||
## Integers
|
||||
An integer is a way to store a whole number. In C, integers are signed by default.
|
||||
|
||||
Values of an integer type are whole numbers.
|
||||
|
||||
Integers are divided into two categories, signed, and unsigned.
|
||||
|
||||
If the sign bit is zero, it's a positive value, and if it's 1, the value is negative.
|
||||
|
||||
They cal be declared using `[short|long] [signed|unsigned] int`, resulting in 6 possible combinations
|
||||
C99 adds a `long long` int
|
||||
## Floats
|
||||
A float is a decimal value. Slower arithmetic and inexact values are both drawbacks of using floats.
|
||||
|
||||
## Characters
|
||||
In C, a `char` denotes a single byte of arbitrary encoding.
|
||||
|
||||
## Variables
|
||||
A variable must be declared before it is assigned.
|
||||
|
||||
## Arrays
|
||||
### Finding the size of an array
|
||||
```c
|
||||
int arr[10];
|
||||
// The size of an array can be found by
|
||||
// determining the number of bytes allocated total and dividing that by the size of each element in the array.
|
||||
int arr_size = sizeof(arr) / sizeof(arr[0]);
|
||||
|
||||
```
|
||||
|
||||
# Pointers
|
||||
`&` gives you the address of a variable
|
||||
`*` gives you the value in memory that an address points to.
|
||||
|
||||
To update the value a pointer points at, you can dereference on the left hand side of the assignment operator:
|
||||
```c
|
||||
// Update the value `p` points at to be 7
|
||||
*p = 7;
|
||||
```
|
||||
|
||||
Because of how operator precedence works, parentheses should be placed around the dereference operator and the variable
|
||||
```c
|
||||
// Increment the value pointed to by `p`
|
||||
(*p)++;
|
||||
```
|
||||
# Formatting specifiers
|
||||
# Standard library
|
||||
## Formatting specifiers
|
||||
| Specifier | Function |
|
||||
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `%d` | Decimal representation: Display a value as a base 10 (hence the decimal) integer. |
|
||||
| `%f` | Fixed point decimal representation. Specify the number of places to round to by adding a decimal and a number, eg `%.2f` would round to two decimal places. |
|
||||
| `%e` | Exponential floating point number representation. |
|
||||
| `%g` | Either fixed point or exponential representation, whichever has a more compact representation. |
|
||||
For number formatting specifiers, the convention is as follows:
|
||||
`%-a.bX`
|
||||
`%`: Start of the formatting specifier
|
||||
`-`: (optional) If included, justify value left in space. Otherwise, justify right in space
|
||||
`a`: (optional) If included, the size of the field in characters.
|
||||
`.`: Separator between `a` and `b`. Optional if `b` is not specified
|
||||
`b`: The number of decimal places to round to
|
||||
`X`: The type of format to use, and the end of the specifier. Use `d` for integer base 10 (decimal) representation, `f` for fixed point decimal, and `e` for exponential notation, and `g` to select between fixed point and exponential, whichever is shorter.
|
||||
## `printf`
|
||||
Used to write a string to stdout with the ability to format variables into the string.
|
||||
|
||||
Write a string to standard output. `f` indicates that it's a formatting string. The string will not include move the cursor to a newline, append `\n` to the end of the string to do so.
|
||||
|
||||
Printf accepts a variable number of arguments, the first argument is the formatting string, then following arguments are the arguments to be inserted into the string.
|
||||
|
||||
TODO: examples
|
||||
## `scanf`
|
||||
Read value(s) from stdin.
|
||||
|
||||
`scanf` is to stdin as `printf` is to stdout.
|
||||
|
||||
The format of the input is specified using [formatting specifiers](#Formatting%20specifiers), and all following arguments are pointers pointing to variables to update.
|
||||
|
||||
|
||||
### Examples
|
||||
```c
|
||||
// Read a float from standard input into the variable `v`.
|
||||
float v;
|
||||
// Here, `v` is uninitialized
|
||||
scanf("%f", &v);
|
||||
|
||||
printf("You input: %f", v);
|
||||
```
|
||||
|
||||
### Behavior
|
||||
The validity of a `scanf` call is not necessarily checked at compile time, and so the number of outputs specified should match the number of inputs.
|
||||
|
||||
For each formatting specifier specified in the string, `scanf` will attempt to locate an appropriate value in the input, skipping whitespace and newlines if necessary until the beginning of a number is reached.
|
||||
|
||||
When asked to read an integer, `scanf` searches for one of:
|
||||
- A digit
|
||||
- A plus or minus sign
|
||||
It will continue to read until it reaches a nondigit (whitespace is not skipped in this case, and it is counted as a nondigit). If it doesn't encounter a valid digit first, it will return early.
|
||||
|
||||
When asked to read a float, `scanf` searches for one of:
|
||||
- A plus sign or minus sign
|
||||
- A series of digits (possibly containing a decimal point), followed by an exponent (optional). An exponent consists of the letter `e` or `E`, an optional sign, and one or more digits.
|
||||
`%e`, `%f`, and `%g` all follow the same rules for recognizing floating point numbers.
|
||||
|
||||
If an ordinary character is included in the pattern matching string, it will be matched then discarded before proceeding to the next character.
|
||||
## `rand`
|
||||
```c
|
||||
// `srand` creates a seed to use for rng
|
||||
srand(time(NULL));
|
||||
|
||||
// `rand` generates a random integer between 0 and `RAND_MAX`
|
||||
// To pick a number between a particular range, you can use the modulo
|
||||
// operator.
|
||||
// The below example picks a number between zero and four.
|
||||
int num = rand() % 4;
|
||||
|
||||
```
|
@ -0,0 +1,30 @@
|
||||
> 1. If `i` is a variable and `p` points to `i`, which of the following expressions are aliases for `i`?
|
||||
|
||||
a. `*p`
|
||||
g. `*&i`
|
||||
|
||||
> 2. If `i` is an `int` variable and `p` and `q` are pointers to `int`, which of the following assignments are legal?
|
||||
|
||||
e. `p = *&q;`
|
||||
f. `p = q;`
|
||||
i. `*p = *q`
|
||||
|
||||
> 3. The following function supposedly computes the sum and average of the numbers in the array `a`, which has length `n`. `avg` and `sum` point to the variables that the function should modify, unfortunately the function contains several errors, find and correct them.
|
||||
|
||||
```c
|
||||
void avg_sum(double a[], int n, double *avg, double *sum)
|
||||
{
|
||||
int i;
|
||||
|
||||
// This was assigning a pointer to a float,
|
||||
// the dereference operator was missing
|
||||
*sum = 0.0;
|
||||
for (i = 0; i < n; i++)
|
||||
// This wasn't increasing the value
|
||||
// `sum` points to, it was modifying the address stored in the pointer
|
||||
(*sum) += a[i];
|
||||
// Missing dereference operators
|
||||
*avg = *sum / n;
|
||||
|
||||
}
|
||||
```
|
@ -0,0 +1,34 @@
|
||||
1. Suppose that the following declarations are in effect:....
|
||||
a. `14`
|
||||
b. `34`
|
||||
c. `4`
|
||||
d. `true`
|
||||
e. `false`
|
||||
|
||||
2. Suppose that `high`, `low`, and `middle` are all pointer variables of the same type, and the `low` and `high` point to elements of an array. Why is the following statement illegal, and how could it be fixed?
|
||||
```c
|
||||
middle = (low + high) / 2
|
||||
```
|
||||
The above statement is illegal because you can't add an `int *` to an `int *`. The below operation is legal because you can perform pointer subtraction, and because `low` is defined on the left hand side of the equation, then adding a long to a pointer is valid.
|
||||
```c
|
||||
middle = low + (high - low) / 2;
|
||||
```
|
||||
|
||||
3. What will be the contents of the `a` array after the following statements are executed?
|
||||
```c
|
||||
{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
|
||||
```
|
||||
|
||||
5. Suppose that `a` is a one dimensional array and `p` is a pointer variable. assuming that the assignment `p = a` has just been performed, which of the following expressions are illegal because of mismatched types? Of the remaining expressions, which are true (have a nonzero value)?
|
||||
The following expressions are illegal because of mismatched types:
|
||||
- (a) `p == a[0]` - Comparison between `int *` and `int`
|
||||
The rest of the expressions are true.
|
||||
|
||||
8. Rewrite the following function to use pointer arithmetic...
|
||||
```c
|
||||
void store_zeros(int *a, int n) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
*(a + i) = 0;
|
||||
}
|
||||
}
|
||||
```
|
@ -0,0 +1,70 @@
|
||||
> **1.** The following function calls supposedly write a single new-line character, but some are incorrect. Identify which calls don't work and explain why.
|
||||
|
||||
b. `printf("%c", "\n");` - This is invalid because the double quotes make `\n` a string, but it's being displayed with the `%c`formatting specifier.
|
||||
c. `printf(%s, '\n');` - This is invalid because it's trying to display a `char` using the string formatting specifier.
|
||||
e. `printf('\n');` - `printf`'s first argument should be a string, not a `char`.
|
||||
h. `putchar("\n");` - `putchar`'s first argument should be a `char`, not a string.
|
||||
i. `puts('\n');` - `puts`'s first argument should be a string, not a `char`.
|
||||
j. `puts("\n");` - `puts` will write a newline after writing a string, so this will write two newlines.
|
||||
|
||||
---
|
||||
|
||||
> **2.** Suppose that `p` has been declared as follows:
|
||||
```c
|
||||
char *p = "abc";
|
||||
```
|
||||
> Which of the following function calls are legal? Show the output produced by each legal call, and explain why all the others are illegal.
|
||||
```c
|
||||
// A - Not legal, because putchar accepts a `char`, not a pointer.
|
||||
putchar(p);
|
||||
// B - Legal, output: `a`
|
||||
putchar(*p);
|
||||
// C - Legal, output: `abc`
|
||||
puts(p)
|
||||
// D - Illegal, `puts` accepts a pointer to a null terminated string, not a `char`.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
> **3.** Suppose that we call `scanf` as follows:
|
||||
```c
|
||||
scanf("%d%s%d", &i, s, &j);
|
||||
```
|
||||
> If the user enters `12abc34` `56def78`, what will be the values of `i`, `s`, and `j` after the call? (Assume that `i` and `j` are `int` variables and `s` is an array of characters.)
|
||||
|
||||
- `i`: `12`
|
||||
- `s`: `"abc34"`
|
||||
- `j`: `56`
|
||||
|
||||
---
|
||||
|
||||
> **7.** Suppose that `str` is an array of three characters. Which one of the following statements is not equivalent to the other three?
|
||||
```c
|
||||
// A
|
||||
*str = 0;
|
||||
// B
|
||||
str[0] = '\0';
|
||||
// C
|
||||
strcpy(str, "");
|
||||
// D
|
||||
strcat(str, "");
|
||||
```
|
||||
(d) is different because it effectively does nothing (concatenates `"abc"` with an empty string). The rest of them make `str` effectively empty by setting the first character to a null byte.
|
||||
|
||||
---
|
||||
|
||||
> **9.** What will be the value of the string `s1` after the following statements have been executed?
|
||||
```c
|
||||
// Assuming `str` is an empty string with enough space to store everything:
|
||||
strcpy(str, "tire-bouchon");
|
||||
// "tire-bouchon"
|
||||
strcpy(&str[4], "d-or-wi");
|
||||
// "tired-or-wir"
|
||||
strcat(str, "red?");
|
||||
// "tired-or-wired?"
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```c
|
||||
"tired-or-wired?"
|
||||
```
|
@ -0,0 +1,50 @@
|
||||
> **12.** Suppose that the macro `M` has been defined as follows:
|
||||
```c
|
||||
#define M 10
|
||||
```
|
||||
> Which of the following tests will fail?
|
||||
```c
|
||||
// C will fail, because `M` is defined.
|
||||
#ifndef M
|
||||
|
||||
// E will fail, because `M` is defined
|
||||
#if !defined(M)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
> **13.** Show what the following program will look like after preprocessing. You may ignore any lines added to the program as a result of including the `<stdio.h>` header.
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
f();
|
||||
|
||||
}
|
||||
|
||||
void f(void) {
|
||||
printf("N is %d\n", 100);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
> **15.** Suppose that a program needs to display messages in either English, French, or Spanish. Using conditional compilation, write a program fragment that displays one of the following three messages, depending on whether or not the specified macro is defined.
|
||||
|
||||
```c
|
||||
#ifdef ENGLISH
|
||||
#define MESSAGE "Insert Disk 1"
|
||||
#endif
|
||||
|
||||
#ifdef FRENCH
|
||||
#define MESSAGE "Inserez Le Disque 1"
|
||||
#endif
|
||||
|
||||
#ifdef SPANISH
|
||||
#define MESSAGE "Inserte El Disco 1"
|
||||
#endif
|
||||
|
||||
printf(MESSAGE);
|
||||
```
|
@ -0,0 +1,83 @@
|
||||
> **1.** Section 15.1 listed several advantages of dividing a program into multiple source files.(a). Describe several other advantages
|
||||
|
||||
- Easier to scale horizontally as developers are added to the team
|
||||
- Reduced cognitive load from less global scope to keep track of
|
||||
|
||||
> (b). Describe some disadvantages
|
||||
- Increased complexity
|
||||
- Need to maintain/troubleshoot a build system
|
||||
|
||||
---
|
||||
|
||||
> **2.** Which of the following should *not* be put in a header file? Why not?
|
||||
|
||||
b. Function definitions - Functions should only be defined once, and this allows multiple files to share the same function definition
|
||||
|
||||
---
|
||||
|
||||
> **3.** We saw that writing `#include <file>` instead of `#include "file"` may not work if file is one that we've written. Would there be any problem with writing `$include "file"` instead of `#include <file>` if *file* is a system header?
|
||||
|
||||
Yes, `""` is a path relative to the current file, whereas `<>` is a path to the system's standard library headers.
|
||||
|
||||
---
|
||||
|
||||
> **4.** Assume that `debug.h` is a header file with the following contents...
|
||||
>(a). What is the output when the program is executed?
|
||||
|
||||
```
|
||||
Output if DEBUG is defined:
|
||||
Value of i: 1
|
||||
Value of j: 2
|
||||
Value of i + j: 3
|
||||
Value of 2 * i + j - k: 1
|
||||
```
|
||||
|
||||
> (b). What is the output if the `#define` directive is removed from `testdebug.c`?
|
||||
|
||||
```
|
||||
Output if DEBUG is not defined:
|
||||
```
|
||||
|
||||
> (c). Explain why the output is different in parts (a) and (b)
|
||||
|
||||
When `DEBUG` is defined, any instances of the `PRINT_DEBUG` token are replaced with a `printf` call during compile time, but when it's not defined, they're replaced with nothing.
|
||||
|
||||
> (d). Is it necessary for the `DEBUG` macro to be defined *before* `debug.h` is included in order for `PRINT_DEBUG` to have the desired effect? Justify your answer.
|
||||
|
||||
Macro invocations are evaluated sequentially, and so if `DEBUG` was defined after `PRINT_DEBUG`, then any usages of `PRINT_EVALUATION` would be have like `DEBUG` was not defined.
|
||||
|
||||
---
|
||||
|
||||
> **5.** Suppose that a program consists of three source files - `main.c`, `f1.c`, and `f2.c`- Plus two header files, `f1.h` and `f2.h`. All three source files include `f1.h` but only `f1.c` and `f2.c` include `f2.h`. Write a makefile for this program, assuming that the compiler is `gcc` and that the executable file is to be named `demo`.
|
||||
```makefile
|
||||
demo: main.o f1.o f2.o
|
||||
gcc -o demo main.o f1.o f2.o
|
||||
|
||||
main.o: main.c f1.h
|
||||
gcc -c main.c
|
||||
|
||||
f1.o: f1.c f1.h f2.h
|
||||
gcc -c f1.c
|
||||
|
||||
f2.o: f2.c f2.h
|
||||
gcc -c f2.c
|
||||
|
||||
```
|
||||
---
|
||||
|
||||
> **6.** The following questions refer to the program described in Exercise 5.
|
||||
> (a). Which files need to be compiled when the program is built for the first time?
|
||||
|
||||
`f1.c`, `f1.h`, `f2.c`, `f2.h`, `main.c`, `main.h`
|
||||
|
||||
> (b). If `f1.c` is changed after the program has been built, which files need to be recompiled?
|
||||
|
||||
Just `f1.c`.
|
||||
|
||||
> (c). If `f1.h` is changed after the program has been built, which files need to be recompiled?
|
||||
|
||||
All source files, because they all include `f1.h`.
|
||||
|
||||
> (d). If `f2.h` is changed after the program has been built, which files need to be recompiled?
|
||||
|
||||
`f1.c` and `f2.c`.
|
@ -0,0 +1,21 @@
|
||||
|
||||
Yes they are, different structs can have the same field names.
|
||||
|
||||
> 2
|
||||
|
||||
```c
|
||||
struct c1 C1 { 0.0, 1.0};
|
||||
|
||||
struct c1 C2 { 1.0, 1.0};
|
||||
```
|
||||
|
||||
> 8a
|
||||
```c
|
||||
const struct color MAGENTA { 255, 0, 255};
|
||||
```
|
||||
|
||||
>11
|
||||
|
||||
20 bytes
|
||||
|
||||
UNCOMPLETED
|
@ -0,0 +1,90 @@
|
||||
> **4.** Suppose that the following declarations are in effect:
|
||||
```c
|
||||
struct point {int x, y; };
|
||||
struct rectangle { struct point upper_left, lower_right; };
|
||||
struct rectangle *p;
|
||||
```
|
||||
> Assume that we want `p` to point to a rectangle structure whose upper left corner is at $(10, 25)$, and whose lower right corner is at $(20, 15)$. Write a series of statements that allocate such a structure and initialize it as indicated.
|
||||
|
||||
```c
|
||||
struct rectangle rect = { { 10, 25 }, { 20, 15 } };
|
||||
p = ▭
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
> **5.** Suppose that `f` and `p` are declared as follows:
|
||||
```c
|
||||
struct {
|
||||
union {
|
||||
char a, b;
|
||||
int c;
|
||||
} d;
|
||||
int e[5];
|
||||
} f, *p = &f;
|
||||
```
|
||||
> Which of the following statements are legal?
|
||||
|
||||
(a) `p->b = ' ';`
|
||||
(b) `p->e[3] = 10;` - **Legal**
|
||||
(c) `(*p).d.a = '*';` - **Legal**
|
||||
(d) `p->d->c = 20;`
|
||||
|
||||
---
|
||||
|
||||
> **7.** The following loop is supposed to delete all nodes from a linked list and release the memory that they occupy. Unfortunately, the loop is incorrect. Explain what's wrong with it and show how to fix the bug.
|
||||
```c
|
||||
for (p = first; p != NULL; p = p->next)
|
||||
free(p);
|
||||
```
|
||||
|
||||
The above loop won't function because it deallocates the entry, then attempts to access the pointer to the next item, *after* it's already been freed.
|
||||
|
||||
A functional example might look like this:
|
||||
```c
|
||||
struct entry *p = first;
|
||||
while (p != NULL) {
|
||||
void *current = p;
|
||||
p = p->next;
|
||||
free(p);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
> **9.** True or false: If `x` is a structure and `a` is a member of that structure, then `(&x)->a` is the same as `x.a`. Justify your answer.
|
||||
|
||||
**True**: The arrow operator is used to access a member of a struct through a pointer. `(&x)` creates a pointer to the `x` struct, therefore the arrow operator can be used to access fields on `x`.
|
||||
|
||||
---
|
||||
|
||||
> **13.** The following function is supposed to insert a new node into its proper place in an ordered list, returning a pointer to the first node in the modified list. Unfortunately, the function doesn't work correctly in all cases. Explain what's wrong with it and show how to fix it. Assume that the `node` structure is the one defined in Section 17.5.
|
||||
```c
|
||||
struct node *insert_into_ordered_list(struct node *list, struct node *new_node) {
|
||||
struct node *cur = list, *prev = NULL;
|
||||
while (cur->value <= new_node->value) {
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
}
|
||||
prev->next = new_node;
|
||||
new_node->next = cur;
|
||||
return list;
|
||||
}
|
||||
```
|
||||
|
||||
In the above code, if the new item needs to be inserted at the *end* of the list, it breaks, because `cur` is set to `NULL`, then it attempts to access `cur->value`.
|
||||
```c
|
||||
struct node *insert_into_ordered_list(struct node *list, struct node *new_node) {
|
||||
struct node *cur = list, *prev = NULL;
|
||||
while (cur->value <= new_node->value) {
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
if (cur->next == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
prev->next = new_node;
|
||||
new_node->next = cur;
|
||||
return list;
|
||||
}
|
||||
```
|
@ -0,0 +1,47 @@
|
||||
# \#2
|
||||
Directives:
|
||||
```c
|
||||
#include <stdio.h>
|
||||
```
|
||||
|
||||
Statements:
|
||||
```c
|
||||
printf("Parkinson's Law: \nWork expands so as to ");
|
||||
printf("fill the time\n");
|
||||
printf("available for its completion.\n");
|
||||
return 0;
|
||||
```
|
||||
|
||||
Output:
|
||||
```
|
||||
Parkinson's Law:
|
||||
Work expands so as to fill the time
|
||||
available for its completion.
|
||||
|
||||
```
|
||||
# \#5
|
||||
(A): `100_bottles` is not a legal C identifier because C identifiers cannot start with a number.
|
||||
# \#6
|
||||
Double underscores are typically used to denote statements reserved by the compiler, and in C++, double underscores are used in name mangling and so they cannot be used entirely. More subjectively, it can be hard to tell how many underscores are present.
|
||||
# \#7
|
||||
(A): `for`
|
||||
(E): `while`
|
||||
|
||||
# \#8
|
||||
14.
|
||||
|
||||
Work:
|
||||
1. `answer`
|
||||
2. `=`
|
||||
3. `(`
|
||||
4. `3`
|
||||
5. `*`
|
||||
6. `q`
|
||||
7. `-`
|
||||
8. `p`
|
||||
9. `*`
|
||||
10. `p`
|
||||
11. `)
|
||||
12. `/`
|
||||
13. `3`
|
||||
14. `;`
|
@ -0,0 +1,37 @@
|
||||
# 1.
|
||||
a. `86,1040`
|
||||
b. `3.02530e+01`
|
||||
c. `83.1620`
|
||||
d. `1e-06 `
|
||||
|
||||
# 2.
|
||||
```c
|
||||
float x = 0.12345;
|
||||
// a
|
||||
printf("%-8.1e", x);
|
||||
// b
|
||||
printf("%10.6e", x);
|
||||
// c
|
||||
printf("%8.3f", x);
|
||||
// d
|
||||
printf("%-6.0f", x);
|
||||
```
|
||||
|
||||
# 3.
|
||||
a. Equivalent
|
||||
b. Equivalent
|
||||
c. Equivalent
|
||||
d. Equivalent
|
||||
|
||||
# 4.
|
||||
`i`: `10`
|
||||
`x`: `0.3f`
|
||||
`j`: `5`
|
||||
|
||||
# 5.
|
||||
`x`: `12.3f`
|
||||
`i`: `45`
|
||||
`f`: `0.6f`
|
||||
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
# 1.
|
||||
a. `1 2`
|
||||
b. `0`
|
||||
c. `1`
|
||||
d. `0`
|
||||
# 3.
|
||||
a. `1`
|
||||
b. `-1`, `-2`
|
||||
c. `-1`, `-1`
|
||||
d. `1`, `2`
|
||||
# 9.
|
||||
a. `63 8`
|
||||
b. `1 2 3`
|
||||
c. `0 1 3`
|
||||
d. `0 0 0`
|
||||
# 11.
|
||||
a. `0 2`
|
||||
b. `4 11 6`
|
||||
c. `0 8 7`
|
||||
d. `15 4 5 4`
|
||||
|
||||
# 15.
|
||||
a. `i = 2, j = 2`
|
||||
b. `i = 1`, `j = 2`
|
||||
c. `i = 1`, `j = 2`
|
||||
d. `i = 1`, `j = 3`
|
103
education/computer engineering/ECE1400/Chapter 5 Exercises.md
Normal file
@ -0,0 +1,103 @@
|
||||
> 2. The following program fragments illustrate the logical operators. Show the output produced by each, assuming that `i`, `j`, and `k` are `int` variables.
|
||||
|
||||
a. `i = 10; j = 5;`
|
||||
```c
|
||||
printf("%d", !i < j);
|
||||
|
||||
// Expected output: `1`, because `!i` evaluates to 0, and 0 is less than 5, so that expression evaluates to true, or 1.
|
||||
```
|
||||
|
||||
b. `i = 2; j = 1;`
|
||||
```c
|
||||
printf("%d", !!i + !j);
|
||||
|
||||
// Expected output: `1`, because !!2 evaluates to 1, and !j evaluates to 0
|
||||
```
|
||||
|
||||
c. `i = 5; j = 0; k = -5;`
|
||||
```c
|
||||
printf("%d", i && j || k);
|
||||
|
||||
// Expected output: `1`, because i && j should evaluate to 0, but `0 || 1` should evalulate to true.
|
||||
```
|
||||
|
||||
d. `i = 1; j = 2; k = 3;`
|
||||
```c
|
||||
printf("%d", i < j || k);
|
||||
|
||||
// Expected output: `1`
|
||||
```
|
||||
|
||||
> 4. Write a single expression whose value is either `-1`, `0`, or `1` depending on whether `i` is less than, equal to, or greater than `j`, respectively.
|
||||
|
||||
```c
|
||||
/*
|
||||
If i < j, the output should be -1.
|
||||
If i == j, the output should be zero
|
||||
If i > j, the output should be 1.
|
||||
*/
|
||||
(i > j) - (i < j)
|
||||
```
|
||||
|
||||
> 6. Is the following `if` statement legal?
|
||||
```c
|
||||
if (n == 1-10)
|
||||
printf("n is between 1 and 10\n");
|
||||
```
|
||||
|
||||
Yes the statement is *legal*, but it does not produce the intended effect. It would not produce an output when `n = 5`, because `1-10` evaluates to `-9`, and `-9 != 5`.
|
||||
|
||||
> 10. What output does the following program fragment produce? (Assume that `i` is an integer variable.)
|
||||
```c
|
||||
int i = 1;
|
||||
switch (i % 3) {
|
||||
case 0: printf("zero");
|
||||
case 1: printf("one");
|
||||
case 2: printf("two");
|
||||
}
|
||||
```
|
||||
|
||||
The program would print `onetwo` because each case is missing a `break` statement.
|
||||
|
||||
> 11. The following table shows the telephone area codes in the state of Georgia along with the largest city in each area:
|
||||
|
||||
| Area code | Major city |
|
||||
| --------- | ---------- |
|
||||
| 229 | Albany |
|
||||
| 404 | Atlanta |
|
||||
| 470 | Atlanta |
|
||||
| 478 | Macon |
|
||||
| 678 | Atlanta |
|
||||
| 706 | Columbus |
|
||||
| 762 | Columbus |
|
||||
| 770 | Atlanta |
|
||||
| 912 | Savannah |
|
||||
> Write a switch statement whose controlling expression is the variable `area_code`. If the value of `area_code` is not in the table, the `switch` statement will print the corresponding city name. Otherwise, the `switch` statement will display the message `"Area code not recognized."` Use the techniques discussed in section 5.3 to make the `switch` as simple as possible.
|
||||
```c
|
||||
int area_code;
|
||||
|
||||
switch (area_code) {
|
||||
case 404:
|
||||
case 470:
|
||||
case 678:
|
||||
case 770:
|
||||
printf("Atlanta");
|
||||
break;
|
||||
case 706:
|
||||
case 762:
|
||||
printf("Columbus");
|
||||
break;
|
||||
case 229:
|
||||
printf("Albany");
|
||||
break;
|
||||
case 478:
|
||||
printf("Macon");
|
||||
break;
|
||||
case 912:
|
||||
printf("Savannah");
|
||||
break;
|
||||
default:
|
||||
printf("Area code not recognized.");
|
||||
break;
|
||||
}
|
||||
```
|
@ -0,0 +1,58 @@
|
||||
> 1. What output does the following program fragment produce?
|
||||
```c
|
||||
i = 1;
|
||||
while (i <= 128) {
|
||||
printf("%d ", i);
|
||||
i *= 2;
|
||||
}
|
||||
```
|
||||
|
||||
Output:
|
||||
```
|
||||
1 2 4 8 16 32 64 128
|
||||
```
|
||||
|
||||
> 2. What output does the following program fragment produce?
|
||||
```c
|
||||
i = 9384
|
||||
do {
|
||||
printf("%d ", i);
|
||||
i /= 10;
|
||||
} while (i <= 128);
|
||||
```
|
||||
|
||||
Output:
|
||||
```
|
||||
9384 938 93 9
|
||||
```
|
||||
|
||||
> 3. What output does the following `for` statement produce?
|
||||
```c
|
||||
for (i = 5, j = i - 1; i > 0, j > 0; --i, j = i - 1)
|
||||
printf("%d ", i);
|
||||
```
|
||||
|
||||
Output:
|
||||
```
|
||||
5 4 3 2
|
||||
```
|
||||
|
||||
> 4. Which one of the following statements is not equivalent to the other two (assuming that the loop bodies are the same?)
|
||||
```c
|
||||
for (i = 0; i < 10; i++) // (a)
|
||||
for (i = 0; i < 10; ++i) // (b)
|
||||
for (i = 0; i ++ < 10; ) // (c)
|
||||
```
|
||||
|
||||
Answer:
|
||||
C is not the same as A and B, because the increment takes place before the loop body is executed.
|
||||
|
||||
> 5. Which one of the following statements is not equivalent to the other two (assuming that the loop bodies are the same)?
|
||||
```c
|
||||
while (i < 10) {...} // (a)
|
||||
for (; i < 10;) {...} // (b)
|
||||
do {...} while (i < 10); // (c)
|
||||
```
|
||||
|
||||
Answer:
|
||||
C is not the same as A and B, because the block is executed before the condition is checked.
|
@ -0,0 +1,48 @@
|
||||
> 3. Which of the following aren not legal types in C?
|
||||
|
||||
a. `short unsigned int`
|
||||
b. `short float`
|
||||
c. `long double`
|
||||
d. `unsigned long`
|
||||
|
||||
Answer:
|
||||
b. `short float`
|
||||
|
||||
> 4. If `c` is a variable of type `char`, which of the following statements is illegal?
|
||||
|
||||
```c
|
||||
char c;
|
||||
// A:
|
||||
i += c; // i has type int
|
||||
// B:
|
||||
c = 2 * c - 1;
|
||||
// C:
|
||||
putchar(c);
|
||||
// D:
|
||||
printf(c);
|
||||
```
|
||||
|
||||
Answer:
|
||||
D is illegal because `printf` operates on strings, not `char`s.
|
||||
|
||||
> 6. For each of the following items of data, specify which one of the types `char`, `short`, `int`, or `long`is the smallest one guaranteed to be large enough to store the item.
|
||||
|
||||
Answer:
|
||||
A. Days in a month: `char`
|
||||
B. Days in a year: `short`
|
||||
C. Minutes in a day: `short`
|
||||
D. Seconds in a day: `long`
|
||||
|
||||
> 10. Suppose that `i` is a variable of type `int`, `j` is a variable of type `float`, and `k` is a variable of type `unsigned int`. What is the type of the expression `i + (int) j * k`?
|
||||
|
||||
Answer:
|
||||
`unsigned int`
|
||||
|
||||
> 15. Use `typedef` to create types named `Int8`, `Int16`, and `Int32`. Define the types so that they represent 8 bit, 16 bit, and 32 bit integers on your machine.
|
||||
|
||||
Answer:
|
||||
```C
|
||||
typedef char Int8;
|
||||
typedef short Int16;
|
||||
typedef long Int32;
|
||||
```
|
@ -0,0 +1,69 @@
|
||||
> 1. We discussed using the expression `sizeof(a) / sizeof(a[0]` to calculate the number of elements in an array. The expression `sizeof(a) / sizeof(t)` where `t` is the type of `a`'s elements would also work, but it's considered an inferior technique. Why?
|
||||
|
||||
Answer:
|
||||
Using the type of the array's first element means that if you change the type of an array, it won't break the code that calculates the number of elements.
|
||||
|
||||
> 3. Write a declaration of an array named weekend containing seven `bool` values. Include an initialize that makes the first and last values `true`; all other values should be `false`.
|
||||
|
||||
Answer:
|
||||
```c
|
||||
bool weekend[] = {true, [1 ... 5] = false, true};
|
||||
```
|
||||
|
||||
> 5. Calculators, watches, and other electronic devices often rely on 7 segment displays for numerical output. To form a digit, such devices turn on some of the seven segments while leaving others off.
|
||||
>
|
||||
> Here's what the array might look like, with each row representing one digit:
|
||||
```c
|
||||
const int segments[10][7] = {{1, 1, 1, 1, 1, 1, 0}, ...};
|
||||
```
|
||||
> I've given you the first row of the initializer, fill in the rest.
|
||||
|
||||
Answer:
|
||||
```c
|
||||
const int segments[10][7] = {
|
||||
{1, 1, 1, 1, 1, 1, 0}, // 0
|
||||
{0, 1, 1, 0, 0, 0, 0}, // 1
|
||||
{1, 1, 0, 1, 1, 0, 1}, // 2
|
||||
{1, 1, 1, 1, 0, 0, 1}, // 3
|
||||
{0, 1, 1, 0, 0, 1, 0}, // 4
|
||||
{1, 0, 1, 1, 0, 1, 1}, // 5
|
||||
{1, 0, 1, 1, 1, 1, 1}, // 6
|
||||
{1, 1, 1, 0, 0, 0, 0}, // 7
|
||||
{1, 1, 1, 1, 1, 1, 1}, // 8
|
||||
{1, 1, 1, 1, 0, 1, 1} // 9
|
||||
};
|
||||
```
|
||||
|
||||
>10. Write a declaration for an 8x8 `char` array named `chess_board`. Include an initializer that puts the following data into the array, one character per array element:
|
||||
\[omitted]
|
||||
|
||||
```c
|
||||
char chess_board[8][8] = {
|
||||
{'r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'},
|
||||
{'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'},
|
||||
{' ', '.', ' ', '.', ' ', '.', ' ', '.'},
|
||||
{'.', ' ', '.', ' ', '.', ' ', '.', ' '},
|
||||
{' ', '.', ' ', '.', ' ', '.', ' ', '.'},
|
||||
{'.', ' ', '.', ' ', '.', ' ', '.', ' '},
|
||||
{' ', '.', ' ', '.', ' ', '.', ' ', '.'},
|
||||
{'.', ' ', '.', ' ', '.', ' ', '.', ' '},
|
||||
{'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'},
|
||||
{'R', 'N', 'B', 'K', 'Q', 'B', 'N', 'R'},
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
> 11. Write a program fragment that declares an 8x8 `char` array named `checker_board` and then uses a loop to store the following data into the array (one character per array element).
|
||||
|
||||
```c
|
||||
char checker_board[8][8];
|
||||
for (int row = 0; row < 8; row++) {
|
||||
for (int column = 0; column < 8; column++) {
|
||||
if ((column + row) % 2 == 0) {
|
||||
checker_board[row][column] = 'B';
|
||||
} else {
|
||||
checker_board[row][column] = 'R';
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
@ -0,0 +1,78 @@
|
||||
> 1. The following function, which computes the area of a triangle, contains two errors. Locate the errors and show how to fix them. (*Hint*: There are no errors in the formula)
|
||||
```c
|
||||
double triangle_area(double base, height)
|
||||
double product;
|
||||
{
|
||||
product = base * height;
|
||||
return product / 2;
|
||||
}
|
||||
```
|
||||
|
||||
Answer:
|
||||
```c
|
||||
// A type annotation is needed for `height`
|
||||
double triangle_area(double base, double height)
|
||||
{
|
||||
// The `product` variable declaration was not in the function block.
|
||||
double product;
|
||||
product = base * height;
|
||||
return product / 2;
|
||||
}
|
||||
```
|
||||
|
||||
> 2. Write a function `check(x, y, n)` that returns `1` if both `x` and `y` fall between zero and `n - 1` inclusive. The function should return 0 otherwise. Assume that `x`, `y`, and `n` are all of type int
|
||||
```c
|
||||
int check(int x, int y, int n) {
|
||||
int in_range = 1;
|
||||
if (x < 0 || y < 0) {
|
||||
in_range = 0;
|
||||
}
|
||||
if (x > n - 1 || y > n - 1) {
|
||||
in_range = 0;
|
||||
}
|
||||
|
||||
return in_range;
|
||||
}
|
||||
```
|
||||
|
||||
> 7. Suppose that function `f` has the following definition:
|
||||
> `int f(int a, int b) { ... }`
|
||||
> Which of the following statements are legal? Assume that `i` has type `int` and `x` has type `double`).
|
||||
|
||||
Answer:
|
||||
All of them are legal and will compile and run. (c) and (d) are what I would consider bad practice because they perform an implicit conversion from a double to an int, and should include an explicit cast.
|
||||
|
||||
> 8. Which of the following would be valid prototypes for a function that returns nothing and has one double parameter?
|
||||
|
||||
Answer:
|
||||
(a) and (b).
|
||||
Parameters must contain a type annotation but they do not need to specify a name. A function prototype declaration must specify a return type.
|
||||
|
||||
> 9. What will be the output of the following program?
|
||||
```c
|
||||
#include <stdio.h>
|
||||
|
||||
void swap (int a, int b);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i = 1, j = 2;
|
||||
swap(i, j);
|
||||
printf("i = %d, j = %d\n", i, j);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void swap(int a, int b)
|
||||
{
|
||||
int temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Answer:
|
||||
```
|
||||
i = 1, j = 2
|
||||
```
|
||||
Because function parameters are passed by value and not reference in C, modifications to `a` and `b` are limited to the scope of `swap`.
|
@ -0,0 +1,322 @@
|
||||
# Banana Cake
|
||||
## Instructions
|
||||
|
||||
1. Assume an action set of {add \<ingredient>, stir, bake, cool}. Draw a flowchart, using the paradigm discussed in class, to show the process of baking a banana cake. Use Google to find a typical list of ingredients.
|
||||
2. Represent the flowchart from problem 1 as pseudocode.
|
||||
|
||||
## Flowchart
|
||||
```d2
|
||||
vars: {
|
||||
d2-config: {
|
||||
dark-theme-id: 200
|
||||
}
|
||||
}
|
||||
grid-columns: 3
|
||||
|
||||
begin: {
|
||||
shape: oval
|
||||
# near: top-left
|
||||
}
|
||||
|
||||
begin -> add 3c flour\
|
||||
-> add 1 1/2 tsp baking soda\
|
||||
-> add 1/2 tsp cinnamon\
|
||||
-> add 1/2 tsp salt\
|
||||
-> stir\
|
||||
-> add 3 mashed bananas\
|
||||
-> add 1 tsp lemon juice\
|
||||
-> stir again\
|
||||
-> add 3 eggs\
|
||||
-> add 2tsp vanilla extract\
|
||||
-> stir a final time\
|
||||
-> bake @ 350f for 50 min\
|
||||
-> let cool for 1 hour\
|
||||
-> end
|
||||
end: {
|
||||
shape: oval
|
||||
# near: bottom-right
|
||||
}
|
||||
```
|
||||
|
||||
## Pseudocode
|
||||
```c
|
||||
/**************************************
|
||||
* Function Title: BakeBananaCake
|
||||
*
|
||||
* Summary: Bake a banana cake
|
||||
*
|
||||
* Inputs: none
|
||||
* Outputs: none
|
||||
**************************************
|
||||
* Pseudocode
|
||||
*
|
||||
* Begin
|
||||
* Add 3c flour
|
||||
* Add 1 1/2 tps baking soda
|
||||
* Add 1/2 tsp cinnamon
|
||||
* Add 1/2 tsp salt
|
||||
* Stir
|
||||
* Add 3 mashed bananas
|
||||
* Add 1 tsp lemon juice
|
||||
* Stir
|
||||
* Add 3 eggs
|
||||
* Add 2tsp vanilla extract
|
||||
* Stir a final time
|
||||
* Bake @ 350F for 50 min
|
||||
* Cool for 1 hour
|
||||
* End
|
||||
**************************************/
|
||||
```
|
||||
|
||||
# Walking
|
||||
## Instructions
|
||||
3. Assume an action set of {walk \<value> steps, turn to \<value> degrees}. Draw a flowchart showing a shady path and a sunny path to get from the west doors of the Engineering Building to the south-east doors of the TSC. Pick a meaningful “if” condition to select one of the two paths. Use real-world data in your design.
|
||||
|
||||
4. Represent the flowchart from problem 3 as pseudocode.
|
||||
|
||||
%%
|
||||
Assuming a step distance of 2.5 feet.
|
||||
|
||||
Shady path:
|
||||
1. Turn to 270 degrees
|
||||
2. Walk 112 steps
|
||||
3. Turn to 225 degrees
|
||||
4. Walk 124 steps
|
||||
5. Turn to 270 degrees
|
||||
6. Walk 361 steps
|
||||
7. Turn to 0 degrees
|
||||
8. Walk 176 steps
|
||||
9. Turn to 270 degrees
|
||||
10. Walk 62 steps
|
||||
|
||||
|
||||
Sunny path:
|
||||
1. Turn to 270 degrees
|
||||
2. Walk 73 steps
|
||||
3. Turn to 0 degrees
|
||||
4. Walk 94 steps
|
||||
5. Turn to 275 degrees
|
||||
6. Walk 467 steps
|
||||
7. Turn to 180 degrees
|
||||
8. Walk 86 steps
|
||||
9. Turn to 270 degrees
|
||||
10. Walk 80 steps
|
||||
|
||||
%%
|
||||
|
||||
## Flowchart
|
||||
```d2
|
||||
vars: {
|
||||
d2-config: {
|
||||
dark-theme-id: 200
|
||||
}
|
||||
}
|
||||
classes: {
|
||||
turn-0: {
|
||||
label: turn to 0 degrees
|
||||
}
|
||||
turn-90: {
|
||||
label: turn to 90 degrees
|
||||
}
|
||||
turn-180: {
|
||||
label: turn to 180 degrees
|
||||
}
|
||||
turn-270: {
|
||||
label: turn to 270 degrees
|
||||
}
|
||||
}
|
||||
beginning: {shape: oval}
|
||||
beginning -> if
|
||||
if: {
|
||||
shape: diamond
|
||||
label: if (shady)\n<then else>\nendif
|
||||
|
||||
}
|
||||
if -> shady: {
|
||||
direction: up
|
||||
label: if shady path
|
||||
}
|
||||
shady {
|
||||
grid-columns: 2
|
||||
1.class: turn-270
|
||||
1 -> 2
|
||||
2.label: walk 112 steps
|
||||
2 -> 3
|
||||
3.label: turn to 225 degrees
|
||||
3 -> 4
|
||||
4.label: walk 124 steps
|
||||
4 -> 5
|
||||
5.class: turn-270
|
||||
5 -> 6
|
||||
6.label: walk 361 steps
|
||||
6 -> 7
|
||||
7.class: turn-0
|
||||
7 -> 8
|
||||
8.label: walk 176 steps
|
||||
8 -> 9
|
||||
9.class: turn-270
|
||||
9 -> 10
|
||||
10.label: walk 62 steps
|
||||
}
|
||||
end: {shape: oval}
|
||||
if -> end
|
||||
if -> sunny: if sunny path
|
||||
sunny {
|
||||
grid-columns: 2
|
||||
1.class: turn-270
|
||||
1 -> 2
|
||||
2.label: walk 73 steps
|
||||
2 -> 3
|
||||
3.class: turn-0
|
||||
3 -> 4
|
||||
4.label: walk 94 steps
|
||||
4 -> 5
|
||||
5.label: turn to 275 degrees
|
||||
5 -> 6
|
||||
6.label: walk 361 steps
|
||||
6 -> 7
|
||||
7.class: turn-0
|
||||
7 -> 8
|
||||
8.label: walk 176 steps
|
||||
8 -> 9
|
||||
9.label: turn to 270 degrees
|
||||
9 -> 10
|
||||
10.label: walk 80 steps
|
||||
}
|
||||
```
|
||||
|
||||
## Pseudocode
|
||||
```c
|
||||
/**************************************
|
||||
* Function Title: WalkToTscFromEngr
|
||||
*
|
||||
* Summary: Walk from the west entrance of the engineering building
|
||||
* to the southeast entrace of the taggart student center, using either
|
||||
* a shady or sunny path
|
||||
*
|
||||
* Inputs: shady (boolean)
|
||||
* Outputs: none
|
||||
**************************************
|
||||
* Pseudocode
|
||||
*
|
||||
* Begin
|
||||
* If (shady) then
|
||||
* Turn to 270 degrees
|
||||
* Walk 112 steps
|
||||
* Turn to 225 degrees
|
||||
* Walk 124 steps
|
||||
* Turn to 270 degrees
|
||||
* Walk 361 steps
|
||||
* Turn to 0 degrees
|
||||
* Walk 176 steps
|
||||
* Turn to 270 degrees
|
||||
* Walk 62 steps
|
||||
* Else
|
||||
* Turn to 270 degrees
|
||||
* Walk 73 steps
|
||||
* Turn to 0 degrees
|
||||
* Walk 94 steps
|
||||
* Turn to 275 degrees
|
||||
* Walk 467 steps
|
||||
* Turn to 180 degrees
|
||||
* Walk 86 steps
|
||||
* Turn to 270 degrees
|
||||
* Walk 80 steps
|
||||
* EndIf
|
||||
* End
|
||||
**************************************/
|
||||
```
|
||||
|
||||
# 4 Way Intersection
|
||||
## Instructions
|
||||
5. Develop a flowchart that describes the behavior of a set of traffic lights that control a 4-way intersection. Assume the light can either be red or green. Define an appropriate action set that accounts for the time the light has been in the current state.
|
||||
|
||||
6. Represent the flowchart from problem 5 as pseudocode.
|
||||
|
||||
## Action Set
|
||||
| Action name | Description |
|
||||
| -- | -- |
|
||||
| Set \[north, east, south, west] light to \[red, green] | Set the specified light to either red or green |
|
||||
| Toggle lights | Change the color of all 4 lights to the color they were not |
|
||||
| Wait \[number of seconds] seconds | Pause for \[number of seconds] seconds before continuing to the next instruction |
|
||||
|
||||
## Flowchart
|
||||
```d2
|
||||
vars: {
|
||||
d2-config: {
|
||||
dark-theme-id: 200
|
||||
}
|
||||
}
|
||||
classes: {
|
||||
toggle-lights: {
|
||||
label: Toggle lights
|
||||
}
|
||||
}
|
||||
beginning: {
|
||||
shape: oval
|
||||
label: beginning
|
||||
}
|
||||
beginning -> initialize lights
|
||||
initialize lights {
|
||||
grid-columns: 1
|
||||
1.label: set the north light to red
|
||||
1 -> 2
|
||||
2.label: set the south light to red
|
||||
2 -> 3
|
||||
3.label: set the east light to green
|
||||
3 -> 4
|
||||
4.label: set the west light to green
|
||||
}
|
||||
initialize lights -> loop
|
||||
loop {
|
||||
near: center-right
|
||||
label: loop indefinitely
|
||||
begin-loop: {
|
||||
shape: step
|
||||
label: begin iteration
|
||||
}
|
||||
begin-loop -> 1
|
||||
1.label: wait 30 seconds
|
||||
1 -> 2
|
||||
2.label: toggle lights
|
||||
end-loop: {
|
||||
shape: step
|
||||
label: end iteration
|
||||
}
|
||||
2 -> end-loop
|
||||
end-loop -> begin-loop
|
||||
}
|
||||
loop -> end: the heat death of the universe
|
||||
end: {
|
||||
near: bottom-right
|
||||
shape: oval
|
||||
label: end
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Pseudocode
|
||||
```c
|
||||
/**************************************
|
||||
* Function Title: RunStopLights
|
||||
*
|
||||
* Summary: Operate stoplights for a 4 way intersection
|
||||
*
|
||||
* Inputs: none
|
||||
* Outputs: none
|
||||
**************************************
|
||||
* Pseudocode
|
||||
*
|
||||
* Begin
|
||||
* Set the north light to red
|
||||
* Set the south light to red
|
||||
* Set the east light to green
|
||||
* Set the west light to green
|
||||
* Loop indefinitely
|
||||
* Wait 30 seconds
|
||||
* Toggle lights
|
||||
* EndLoop
|
||||
* End
|
||||
**************************************/
|
||||
```
|
||||
|
@ -0,0 +1,2 @@
|
||||
- To find the magnitude of a negative twos compliment number, flip all of the bits and add one.
|
||||
-
|
15
education/computer engineering/ECE2700/Adders.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Half Adder
|
||||
|
||||
# Full Adder
|
||||
|
||||
# Ripple Carry Adder
|
||||
|
||||
# Carry-Select Adder
|
||||
A carry select adder is built using two ripple carry adders, and multiplexing them together based off of the value of $c_{in}$. This is done for performance reasons, because when adding two numbers $x$ and $y$, we know $x$ and $y$ *before* we know the value of $c_{in}$. This means we can compute what the output of $x + y + c_{in}$ would be for $c_{in} = 0$ and $c_{in} = 1$ at the same time, then just toggle between the two possible values given the *actual* value of $c_{in}$.
|
||||
|
||||
The delay is calculated like so:
|
||||
1. Given the delay of a full adder is $k$, and the delay of a 2 to 1 mux is $\frac{1}{m}k$,
|
||||
2. then the delay of a 4 bit ripple carry adder is $4k$, because it's 4 full adders chained together, running sequentially.
|
||||
3. This means that the delay of a 4 bit carry select adder is $4k + \frac{k}{m}$
|
||||
|
||||
# Carry-lookahead adder
|
148
education/computer engineering/ECE2700/Binary Logic.md
Normal file
@ -0,0 +1,148 @@
|
||||
# History of Boolean Algebra
|
||||
- In 1849, George Boole published a scheme for describing logical thought and reasoning
|
||||
- In the 1930s, Claude Shannon applied Boolean algebra to describe circuits built with switches
|
||||
- Boolean algebra provides the theoretical foundation for digital design
|
||||
|
||||
# Properties of Boolean Algebra
|
||||
| Number | Col. A | Col. A Description | Col. B | Col. B Description |
|
||||
| ---------------------- | --------------------------------------------------------------------------------- | ------------------ | ----------------------------------------------------------------------------------- | ------------------ |
|
||||
| 1. | $0 \cdot 0 = 0$ | | $1 + 1 = 1$ | |
|
||||
| 2. | $1 \cdot 1 = 1$ | | $0 + 0 = 0$ | |
|
||||
| 3. | $0 \cdot 1 = 1 \cdot 0 = 0$ | | $1 + 0 = 0 + 1 = 1$ | |
|
||||
| 4. | if $x = 0$ then $\overline{x} = 1$ | | if $x = 1$ then $\overline{x} = 0$ | |
|
||||
| 5. | $x \cdot 0 = 0$ | | $x + 1 = 1$ | |
|
||||
| 6. | $x \cdot 1 = x$ | | $x + 0 = x$ | |
|
||||
| 7. | $x \cdot x = x$ | | $x + x = x$ | |
|
||||
| 8. | $x \cdot \overline{x} = 0$ | | $$x + \overline{x} = 1$ | |
|
||||
| 9. | $\overline{\overline{x}} = x$ | | | |
|
||||
| 10. Commutative | $x \cdot y = y \cdot x$ | | $x + y = y + x$ | |
|
||||
| 11. Associative | $x \cdot (y \cdot z) = (x \cdot y) \cdot z$ | | $x + (y + z) = (x + y) +z$ | |
|
||||
| 12. Distributive | $x \cdot (y +z) = x \cdot y + x \cdot z$ | | $x + y \cdot z = (x + y) \cdot (x + z$ | |
|
||||
| 13. Absorption | $x + x \cdot y = x$ | | $x \cdot (x + y) = x$ | |
|
||||
| 14. Combining | $x \cdot y + x \cdot \overline{y} = x$ | | $(x + y) \cdot (x + \overline{y}) = x$ | |
|
||||
| 15. DeMorgan's Theorem | $\overline{x \cdot y} = \overline{x} + \overline{y}$ | | $x + y = \overline{x} \cdot \overline{y}$ | |
|
||||
| 16. | $x + \overline{x} \cdot y = x + y$ | | $x \cdot (\overline{x} + y) = x \cdot y$ | |
|
||||
| 17. Consensus | $x \cdot y + y \cdot z + \overline{x} \cdot z = x \cdot y + \overline{x} \cdot z$ | | $(x + y) \cdot (y + z) \cdot (\overline{x} + z) = (x + y) \cdot (\overline{x} + z)$ | |
|
||||
# Synthesis
|
||||
In the context of binary logic, synthesis refers to the act of creating a boolean expression that evaluates to match a given truth table.
|
||||
|
||||
This is done by creating a product term for each entry in the table that has an output of $1$, that also evaluates to $1$, then ORing each product term together and then simplifying.
|
||||
|
||||
Example:
|
||||
|
||||
Given the below truth table, synthesize a boolean expression that corresponds.
|
||||
|
||||
| $x_1$ | $x_2$ | $f(x_1, x_2)$ |
|
||||
| ----- | ----- | ------------- |
|
||||
| 0 | 0 | 1 |
|
||||
| 0 | 1 | 1 |
|
||||
| 1 | 0 | 0 |
|
||||
| 1 | 1 | 1 |
|
||||
- $f(0, 0)$ evaluates to true with the expression $\overline{x}_1 \cdot \overline{x}_2$
|
||||
- $f(0, 1)$ evaluates to true with the expression $\overline{x}_1\cdot x_2$
|
||||
- $f(1, 0)$ should provide an output of zero, so that can be ignored
|
||||
- $f(1, 1)$ evaluates to true with the expression $x_1 \cdot x_2$
|
||||
ORing all of the above expression together, we get:
|
||||
$$ f(x_1, x_2) = \overline{x}_1\overline{x}_2 + \overline{x}_1 x_2 + x_1x_2 $$
|
||||
$$
|
||||
\begin{multline}
|
||||
= x_1x_2 \\
|
||||
= x
|
||||
\end{multline}
|
||||
$$
|
||||
# Logic Gates
|
||||
|
||||

|
||||
# NOT Gate
|
||||
A binary NOT gate has a single input, and inverts that input (output is not the input).
|
||||
|
||||
## Truth Table
|
||||
| $x$ | $y$ |
|
||||
| --- | --- |
|
||||
| 0 | 1 |
|
||||
| 1 | 0 |
|
||||
## Mathematical Expression
|
||||
A NOT operation is mathematically expressed using a bar:
|
||||
$$ y = \bar{x} $$
|
||||
# AND Gate
|
||||
An AND gate will only output a 1 if *both* inputs are a one (input one *and* input two are enabled).
|
||||
|
||||
## Truth Table
|
||||
| $x_1$ | $x_2$ | $y$ |
|
||||
| ----- | ----- | --- |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 0 |
|
||||
| 1 | 0 | 0 |
|
||||
| 1 | 1 | 1 |
|
||||
## Mathematical Expression
|
||||
An AND operation is mathematically expressed using a times symbol, or with no symbol at all:
|
||||
$$ y = x_1 \cdot x_2 = x_1x_2$$
|
||||
|
||||
# NAND Gate
|
||||
A NAND gate outputs a 1 *unless* both inputs are enabled (input one *and* input two are *not* enabled).
|
||||
|
||||
## Truth Table
|
||||
| $x_1$ | $x_2$ | $y$ |
|
||||
| ----- | ----- | --- |
|
||||
| 0 | 0 | 1 |
|
||||
| 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 |
|
||||
| 1 | 1 | 0 |
|
||||
## Mathematical Expression
|
||||
A NAND operation is mathematically expressed using a bar over an AND operation:
|
||||
$$ y = \overline{x_1 \cdot x_2}$$
|
||||
|
||||
|
||||
# OR Gate
|
||||
An OR gate outputs a 1 if either or both inputs are enabled (if input one *or* input two is enabled).
|
||||
## Truth Table
|
||||
| $x_1$ | $x_2$ | $y$ |
|
||||
| ----- | ----- | --- |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 |
|
||||
| 1 | 1 | 1 |
|
||||
## Mathematical Expression
|
||||
A mathematical OR is notated with a $+$ symbol.
|
||||
|
||||
$$ y = x_1 + x_2 $$
|
||||
# NOR Gate
|
||||
A NOR gate outputs a one if neither gate is enabled.
|
||||
## Truth Table
|
||||
| $x_1$ | $x_2$ | $y_1$ |
|
||||
| ----- | ----- | ----- |
|
||||
| 0 | 0 | 1 |
|
||||
| 0 | 1 | 0 |
|
||||
| 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 |
|
||||
## Mathematical Expression
|
||||
A NOR operation is expressed using a bar over an OR operation.
|
||||
$$ y = \overline{x_1 + x_2} $$
|
||||
# XOR Gate
|
||||
An XOR gate is on if one input is enabled, but *not* both (exclusively one or the other).
|
||||
|
||||
## Truth Table
|
||||
| $x_1$ | $x_2$ | $y$ |
|
||||
| ----- | ----- | --- |
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 |
|
||||
| 1 | 1 | 0 |
|
||||
## Mathematical Expression
|
||||
An XOR operation is expressed using a circle around an addition symbol:
|
||||
$$ y = x_1 \oplus x_2 $$
|
||||
|
||||
## XNOR Gate
|
||||
An XNOR gate is on if neither input is enabled, or both inputs are enabled.
|
||||
|
||||
## Truth Table
|
||||
|
||||
| $x_1$ | $x_2$ | $y$ |
|
||||
| ----- | ----- | --- |
|
||||
| 0 | 0 | 1 |
|
||||
| 0 | 1 | 0 |
|
||||
| 1 | 0 | 0 |
|
||||
| 1 | 1 | 1 |
|
||||
## Mathematical Expression
|
||||
An XNOR operation is expressed using a bar over an XOR operation:
|
||||
$$ y = \overline{x_1 \oplus x_2} $$
|
56
education/computer engineering/ECE2700/Digital Hardware.md
Normal file
@ -0,0 +1,56 @@
|
||||
Any poduct that contains a logic circuit is classified as digital hardware.
|
||||
- Moore's Law states that the number of a transistors on a chip doubles every two years
|
||||
- The International Technology Roadmap for Semiconductors (ITRS) forecasts technology, including the number of transistors on a chip
|
||||
- Multiple integrated circuits can be connected using a printed circuit board, or PCB.
|
||||
- *Standard chips* conform to an agreed upon standard for functionality and physical configuration. They are usually less than 100 transistors in size, and provide basic building blocks for logic.
|
||||
- These chips are combined to form a larger logic circuit
|
||||
- They were popular until the 1980s
|
||||
- As ICs improved, it became inefficient space-wise to have separate chips for each logical building block
|
||||
- The functionality of these chips is fixed, and they do not change.
|
||||
# Programmable Logic Devices
|
||||
Programmable logic devices (PLDs) include a number of programmable switches that can configure the internal circuitry of a chip
|
||||
- The most common type of PLD is a Field Programmable Gate Array (FPGA)
|
||||
- FPGAs are widely available, but come with the drawback that they're limited in speed and performance
|
||||
|
||||
# Application Specific Integrated Circuits
|
||||
Application Specific Integrated Circuits (ASICs) have higher maximum performance and transistor density compared to FPGAs, but the cost of production is very high.
|
||||
- A logic circuit is made of connected logic gates
|
||||
|
||||
# Binary Numbers
|
||||
In base 10, a value is expressed by an n-tuple with n digits
|
||||
$$ D = d_{n-1}d_{n-2} \cdots d_1 d_0 $$
|
||||
This represents the value
|
||||
$$ V(D) = d_{n-1} * 10^{n-1} + d_{n - 2} * 10^{n-2} + \cdots + d_1 * 10^1 + d_0 * 10^0 $$
|
||||
In a binary or base 2 number system, each digit can be a zero or one, called a *bit*.
|
||||
$$ D = d_{n-1}d_{n-2} \cdots d_1 d_0 $$
|
||||
To determine the integer value, a very similar formula can be used.
|
||||
$$ V(B) = b_{n-1} * 2^{n-1} + b_{n-2} * 2^{n-2} \cdots b_{1} * 2^1 + b_0 * 2^0 $$This formula can be generalized as:
|
||||
*For radix $r$*:
|
||||
$$ k = k_{n-1} k_{n-2} \cdots k_1 k_0$$
|
||||
- The base of a number is often notated in the format of $(n)_b$, EG a base 10 number might be $(14)_{10}$, and a binary number might be $(10)_2$.
|
||||
- The *least significant bit* (LSB) is usually the right-most bit. The highest value bit, or the *most significant bit* (MSB).
|
||||
- A nibble is 4 bits, and a byte is 8 bits
|
||||
## Conversions
|
||||
### Base 10 to Binary
|
||||
Repeatedly divide by 2, and track the remainder.
|
||||
|
||||
As an example, the below table shows how one might convert from $(857)_{10}$ to base 2.
|
||||
|
||||
| Equation | Remainder | |
|
||||
| --------------- | --------- | --- |
|
||||
| $857 / 2 = 428$ | $1$ | |
|
||||
| $428 / 2 = 214$ | $0$ | |
|
||||
| $214 / 2 = 107$ | $0$ | |
|
||||
| $107 / 2 = 53$ | $1$ | |
|
||||
| $53 / 2 = 26$ | $1$ | |
|
||||
| $26 / 2 = 13$ | $0$ | |
|
||||
| $13 / 2 = 6$ | $1$ | |
|
||||
| $6 / 2 = 3$ | $0$ | |
|
||||
| $3 / 2 = 1$ | $1$ | |
|
||||
| $1 / 2 = 0$ | $1$ | |
|
||||
|
||||
The final answer is $1101011001$. The least significant bit is the remainder of the first division operation, and the most significant bit is the remainder of the last operation.
|
||||
# Definitions
|
||||
- **Xtor** is an abbreviation for *transistor*
|
||||
- **Moore's Law** states that the number of transistors on a chip doubles every two years.
|
||||
- A tuple is a finite and ordered list of things
|
37
education/computer engineering/ECE2700/Karnaugh Maps.md
Normal file
@ -0,0 +1,37 @@
|
||||
A Karnaugh map is an alternative to a truth table for representing a function in boolean algebra, and serve as a way to derive minimum cost circuits for a truth table.
|
||||
|
||||
![[karnaugh-maps.png]]
|
||||
|
||||
Given the above truth table, the columns are labelled with $x_1$, and the rows are labelled with $x_2$.
|
||||
|
||||
To find a minimal boolean expression with a Karnaugh map, we need to find the smallest number of product terms ($x_1$, $x_2$) that should produce a 1 for all instances where the cell in a table is $1$.
|
||||
|
||||
# Two Variable Maps
|
||||
|
||||
![[Pasted image 20250224104850.png]]
|
||||
|
||||
- Given the map described in the above image, the output is $1$ for the row where $x_2$ is equal to 1.
|
||||
- Similarly, the output is $1$ for the column where $x_1$ is equal to zero.
|
||||
- By ORing the condition where $x_1$ is zero ($\overline{x_1}$), and the condition where $x_2$ is one ($x_1$), we can find a minimal expression for the truth table.
|
||||
|
||||
# Three Variable Maps
|
||||
![[Pasted image 20250224105753.png]]
|
||||
|
||||
A three variable Karnaugh map is constructed by placing 2 two-variable maps side by side. The values of $x_1$ and $x_2$ distinguish columns in the map, and the value of $x_3$ distinguishes rows in the map.
|
||||
|
||||
To convert a 3 variable Karnaugh map to a minimal boolean expression, start by looking for places in the map that contain 1s next to each other (by row, or by column).
|
||||
|
||||
![[Pasted image 20250224110124.png]]
|
||||
|
||||
From there, describe the pair of 1s using boolean algebra.
|
||||
|
||||
In the above example, the top pair of 1s is in the column where $x_3$ is equal to zero ($\overline{x_3}$), and $x_1$ is equal to $1$ ($x_1$). This describes a single term in the resulting equation ($x_1\overline{x_3}$).
|
||||
|
||||
|
||||
![[Pasted image 20250224110632.png]]
|
||||
> Similar logic can be employed using more than just a *pair* of ones.
|
||||
|
||||
|
||||
# Four Variable Maps
|
||||
![[Pasted image 20250224111117.png]]
|
||||
![[Pasted image 20250224110819.png]]
|
@ -0,0 +1,50 @@
|
||||
- Output depends on input and past behavior
|
||||
- Requires use of storage elements
|
||||
|
||||
# Latches
|
||||
## SR Latch
|
||||
SR stands for *Set*/*Reset*, and functions like so:
|
||||
- When a signal comes into $S$, $Q_a$ is **set** on and stays on until a signal comes into $R$, at which point the output ($Q_a$) is **reset**, back to zero.
|
||||
- $S$ and $R$ are interchangeable, it just impacts whether $Q_a$ or $Q_b$ is set/reset.
|
||||
Truth table:
|
||||
|
||||
| $S$ | $R$ | $Q_a$ | $Q_b$ |
|
||||
| --- | --- | ----- | ----- |
|
||||
| 0 | 0 | 0/1 | 1/0 |
|
||||
| 0 | 1 | 0 | 1 |
|
||||
| 1 | 0 | 1 | 0 |
|
||||
| 1 | 1 | 0 | 0 |
|
||||
![[Pasted image 20250303095542.png]]
|
||||
|
||||
|
||||
## Gated Latch
|
||||
A gated latch is similar to a basic latch, but the output only changes when $clk = 1$.
|
||||
## D Latch
|
||||
A D latch has two inputs, $clk$ and $data$. When $clk$ is high, $data$ is stored.
|
||||
# Flip Flops
|
||||
A latch, but the output only changes on one of the clock edges
|
||||
- Can be a rising edge latch or a falling edge latch
|
||||
## JK Flip Flop
|
||||
Similar to an SR flip flop, a JK flip flop has set/reset inputs, but when *both* inputs are high, then the output is toggled.
|
||||
## T Flip Flop
|
||||
A T Flip Flip, or a toggle flip flop has two inputs:
|
||||
- $clk$ - Clock input
|
||||
- $T$ - Whenever $T$ goes from low to high, the output toggles its state
|
||||
|
||||
# Registers
|
||||
## Shift Register
|
||||
![[Pasted image 20250317101146.png]]
|
||||
Above is a simple shift register.
|
||||
|
||||
## Parallel Shift Register
|
||||
A parallel shift register has 4 inputs, 4 outputs, a serial input, and a shift/load input.
|
||||
|
||||
When the *load* input is high, the input is stored into the register. When the *shift* input is high, the registers are shifted and the serial input is read into the new space.
|
||||
|
||||
# Counters
|
||||
## A 3-bit Up-counter
|
||||
![[Pasted image 20250317102911.png]]
|
||||
|
||||
# Synchronous Sequential Circuits
|
||||
- A synchronous circuit is clock driven, while an asynchronous circuit is not.
|
||||
|
135
education/computer engineering/ECE2700/Verilog/Modules.md
Normal file
@ -0,0 +1,135 @@
|
||||
Modules are the building block through which Verilog is built.
|
||||
|
||||
Each module can be thought of as a black box with a series of inputs, and a series of outputs. Changing the input changes the outputs.
|
||||
|
||||
Module definitions are started with the `module` keyword, and closed with the `endmodule` keyword.
|
||||
|
||||
## Syntax
|
||||
The general syntax of a module is as follows:
|
||||
```verilog
|
||||
// This line is referred to as the *module header*
|
||||
module <name> ([port_list]);
|
||||
// Contents of the module
|
||||
endmodule
|
||||
|
||||
// The port list is optional
|
||||
module <name>;
|
||||
// Contents
|
||||
endmodule
|
||||
```
|
||||
|
||||
Below is an example of the structure of a half adder module:
|
||||
```verilog
|
||||
module half_adder(
|
||||
input a,
|
||||
input b,
|
||||
output sum_bit,
|
||||
output carry_bit
|
||||
);
|
||||
// ------- snip ------------
|
||||
endmodule
|
||||
```
|
||||
|
||||
## Ports
|
||||
Ports are a set of signals that act as input and outputs for a particular module.
|
||||
|
||||
There are 3 kinds of ports:
|
||||
- `input`: Input ports can only receive values from the outside. `input` ports cannot be written to.
|
||||
- `output`: Output ports can be written to, but not read from.
|
||||
- `inout`: Inout ports can send *and* receive values.
|
||||
|
||||
Ports can be declared in the port list, or in the module body. Ports declared in the port list can optionally omit their type and only declare a name, to be specified within the body of the module:
|
||||
```verilog
|
||||
module half_adder(
|
||||
a,
|
||||
b,
|
||||
sum_bit,
|
||||
carry_bit
|
||||
);
|
||||
input a;
|
||||
input b;
|
||||
output sum_bit;
|
||||
output carry_bit;
|
||||
// ----------- snip -----------
|
||||
endmodule
|
||||
```
|
||||
|
||||
The full type of a port can also be defined within the portlist:
|
||||
```verilog
|
||||
```verilog
|
||||
module half_adder(
|
||||
input wire a,
|
||||
input wire b,
|
||||
output wire sum_bit,
|
||||
output wire carry_bit
|
||||
);
|
||||
input a;
|
||||
input b;
|
||||
output sum_bit;
|
||||
output carry_bit;
|
||||
// ----------- snip -----------
|
||||
endmodule
|
||||
```
|
||||
|
||||
### Port types
|
||||
If no type is defined, ports are implicitly defined as *nets* of type `wire`.
|
||||
|
||||
> In verilog, the term *net* refers to network, and it refers to a connection that joins two or more devices together.
|
||||
|
||||
Ports can be a vector type:
|
||||
```verilog
|
||||
module test(a, b, c);
|
||||
input [7:0] a;
|
||||
input [7:0] b;
|
||||
output [7:0] c;
|
||||
// -------- snip ---------
|
||||
endmodule
|
||||
```
|
||||
|
||||
# Instantiation
|
||||
Larger designs can be built by using multiple smaller modules.
|
||||
|
||||
Modules can be *instantiated* within other modules and ports, and these *instances* can be connected with other signals.
|
||||
|
||||
These port connections can be defined by an *ordered list*, or by *name*.
|
||||
|
||||
### By Ordered List
|
||||
```verilog
|
||||
module submodule (input x, y, z, output o);
|
||||
// ------- snip -------
|
||||
endmodule
|
||||
|
||||
module parent;
|
||||
wire a, b, c;
|
||||
wire o;
|
||||
// Similar to C, the type of the module is first, followed by
|
||||
// the name of the module instance.
|
||||
submodule foo (a, b, c, o);
|
||||
endmodule
|
||||
```
|
||||
|
||||
### By Name
|
||||
Ports can also be joined by explicitly defining the name.
|
||||
|
||||
Syntactically, this is done with a dot (`.`), followed by the port name defined by the design, followed by the signal name to connect, wrapped in parenthesis (`.x(a)`).
|
||||
```verilog
|
||||
module submodule (input x, y, z, output o);
|
||||
// ------------snip-----------------
|
||||
endmodule
|
||||
|
||||
module parent;
|
||||
wire a, b, c;
|
||||
wire o;
|
||||
submodule foo (
|
||||
.x(a),
|
||||
.y(b),
|
||||
.z(c),
|
||||
.o(o)
|
||||
);
|
||||
```
|
||||
|
||||
Because association is done by name, the order of definition does not matter.
|
||||
|
||||
### Unconnected ports
|
||||
Ports that are not connected to any wire by the parent module will have a value of high impedance, and is considered unknown/undefined.
|
||||
|
88
education/computer engineering/ECE2700/Verilog/Types.md
Normal file
@ -0,0 +1,88 @@
|
||||
There are two main categories of data types in Verilog. These categories differ in the underlying hardware structure they represent, and they differ in the way they are assigned and retain values.
|
||||
# Nets
|
||||
A *net* refers to a *network* of connections that join two or more devices together.
|
||||
|
||||
Nets connect different hardware entities and *do not store values*.
|
||||
## Wire
|
||||
A `wire` is the most commonly used type of net. When a port is declared in Verilog, it is implicitly given a type of `wire`.
|
||||
|
||||
It is illegal to re-declare a name already in use by a net:
|
||||
```verilog
|
||||
module foo;
|
||||
wire abc;
|
||||
wire a;
|
||||
wire b;
|
||||
wire c;
|
||||
|
||||
wire abc; // ILLEGAL: The wire `abc` is already defined
|
||||
|
||||
```
|
||||
|
||||
# Variables
|
||||
A variable is a data storage element. They retain the last input given.
|
||||
```verilog
|
||||
```verilog
|
||||
module testbench;
|
||||
integer int_a; // Integer variable
|
||||
real real_b; // Real variable
|
||||
time time_c; // Time variable
|
||||
|
||||
initial begin
|
||||
int_a = 32'hfacd_1b34; // Assign an integer value
|
||||
real_b = 0.1234567; // Assign a floating point value
|
||||
|
||||
#20; // Advance simulation time by 20 units
|
||||
time_c = $time; // Assign current simulation time
|
||||
|
||||
// Now print all variables using $display system task
|
||||
$display ("int_a = 0x%0h", int_a);
|
||||
$display ("real_b = %0.5f", real_b);
|
||||
$display ("time_c = %0t", time_c);
|
||||
end
|
||||
endmodule
|
||||
```
|
||||
```
|
||||
## Registers
|
||||
A `reg` can be used to model hardware registers because it stores a value until the next assignment.
|
||||
|
||||
### Integer
|
||||
A Verilog `integer` type is a 32 bit wide storage value. It does not *need* to store integers, it can be used for other purposes.
|
||||
```verilog
|
||||
integer count;
|
||||
```
|
||||
### Time
|
||||
A `time` variable is unsigned, 64 bits wide, and can be used to store time duration for debugging purposes. `realtime` is similar, but time is stored as a floating bit value.
|
||||
|
||||
## Real
|
||||
The `real` type denotes a floating point value.
|
||||
|
||||
## Strings
|
||||
Strings are stored in a vector of `reg`s. The width of the `reg` *must* be large enough to hold the string.
|
||||
|
||||
Each character in a string represents a one byte ASCII value. If the size of the variable is smaller than the string, the string is truncated.
|
||||
# Scalar and Vector Types
|
||||
By default, declarations of a net or `reg` value is 1 bit wide, referred to as a *scalar* value (only a single value).
|
||||
|
||||
```verilog
|
||||
// Scalar declaration
|
||||
wire foo;
|
||||
// Vector declaration, with 8 bits.
|
||||
wire [7:0] bar;
|
||||
```
|
||||
|
||||
Individual bits in a vector can be accessed using array operators, eg `[i]`.
|
||||
|
||||
```verilog
|
||||
reg [7:0] foo;
|
||||
|
||||
// Write to bit 0
|
||||
foo [0] = 1;
|
||||
```
|
||||
|
||||
## Part selects
|
||||
A range of contiguous bits from within another vector can be selected, referred to as a part select. This range can then be treated as a vector.
|
||||
```verilog
|
||||
reg [31:0] foo;
|
||||
// Select bits 23 through 16 (inclusive), and assign the 8 bit hex value `0xff` to them.
|
||||
foo [23:16] = 8'hff;
|
||||
```
|
62
education/computer engineering/ECE2700/Verilog/Verilog.md
Normal file
@ -0,0 +1,62 @@
|
||||
## Boolean Engineering
|
||||
- Truth tables
|
||||
- Only practical for small circuits
|
||||
- Schematic capture
|
||||
- Using CAD to place logic gates on a virtual canvas
|
||||
- Facilitates *hierarchical design*
|
||||
- Good for larger circuits
|
||||
- Don't scale well for very large circuits
|
||||
- Hardware Description Languages
|
||||
- Enables hierarchical design
|
||||
- Standardized by IEEE
|
||||
- Design is more portable
|
||||
- Usable in combination with schematic design
|
||||
|
||||
# Verilog
|
||||
- Originally developed by Gateway Design Automation
|
||||
- Put in public domain in 1990
|
||||
- Standardized in 1995
|
||||
- Originally intended for simulation of logic networks, later adapted to synthesis
|
||||
- Structural Verilog describes how things are laid out at a logic level.
|
||||
|
||||
## Structural Verilog
|
||||
Structural Verilog describes things at a logic level.
|
||||
- The use of logic gates and continuous assignment are markers of structural Verilog.
|
||||
```verilog
|
||||
// V---V---v--v-----portlist (not ordered)
|
||||
module example1(x1, x2, s, f);
|
||||
// Defining the types of the various ports
|
||||
input x1, x2, s;
|
||||
output f;
|
||||
// The first argument is the output value.
|
||||
// In this example, `k`, `g`, `h`, `f` are implicitly declared.
|
||||
// They could also be declared manually with the syntax `wire foo`, alongside the `input` and `output` declarations
|
||||
not(k, s); // You can also NOT a variable using a tilde, eg `~s`
|
||||
and(g, k, x1);
|
||||
and(h, s, x2);
|
||||
or(f, g, h);
|
||||
// You can also do this
|
||||
assign f = (~s & x1) | (s & x2);
|
||||
endmodule
|
||||
```
|
||||
## Behavioral Verilog
|
||||
Behavioral Verilog describes broader behavior, at a higher level
|
||||
- The use of `reg`s, time delays, arithmetic expressions, procedural assignment, and other control flow constructs are markers of behavioral Verilog.
|
||||
```verilog
|
||||
// V---V---v--v-----portlist (not ordered)
|
||||
module example1(x1, x2, s, f);
|
||||
// Defining the types of the various ports
|
||||
input x1, x2, s;
|
||||
output f;
|
||||
always @(a, b)
|
||||
// always @(....) says "do this stuff whenever any of the values inside of @(...) change"
|
||||
{s1, s0} = a + b;
|
||||
endmodule
|
||||
```
|
||||
|
||||
## Testbench Layout
|
||||
- Define UUT module
|
||||
- Initialize Inputs
|
||||
- Wait
|
||||
- Test every possible combination of inputs and validate that the outputs are correct
|
||||
- Debug output can be displayed with `$display("Hello world");`
|
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 102 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 695 KiB |
After Width: | Height: | Size: 331 KiB |
BIN
education/computer engineering/ECE2700/assets/karnaugh-maps.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
education/computer engineering/ECE2700/assets/logic-gates.jpeg
Normal file
After Width: | Height: | Size: 64 KiB |
@ -0,0 +1,42 @@
|
||||
<https://www.vox.com/the-big-idea/2018/3/5/17080470/addiction-opioids-moral-blame-choices-medication-crutches-philosophy>
|
||||
|
||||
|
||||
|
||||
| Claim | Elaboration | Link to source |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Addiction treatment options aren't embraced by the public because treating addiction is seen as indulging in weakness rather than "curing" addiction | - The data shows that we could save many lives by expanding [medication-assisted treatments](https://www.vox.com/science-and-health/2017/7/20/15937896/medication-assisted-treatment-methadone-buprenorphine-naltrexone) and adopting harm reduction policies like [needle exchange programs](https://www.cdc.gov/policy/hst/hi5/cleansyringes/index.html).<br>-Methadone and buprenorphine, the most effective medication-assisted treatments, are [“crutches,”](https://www.nbcnewyork.com/news/local/Methadone-Judge-Rule-Father-Blame-Lepolszki-Son-Overdose-Heroin-Addict-Ruling-I-Team-Investigation-273213211.html) in the words of felony treatment court judge Frank Gulotta Jr.; they are [“just substituting one opioid for another,”](https://www.vox.com/policy-and-politics/2017/5/11/15613258/tom-price-opioid-epidemic) according to former Health and Human Services Secretary Tom Price<br>- | [link](https://www.vox.com/the-big-idea/2018/3/5/17080470/addiction-opioids-moral-blame-choices-medication-crutches-philosophy#:~:text=The%20data%20shows,than%20%E2%80%9Ccuring%E2%80%9D%20i) |
|
||||
| - people view addiction as a moral failure | - Most of us have been trained to use more forgiving language when talking about addiction. We call it a disease. We say that people with addiction should be helped, not blamed. But deep down, many of us still have trouble avoiding the thought that they could stop using if they just tried harder. | |
|
||||
- People view addiction as a moral failure
|
||||
- Addiction treatment options aren't embraced by the public because treating addiction is seen as indulging in weakness rather than "curing" addiction
|
||||
- "Most of us have been trained to use more forgiving language when talking about addiction. We call it a disease. We say that people with addiction should be helped, not blamed. But deep down, many of us still have trouble avoiding the thought that they could stop using if they just tried harder. "
|
||||
- "There’s a part of us that can’t help but see addiction as a symptom of weak character and bad judgment."
|
||||
- The view of addiction as a moral failure is causing real damage to the world
|
||||
- "The stigma against addiction is “the single biggest reason America is failing in its response to the opioid epidemic,” [Vox’s German Lopez concluded](https://www.vox.com/science-and-health/2017/12/18/16635910/opioid-epidemic-lessons) after a year of reporting on the crisis""
|
||||
- "Lives depend on where we come down. The stigma against addiction owes its stubborn tenacity to a specific, and flawed, philosophical view of the mind, a misconception so seductive that it ensnared Socrates in the fifth century BC."
|
||||
- People view addiction as a moral failure because of the subconscious societal belief that our actions always reflect our beliefs and values
|
||||
- "We tend to view addiction as a moral failure because we are in the grip of a simple but misleading answer to one of the oldest questions of philosophy: Do people always do what they think is best? In other words, do our actions always reflect our beliefs and values? When someone with addiction chooses to take drugs, does this show us what she truly cares about — or might something more complicated be going on?"
|
||||
- Plato describes acting against one's best judgement as "Akrasia"
|
||||
- "At one point their discussion turns to the topic of what the Greeks called akrasia: acting against one’s best judgment."
|
||||
- "Akrasia is a fancy name for an all-too-common experience. I know I should go to the gym, but I watch Netflix instead. You know you’ll enjoy dinner more if you stop eating the bottomless chips, but you keep munching nevertheless."
|
||||
- This makes the article more relatable
|
||||
- Socrates felt that this didn't make sense, arguing that actions always reveal true beliefs
|
||||
- "Socrates clearly never went to a restaurant with unlimited chips. But he has a point. To figure out what a person’s true priorities are, we usually look to the choices they make. (“Actions speak louder than words.”) When a person binges on TV, munches chips, or gets high despite the consequences, Socrates would infer that they must care more about indulging now than about avoiding those consequences — whatever they may _say_ to the contrary"
|
||||
- He argues that people simply have bad judgement, and that they aren't acting against their better judgement.
|
||||
- He also argues that bad decisions indicate bad priorities.
|
||||
- The idea that people need to hit "rock bottom" before they can hit true recovery reinforces that idea. It means that a person needs to truly understand the consequences of their "selfishness".
|
||||
- Socratic rationale for punishing drug possession with jail is another example of this idea.
|
||||
- Addiction intensifies the disconnect between judgement and action
|
||||
- "Here’s the testimony of one person with addiction, reported in Maia Szalavitz’s book [_Unbroken Brain_](https://books.google.com/books?id=4yJ3CgAAQBAJ&lpg=PP1&pg=PA114#v=onepage&q&f=false): “I can remember many, many times driving down to the projects telling myself, ‘You don’t want to do this! You don’t want to do this!’ But I’d do it anyway.”
|
||||
- Ethos
|
||||
- The "self" is not a single unitary thing
|
||||
- The concept of a "dual process" mind comes from Nobel laureate Daniel Kahneman, who divides the mind into a part that makes judgements quickly, intuitively, and unconsciously ("System 1") and a part that thinks more slowly, rationally, and consiously ("System 2").
|
||||
- Neuroscientist Kent Berridge notes a system in our brain he calls the "wanting system", which regulates our cravings for things like food, sex, and drugs, using signals based in the neutrotransmitter dopamine
|
||||
- "More pertinent for our purposes is research on what [University of Michigan neuroscientist Kent Berridge](http://www-personal.umich.edu/~berridge/) calls the “wanting system,” which regulates our cravings for things like food, sex, and drugs using signals based in the neurotransmitter dopamine. The wanting system has powerful control over behavior, and its cravings are insensitive to long-term consequences."
|
||||
- He notes that drugs hijack that system causing cravings that are far stronger than humans experience.
|
||||
- The boundaries of where "the self" is in the human brain aren't clearly defined, processes in the brain mesh together tightly, so there's no clean boundary.
|
||||
- From a philosophical sense, there are many different ways to approach the concept of the self.
|
||||
- Modern philosophers reject the socratic view on behavior, instead saying that the self is instead based on judgements about the kind of person one wants to be, and the life they want to lead.
|
||||
- Addiction lies somewhere between choice and compulsion. Addiction doesn't make the choice for you, but it makes you gravitate towards a particular options.
|
||||
- Addiction is not a moral failure because it's still the same person, they just face cravings that are far harder to resist.
|
||||
- Treatments like methadone and buprenorphine can help with addiction by reducing the power of those cravings.
|
||||
-
|
@ -0,0 +1,16 @@
|
||||
- What conversations are meaningful?
|
||||
- What conversations are intentionally emotionally charged?
|
||||
- Fake news is rising
|
||||
- More people get news from social media
|
||||
- The attention economy is extremely effective
|
||||
- Social media is intentionally habit forming
|
||||
- Hate speech is poorly moderated, if at all
|
||||
- Fake news is meant to drive emotion
|
||||
- Manipulating emotions through social media (fake news) should raise
|
||||
- Emotional analytics *can* benefit the user
|
||||
- Very small (1/250 sec) exposure to content still has an impact
|
||||
- News literacy curriculum rarely addresses emotional news literacy
|
||||
- Mindfulness is good
|
||||
- System 1 and 2 thinking
|
||||
- Schools should address larger societal issues in discussion surrounding news literacy
|
||||
-
|
@ -0,0 +1,130 @@
|
||||
- Chose something to genuinely research, because I don't know, rather than a topic I'm passionate about.
|
||||
- Write out my opinion on the topic *before* starting formal research
|
||||
|
||||
- An issue or topic I've always wanted to learn more about is the political system
|
||||
- An issue or topic I have a personal connection to is philosophy, technology
|
||||
- A conversation or debate I spend a lot of time thinking about is the art of improvement
|
||||
- Something I think needs to change in society is the existence of self propagating norms
|
||||
- An issue that affects my community negatively is political discourse.
|
||||
- Something I wish more people cared about was fixing the world
|
||||
- I worry that I see safe spaces being used in a negative way
|
||||
# Primary research
|
||||
- Interview prominent public figures or heads of clubs that have public stated feelings about safe spaces, asking about why they did it, how they did it, what impact they feel it's had.
|
||||
- https://www.usu.edu/safe-at-usu/
|
||||
# Secondary Research
|
||||
- https://qz.com/398723/slavoj-zizek-thinks-political-correctness-is-exactly-what-perpetuates-prejudice-and-racism
|
||||
- https://en.wikipedia.org/wiki/Jonathan_Haidt
|
||||
- https://www.insidehighered.com/node/7407
|
||||
- https://www.vox.com/2016/7/5/11949258/safe-spaces-explained
|
||||
- https://www.dochaspsych.com/blog-defining-your-safe-space-what-does-safe-space-mean/
|
||||
- https://dictionary.cambridge.org/us/dictionary/english/safe-space
|
||||
- https://www.merriam-webster.com/dictionary/safe%20space
|
||||
- https://chicagomaroon.com/2016/news/reg-honors-chicago-blood-bank-founder/
|
||||
# The Complex Case of Fear and Safe Space
|
||||
## Introduction
|
||||
- The Chicago School board considered a proposal for a magnet school intended to be a safe space for LGBT individuals
|
||||
- The only reliable way to prevent disrespectful treatment is through separation
|
||||
- The rational commonly used for safe spaces makes it difficult for an educator to effectively respond to actual harassment
|
||||
- The need for safe space for students who experience social exclusion and harassment is the result of a political economy that was *intended to create safe space for others*. (2) Students *who are able* to articulate a need for safe space often don’t need the kind of space separation offers; *students who need (if only temporarily) separation, often are unable to say so.* (3) ‘‘Safe space’’ does not always or only function to defuse fear and establish safety for students; safe space may also function to create emotional relief for adults
|
||||
- Safe spaces translate feelings of fear into separation, creating a divide
|
||||
- The desire for safe spaces comes from the inherent idea that being hurt is an uncomfortable emotion, and fearing being hurt is an uncomfortable emotion. These are generally perceived to impede students' abilities to learn and grow. As such, safety is the antidote for fear, but this safety creates separation
|
||||
- The creation of safe spaces relies on the assumption that the creators of safe spaces are able to effectively anticipate the fears of students across cultural, racial, and social divides.
|
||||
- In this context, fear is fear of harm and danger. By operating on the assumption that more harm will come, this establishes a power relationship that's rooted in *past histories*, where the disadvantaged group is harmed.
|
||||
- By implementing safe spaces, you create a dynamic where the response to harassment (assumed or real) is fear.
|
||||
- If safe spaces create a dynamic of fear, the effect of safe spaces is less than desirable, and it doesn't move towards the intended goal of making students feel safer, rather it moves them away.
|
||||
## Where do calls for safe spaces come from?
|
||||
- Many students do not want to be separated from their peers
|
||||
- Many students who have the luxury of asking for a safe space don't truly need one
|
||||
- Calls for safe spaces have typically come from parents or educators
|
||||
- Many of the dynamics that enable harassment are invisible to those who enjoy privilege, social or otherwise
|
||||
- A call for a safe space indicates acknowledgement that a student feels uncomfortable in the face of other peers' behavior. The call for a safe space as a solution places that uncomfortable feeling into the box of "fear"
|
||||
- As long as we assume that emotions are instinctual reactions of a person to external events (even if triggered by cognitive judgment) that prompt action, the only available analysis of emotion relies on an outmoded faculty psychology. This has the troubling effect of divorcing logic and affect in action
|
||||
## Fear
|
||||
- Emotions can be viewed through the lens of a cognitive device that can help create and form habits.
|
||||
### Fear as an evolutionary tool
|
||||
- As Dewey helps us to understand, *it is not that fear as emotion causes us to move away from persons perceived as somehow dangerous; rather, affect becomes ‘‘fear’’ by the interpreted action of separation.*
|
||||
- Therefore, neurologically, *fear stems from habit*, not the other way around
|
||||
- Affect arises unbidden in a reaction to a problematic circumstance in which habits of adjustment are inadequate
|
||||
- Basically: You feel fear when you are unable to resolve the perceived issue through typical means
|
||||
- This emotional response doesn't necessarily need to be fear, leading to separation
|
||||
- This emotional response can be redirected into a search for understanding, creating a productive output (Dewey)
|
||||
- The author disagrees with the above sentiment, arguing that fear and anger can be intelligent, productive, emotions.
|
||||
### Fear as a Sociocultural Practice
|
||||
- According to Ahmed, objects and rhetoric can become "sticky, or saturated with emotion"
|
||||
- The author then uses this to reinforce the idea that by propagating "past feelings" forward by proactively acting against them, we continue to let these ideas hold meaning, and power.
|
||||
- The author refers to this propagation of fear as "habituated fear"
|
||||
- This fear works in two ways, the discriminated group fears further discrimination, and the dominant group fears losing control, change, and that which it does not understand. "The more we don't know \[understand] what or who it is we fear, *the more the world becomes fearsome*"
|
||||
- You can change the narrative around an idea, thus changing the emotions associated with it
|
||||
- *By designating fears \[at a societal level], we divide the world into safe spaces and unsafe spaces \[for different groups of people]*
|
||||
- By creating a designated "zone" of safety, you're allowing fear to restrict the space in which "targeted groups" exist in, which in turn allows "attacking groups" to grow and occupy more space
|
||||
- Without the ability to attach fear to certain objects, the "world itself" becomes fearsome. Humans attach fear to certain objects, thus enabling them to view the world from a simpler perspective of "safe", and "unsafe
|
||||
- Those in the discriminated group are often led to mask discomfort because societally, especially in "dominant groups", showing fear is seen as a sign of weakness. They are not able to avoid interacting with the dominant group without facing significant socioeconomic consequences.
|
||||
- The effect of safe spaces is to restrict the movement of parties *least likely* to cause trouble. This includes examples like restricting females to dorms to keep them safe from roving males, to the creation of a LGBT school for the protection of those students
|
||||
- The creation of safe spaces places people into categories, categories built around fear. This is effectively actively *investing* in the set of societal norms, creating further discrimination and harm.
|
||||
### Understanding emotions
|
||||
- Emotions come to be with reference to relational, socially constructed, context oriented experience
|
||||
- Separation is one way in which responding to an event results in the event being recorded as "something to be afraid of" in the amygdala
|
||||
- In may ways, safe spaces enable the habituation of fear in this manner
|
||||
- Fear is an emotion that's more easily used to hurt or control others, by making targeted groups afraid, then you give the dominant group control over them
|
||||
- *Safe spaces are a simple solution for an inherently complicated problem*. They limit rich deconstruction and interpretation of a situation, leading to limited ability to act on a fitting response.
|
||||
- When fear becomes habitually associated with an object, it becomes resistant to rational control
|
||||
- **How does fear benefit the fearful one?**
|
||||
- As people put up defenses from each other, we grow farther apart, and it becomes easier to view a group of people as "the other"
|
||||
- These groups tend to
|
||||
- Harassment can be more effectively combatted by re-interpreting the treatment they receive.
|
||||
|
||||
# Dilemmas of political correctness
|
||||
<https://ora.ox.ac.uk/objects/uuid:40d31aed-1296-4dc6-b511-e7135b83ee8a>
|
||||
- Discussions around political correctness can often be simplified down into such:
|
||||
- Proponents see nothing to fear in erecting norms that inhibit expression on one side, and opponents see this as a misguided effort to silence political enemies.
|
||||
- The author defines political correctness as "the attempt to establish norms of speech (or sometimes behavior) that are thought to protect vulnerable, marginalized, or historically victimized groups, with the goal of shaping public discourse with the goal of avoiding insult or outrage, a lowered sense of self esteem, or otherwise offending sensibilities." By dubbing something politically incorrect, it implies that there is something worrisome or objectionable at work
|
||||
- The author places strong emphasis on the distinction between an idea being morally right or wrong, and being politically correct. He provides the examples that:
|
||||
- Criticizing someone for referring to an administrative assistant as a "secretary" constitutes political correctness, but advocating for higher wages is not
|
||||
- Insisting on trigger warnings or deleting offending material is a form of political correctness, but arguing for rape prevention security measures is not.
|
||||
- In the inverse, it's not politically incorrect to make a donation to fight gay marriage, but it is politically incorrect to speak publicly against gay marriage
|
||||
- Political correctness can be viewed as something to benefit marginalized groups, or as a societal movement towards restraint on public expression
|
||||
- Given the idea that political correctness is a societal movement, it culminates in a form of self censorship where there are consequences for those who violate communal norms
|
||||
- One practical example of this is when German politician Phillipp Jenninger fell into disgrace after a speech that engaged rhetorically with the perspective of Nazi Germany, even though the speech was devoid of Nazi sympathy or anti-semitism. The same speech was given in a jewish synagogue by a jewish leader, and it received no negative response, demonstrating that the worry was the *signal* sent by the speech being given by a german politician
|
||||
- Another practical example is when the mayor of Washington DC was forced to resign after making use of the word "niggardly"
|
||||
- The N word is derived from latin roots (*niger* - dark) and developed from french and spanish roots in the mid 18th century, whereas niggardly is derived from the old english word *nigon*, meaning stingy. The modern etymological root is niggle, meaning giving excessive attention to minor details
|
||||
- Self censorship is an ultimate victory for those seeking to eliminate a form of censorship
|
||||
- Political correctness stems from concern for the victimized groups, and is typically seen on the left end of the political spectrum, but it can also be seen on the right
|
||||
- Examples includes attempts to delegitimize opposition to war by suggesting dissenters are insulting "the brave men and women who fight on our behalf"
|
||||
- Those opposed to political correctness often dismiss it as a trivial insistence to redefine words, or an attempt to silence opposition.
|
||||
- It's easy to dismiss some cases, but it's harder to dismiss others (eg, the taboo on the N word or certain taboos around racial science, or the underlying worries around such ideas).
|
||||
- There are perfectly valid motivations for attempting to cultivate and enforce political norms, eg a record of violence and injustice directed towards African Americans being promoted through superficially respectable means
|
||||
- On a broader level, enlightened moral thinking has led society to converge on a *default norm against advancing ideas associated with oppression or marginalization*
|
||||
- The author agrees with the idea that political correctness has made “the casual infliction of humiliation...much less socially acceptable than it was,” and even that “encouraging students to be ‘politically correct’ has made our country a far better place.”
|
||||
- The author argues that political correctness has brought huge benefits, but there are limits of being politically correct
|
||||
- Where those limits should be located is subject to disagreement. On one end of the spectrum are minor conventions and taboos, at the other end are explicit laws prohibiting forms of expression (hate speech)
|
||||
- You can acknowledge the value of political correctness without endorsing all uses of political correctness as a barrier in public discourse
|
||||
- Potential drawbacks of political correctness are especially relevant when you note how individual applications of political correctness are applied at an extreme level.
|
||||
- Extreme political correctness can often revolve around morally superficial applications of reasonable norms, taken to an extreme
|
||||
- Political correctness concerns offense and sensibilities, not the objective interests of everyone involved.
|
||||
- There's an increasing tendency to reject government terms like "illegal alien" in favor of "undocumented immigrant" with the implication that refusing to do so implies reactionary or hateful views.
|
||||
- One example of political correctness backfiring is when "sensitive" material is removed from coursework to avoid upsetting students.
|
||||
- This is shown with affirmative action causing problems and not having the intended affect
|
||||
- We want to avoid "being gored on either horn"
|
||||
- Enforcing political correctness can lead to widespread "preference falsification", in which what people believe in private is detached from what is spoken in public
|
||||
- "preference falsification" can lead to polarization.
|
||||
- In the example of social justice, many attribute poor social outcomes to factors *external* to the person, because then you can avoid directly blaming the person, an inherently uncomfortable discussion. Regardless of how correct the end result is, this tendency is still present.
|
||||
- In promoting norms intended to benefit marginalized groups, we both help and hurt them.
|
||||
|
||||
# Safe spaces, explained
|
||||
- The author introduces the paper by showcasing some of the negative ways in which safe spaces are viewed and understood.
|
||||
- The author then explains that safe spaces are a place where marginalized groups can feel welcome and accepted
|
||||
- Distinction is made between psychological safety and physical safety
|
||||
- The first usages of the term "safe space" came from the 1960s, where same sex relationships were outlawed, so a safe space was a place where people were able to practice same sex relationships without being noticed by the cops.
|
||||
- Examples of situations where the classical term "safe space" still applies exist in areas where non-heteronormative behavior is outlawed or socially shamed.
|
||||
- The same idea applies to other groups, like women, and people of color.
|
||||
- One advocate for safe spaces states that they've found that being able to surround themselves with people of the same marginalized group makes it easier to be themselves
|
||||
- Some safe spaces are created explicitly, whereas others are created organically
|
||||
- Safe spaces create a place for marginalized groups to truly relax. The author makes the claim that stress caused by discrimination creates poor health outcomes among groups who experience systemic discrimination.
|
||||
- Opponents of safe spaces caution that safe spaces limit social change by preventing the "messy work" of fighting for social change from occurring.
|
||||
- Debate and conflict isn't always what people want or feel they need.
|
||||
- There's a fear that social justice issues are nearly impossible to effectively resolve
|
||||
- Groupthink is a real issue that can occur within safe spaces.
|
||||
- People in marginalized groups have to face the feeling that society wasn't really designed for them, whereas people in dominant groups don't face that experience.
|
||||
|
||||
# How Safe Spaces Contribute to Mental Health
|
||||
- The term safe space is broadly used to describe designated areas or communities
|
@ -0,0 +1,15 @@
|
||||
The author grew up in between American and Mexican cultures. In school, she got punished for speaking Spanish at recess, and in college, she had to attend classes that were taught on how to speak without an accent.
|
||||
|
||||
She proposes the idea that languages are living. They constantly evolve, and different dialects can form as a means of expression or through localization. Languages can mix and merge to form new dialects that contain ideas from both.
|
||||
|
||||
The author then goes on to explain that languages are often used as a means of discrimination, and segregation. However, the inverse is also true. Discriminated groups will often form a new dialect or culture as a result of that discrimination.
|
||||
|
||||
|
||||
- The idea was proposed that languages can form in a way that's predominantly a male discourse.
|
||||
- Languages are living, and dialects form as a means of expression.
|
||||
- Languages mix and merge.
|
||||
- Discrimination and segregation occur because of language, and vice versa.
|
||||
- The language someone speaks is a large part of their identity.
|
||||
- Art created with a culture specific dialect can hold immense significance for members of that culture, and can be a means of sharing that culture.
|
||||
- The culture you exist in becomes internalized in your identity.
|
||||
- Excluding groups from a culture can lead to new cultures forming.
|
@ -0,0 +1,3 @@
|
||||
- First sentence should have author, article name, and main claim the article makes
|
||||
- Summary should be ordered in the same way the ideas in the article are
|
||||
- Use signal phrases ("argues", "makes the claim")
|
@ -0,0 +1,5 @@
|
||||
- Writing is distinct from grammar and rhetoric, and most writing classes don't teach writing, they instead focus on grammar and rhetoric.
|
||||
- Core curriculums ensure essentials, but limit depth and advancement of thinking
|
||||
- Drilling students on grammar does not improve writing ability, students should instead be taught how to use grammar effectively
|
||||
|
||||
- I thought the writing was meandering, rambly, and overly abstract. They never provide a clear definition of what good writing entails
|
@ -0,0 +1,18 @@
|
||||
- Arguing is an essential part of what it means to be human
|
||||
- Humans are not naturally adept at arguments
|
||||
- Our beliefs guide and determine our behavior
|
||||
- Others care how we behave
|
||||
- If beliefs lead to behavior, then controlling beliefs means controlling behaviors
|
||||
- Argumentative skills are self defensive
|
||||
- Diverting attention away from reasons makes those reasons easier to accept
|
||||
- Making opponents of a belief "The Enemy" is another way to make a belief easier to accept
|
||||
- Manipulation of beliefs can generally be categorized as diverting manipulation and distorting manipulation
|
||||
- Everyone aims to be in possession of the truth
|
||||
- Knowing why you believe a certain way is important, perhaps more important than the beliefs themselves.
|
||||
- Cognitive success is being correct, cognitive command is understanding why
|
||||
- Cognitive command doesn't necessarily guarantee correctness, but it enables one to rationally correct themselves
|
||||
- Pushback helps develop more complete understanding
|
||||
- When you only interact with people that agree with you, your beliefs become more extreme.
|
||||
- Deliberative democracy is healthy
|
||||
- Democracy relies on the ability to undo change, ala "we make changes and learn from them as we approach the ideal"
|
||||
- Everyone believes that they haven't been duped.
|
@ -0,0 +1,27 @@
|
||||
# Aristotle
|
||||
Aristotle claimed:
|
||||
- Humans are naturally *political*.
|
||||
- Humans naturally seek to *know*.
|
||||
|
||||
He used the term *political* to describe *humanity's dependency and tendency towards social interaction*.
|
||||
# Society
|
||||
- Humans need to be needed by each other.
|
||||
- Interdependence introduces complexity in society.
|
||||
- A mark of civility is the objection to things that harm others.
|
||||
- People often fail to recognize when they're being exploited in relationships.
|
||||
- We rely on others to share and accumulate data
|
||||
|
||||
# Arguments
|
||||
- Humans don't like being wrong.
|
||||
- Behavior is frequently determined by an individual's beliefs.
|
||||
- People naturally object to info they believe is wrong, in the same way that people naturally object to things that harm others.
|
||||
- **An argument is a rational response to a disagreement**, through showing others *why* they should adopt your beliefs.
|
||||
- From an argument, you want others to rationally adopt your beliefs.
|
||||
- Humans are inherently uncomfortable with disagreement.
|
||||
- You can audit a personal belief while still holding it, and regular auditing of personal beliefs is healthy.
|
||||
- Non-hostile arguments are a good way to audit those beliefs, and as such are healthy.
|
||||
|
||||
# Definitions
|
||||
| Phrase | Definition |
|
||||
| ------------ | --------------------------------------- |
|
||||
| Epistemology | The philosophical analysis of knowledge |
|
@ -1,31 +0,0 @@
|
||||
# Thesis
|
||||
The school should support food trucks during lunch.
|
||||
|
||||
# Problem
|
||||
Many students want better lunch options (look at the ala cart line, interview students), and the school can always use more funding. If the school encourages food trucks to park in the bus parking area during lunch (possibly for a fee or % of income), than it benefits the school because they gain profit, it benefits the students because they get more food options
|
||||
|
||||
TODO: figure out what payment system the school uses, and whether or not they could offer support to food trucks
|
||||
TODO: maybe bring food on presentation day for them?
|
||||
## Pros
|
||||
- students get better lunch options
|
||||
- they can get back to school earlier (help with tardies after lunch)
|
||||
- school fundraisers could use the food trucks (like w/ noodles and co)
|
||||
- school can get money from the thing
|
||||
- supports local small businesses
|
||||
- encourage students to walk around outside
|
||||
|
||||
## Cost
|
||||
|
||||
## Advertising
|
||||
|
||||
# Feasibility
|
||||
- It is legally defensible to restrict the sale of competitive foods *on campus*
|
||||
- *States* can restrict the sale of competitive foods, Utah appears to restrict them based solely off of nutritional value
|
||||
-
|
||||
|
||||
# Links
|
||||
https://www.cdc.gov/healthyschools/mih/pdf/approach5.pdf
|
||||
https://www.govinfo.gov/content/pkg/PLAW-111publ296/pdf/PLAW-111publ296.pdf
|
||||
https://statepolicies.nasbe.org/health/categories/nutrition-environment-and-services/competitive-foods-es/utah
|
||||
https://schools.utah.gov/file/ee7be5e9-2d64-45a4-9a53-fa215fff07df
|
||||
https://gis.cachecounty.org/Websites/Parcel%20and%20Zoning%20Viewer/
|
@ -1,85 +0,0 @@
|
||||
## What is art?
|
||||
**Art**: the expression or application of human creative skill.
|
||||
art must:
|
||||
- be made with the intent to convey emotion
|
||||
- should "satisfy the senses"
|
||||
- be made with intent
|
||||
- have attention to feeling and emotion
|
||||
art may:
|
||||
- be a relay of experience or emotion from one person to another
|
||||
|
||||
## Medium
|
||||
A particular material, along with an accompanying technique (plural: media). Example include:
|
||||
- Acrylic, enamel, gesso, glaze, ink, oil
|
||||
|
||||
## History
|
||||
1. The branch of knowledge dealing with past events
|
||||
## How do you look at art?
|
||||
Purposes and functions of art include:
|
||||
- Communicating information:
|
||||
- In non-literate societies, art was used to teach.
|
||||
- Today, film and television are used to disseminate information.
|
||||
- Spirituality and Religion
|
||||
- All of the world's major religions have used art to inspire and instruct the faithful
|
||||
- Personal and cultural expression
|
||||
- Social and political ends
|
||||
- Artists have criticized or influenced values or public opinion
|
||||
- Often it is clear and direct
|
||||
- Other times, however, it is less obvious
|
||||
- Monarchs who commissioned projects to symbolize their strength and power
|
||||
|
||||
Generally, art can be broken down into two parts, *form*, and *content*.
|
||||
- Form relates to the "formal" aspects of art, composition or medium.
|
||||
- Content relates to the subject. What's being portrayed, how are they portraying it?
|
||||
- The distinction should be made between fact and opinion/guessing.
|
||||
|
||||
Parts of form:
|
||||
1. Line and Shape
|
||||
- Lines define space and may create an outline or contour, as style called "linear"
|
||||
- They can be *visible* or *implied*, and may be a part of composition
|
||||
- It may be 2 dimensional, 3 dimensional, suggested, or implied.
|
||||
- *Wherever there is an edge
|
||||
2. Color
|
||||
- Hue: The name of the color (red, blue, yellow)
|
||||
- Saturation: The quality or vibrancy of those values
|
||||
- Value: The addition of white, black, or grey to the value
|
||||
- Tint: pure hue + white
|
||||
- Tone: pure hue + grey
|
||||
- Shade: pure hue + black
|
||||
3. Texture
|
||||
- Texture is an element of art pertaining to the surface quality or "feel" of the work of art
|
||||
- Texture can be described as smooth, rough, soft, etc. Some textures are real, and others are simulated
|
||||
- Textures that can be *felt* are ones that fingers can actually touch.
|
||||
4. Space and Mass
|
||||
- Space references to what contains objects: may be 2D or 3D.
|
||||
- Mass refers to the effect and degree of the bulk, density, and weight of matter in space.
|
||||
- In architecture or sculpture, it is the area occupied by a form.
|
||||
- Perspective: Foreshortening is a way of representing an object so that it conveys the illusion of depth; an object appears to be thrust forward or backward in space.
|
||||
5. Composition
|
||||
- How are items arranged or organized in art
|
||||
- Symmetrical, asymmetrical
|
||||
- Static or dynamic
|
||||
- Picture space is comprised of foreground, middle ground, and background.
|
||||
6. Scale
|
||||
- As an art history term, scale refers to the size of an object or object represented
|
||||
- Size of things, conveyed or literal
|
||||
|
||||
Parts of style:
|
||||
- Cultural style
|
||||
- Societies develop their own beliefs and style of material forms
|
||||
- Artists are a product of their culture
|
||||
- Period style
|
||||
- Style changes over time
|
||||
- Art changes because of economic and political changes
|
||||
- Regional style
|
||||
- Geography leads to diverse styles
|
||||
- Personal style
|
||||
- Individual artists often have distinct styles
|
||||
|
||||
Two basic forms of style:
|
||||
- Representational: Seeks to create recognizable subject matter (this is a picture of a dog)
|
||||
- Abstract: Seeks to capture the essence of a form, not the literal representation (this picture captures the feeling of a dog)
|
||||
|
||||
| Phrase | Definition |
|
||||
| ---- | ---- |
|
||||
| | |
|
@ -1,37 +0,0 @@
|
||||
| Piece | Place | Artist | Medium | Stuff |
|
||||
| ------------------------------------------------ | ----------------------------- | ------------------------------------ | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Treasury Of Atreus | Ancient Greece: Helladic | Unknown | Limestone | Largest dome for over 1000 years<br>Largest monolithic lintel<br>Ashlar masonry and cyclopic masonry<br>Thought to be Atreus, he abdicated (possibly a tomb)<br>post and lintel and corbelled arch<br> |
|
||||
| Snake Goddess | Ancient Greece: Minoan | Unknown | Faience | Hierarchy of Scale; Exposed breasts - power<br>victory pose<br>rosettes<br>sideways dress - otherworldly<br>We don't know much about this work |
|
||||
| Bull-leaping, from the palace at Knossos | Ancient Greece: Minoan | Unknown | Fresco | Different people with different colors<br>Elongation of bull shows motion<br>Aquatic pattern on border<br>Connection to sea |
|
||||
| Doryphoros (Spear Bearer) or *Canon* | Classical Greece: Classical | Polykleitos | Marble copy after bronze original | Called Canon because it's the standard of beauty for sculptures<br>Used golden ratio<br>Polykleitos was in the cult of pythagoreans<br>Contraposto - counter posture<br>Well preserved because of Pompeii<br> |
|
||||
| Dying Gaul | Classical Greece: Hellenistic | Epigonos | Marble copy after bronze original | Representational hair<br>Objects on ground give sense of place<br>Shows blood and sweat<br>Doesn't portray a greek man (less jacked, less hot), shows a frenchman<br>Choker shows he's a gaul<br>Defeat: Broken sword, no attempt to call for help (horn), sitting on shield |
|
||||
| Aphrodite (Venus de Milo) | Classical Greece: Hellenstic | Alexandros of Antioch-on-the-Meander | Marble | Individualized<br>Lot of detail compared to aphrodite of knidos<br>Dry drapery<br>Contrasting textures<br>Contraposto<br>Has musculature and feminine form<br>More intimate, sensual |
|
||||
| Nike alighting on a warship (Nike of Samothrace) | Classical Greece: Hellenistic | Unknown | Marble | Rhodes probably had a successful naval victory<br>Where Nike got it's logo<br>Wet drapery, would have been in fountain<br>lot of contrasting texture<br>Dynamic<br> |
|
||||
| Pont-du-Gard | Rome: Empire | Unknown | Shelly Limestone | Arches create space<br>Aquaduct helped city<br>columns aligned vertically<br>Ashlar Masonry<br>Used as major bridge<br>Use of Roman arch |
|
||||
| Portrait of Augustus as General | Rome: Empire | Unknown | Marble Copy, Bronze Original | Three powers (ishtar gate):<br>- Curass - Military<br>- Toga - Wealth and political power<br>- Eros - Supernatural power<br>Harkening pose: asking for cooperation, contraposto<br>Idealized proportions<br> |
|
||||
| The Pantheon | Roman: Empire | Patron: Hadrean | Concrete | First pantheon built out of wood, burned down<br>Rebuilt out of concrete<br>Originally built on a hill, now sunk by detrius of time<br>Monolithic columns from egypt in portico(front porch)<br>Had rosettes in ceiling squares<br>Biggest dome in the world<br>Squares and circles everywhere |
|
||||
| Arch of Titus | Rome: Empire | Patron: Titus | Concrete faced with marble | Commemorates when Rome defeats Jerusalem<br>Triumphal Arch <br>Depicts jewish temple being raided, money used to fund colosseum<br>Original historian was jewish (Josephus) |
|
||||
| Portrait of a Husband and Wife | Rome: Empire | Unknown | Fresco | His skin is darker<br>Preserved because of Pompeii<br>She's holding beeswax tablet and stylus<br>They're flexing literacy<br>Literacy was only for the rich<br> |
|
||||
| | | | | |
|
||||
|
||||
| Term | Definition |
|
||||
| -------------------------- | ---------------------------------------------------------------------------------------------------- |
|
||||
| Faience | Metal Glaze, Colder |
|
||||
| Verism | Exaggerated age, wrinkles. Counterpart to hellenism but with emphasis on age instead of muscles |
|
||||
| Chryselephantine | Ivory veneer with gold |
|
||||
| Archaizing | Make something look older in content and style - Fonseca Bust |
|
||||
| Harkening Pose | Asking for cooperatinon |
|
||||
| Patron | Person that paid for it |
|
||||
| Incrustacean | Cut rock in half and flip to show vein - Pantheon |
|
||||
| Portico | Fancy front porch - Pantheon |
|
||||
| Trumphal Arch | Winning army walks through on return home |
|
||||
| Contraposto | The Italian word for counter posture, natural stance, more weight on one foot, body makes an S shape |
|
||||
| Ungrounded | No historical record |
|
||||
| Doric | Masculine, beefy, the simplest, oldest style |
|
||||
| Ionic | Feminine, slender, medium old |
|
||||
| Corinthian | Fancy top, planty shape around the base of the top, latest style |
|
||||
| Corbelled Arch | Rocks that go in gradually, like two wedges |
|
||||
| Post and Lintel | Two posts and a lintel across the top |
|
||||
| Roman arch (with keystone) | Normal vault |
|
||||
| Groin vault | 4 way intersection |
|
||||
| | |
|
@ -1,9 +1,10 @@
|
||||
| Term | Definition |
|
||||
| ---- | ---- |
|
||||
| Consistent | The system of equations has at least one solution |
|
||||
| Inconsistent | Parallel lines, no solution |
|
||||
| Independent | The lines only cross at one point. |
|
||||
| Dependant | The lines are identical, and there are infinitely many solutions. Both equations represent the same line when plotted. |
|
||||
| Term | Definition |
|
||||
| ------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| Consistent | The system of equations has at least one solution |
|
||||
| Inconsistent | Parallel lines, no solution |
|
||||
| Independent | The lines only cross at one point. |
|
||||
| Dependant | The lines are identical, and there are infinitely many solutions. Both equations represent the same line when plotted. |
|
||||
|
||||
# Solving
|
||||
## Graphing
|
||||
Graph the two equations, and look for points where they intersect
|
23
education/math/MATH1060 (trig)/Addition and Subtraction.md
Normal file
@ -0,0 +1,23 @@
|
||||
Given the formula $\sin(\alpha + \beta)$:
|
||||
$$ \sin(\alpha + \beta) = \sin(\alpha)\cos(\beta) + \cos(\alpha)\sin(\beta) $$
|
||||
$$ \sin(\alpha - \beta) = \sin(\alpha)\cos(\beta) - \cos(\alpha)\sin(\beta) $$
|
||||
Given the formula $\cos(\alpha + \beta)$:
|
||||
$$ \cos(\alpha + \beta) = \cos(\alpha)\cos(\beta) - \sin(\alpha)\sin(\beta) $$
|
||||
$$ \cos(\alpha - \beta) = \cos(\alpha)\cos(\beta) + \sin(\alpha)\sin(\beta) $$
|
||||
Given the formula $\tan(\alpha + \beta)$:
|
||||
$$\tan(\alpha + \beta) = \dfrac{\tan\alpha + \tan\beta}{1 - \tan\alpha\tan\beta} $$
|
||||
$$\tan(\alpha - \beta) = \dfrac{\tan\alpha - \tan\beta}{1 + \tan\alpha\tan\beta} $$
|
||||
|
||||
## Cofunctions
|
||||
Given that cofunctions are two functions that add up to 90 degrees, you can use the trig identities for sum and difference to find cofunctions.
|
||||
|
||||
For a right triangle where $\alpha = \theta$, $\beta = \frac{\pi}{2} - \theta$.
|
||||
|
||||
This means that $\sin(\theta) = \cos(\frac{\pi}{2} - \theta)$
|
||||
|
||||
Using this information, you can derive various cofunction identities.
|
||||
|
||||
| $\sin\theta = \cos(\frac{\pi}{2} - \theta)$ | $\cos\theta = \sin(\frac{\pi}{2} - \theta)$ |
|
||||
| ------------------------------------------- | -------------------------------------------- |
|
||||
| $\tan\theta = \cot(\frac{\pi}{2} - \theta)$ | $\cot\theta = \tan(\frac{\pi}{2} - \theta))$ |
|
||||
| $\sec\theta = \csc(\frac{\pi}{2} - \theta)$ | $\csc\theta = \sec(\frac{\pi}{2} - \theta)$ |
|
58
education/math/MATH1060 (trig)/Angles.md
Normal file
@ -0,0 +1,58 @@
|
||||
Angles consist of two rays with the same endpoint and are typically measured in standard position. Standard position is when one of the rays, referred to as the initial side starts at the origin and extend outwards along the $x$ axis, with a second ray referred to as the terminal side.
|
||||
|
||||
If an angle is measured counterclockwise, it's a *positive angle*, and if an angle is measured clockwise, it's a *negative angle*.
|
||||
|
||||
## Degrees and Radians
|
||||
To convert **from radians to degrees**, multiply the radian value by $\frac{180\degree}{\pi}$.
|
||||
$$ x * \frac{180\degree}{\pi}$$
|
||||
To convert **from degrees to radians**, multiply the degree measure by $\frac{\pi}{180\degree}$.
|
||||
$$ x * \frac{\pi}{180\degree} $$
|
||||
|
||||
## Complementary and Supplementary Angles
|
||||
A **complimentary** angle is formed when two positive angles add up to $90\degree$ or $\frac{\pi}{2}$. One mnemonic device that you can use to remember this is:
|
||||
|
||||
> Complementary starts with C, and C stands for corner. $90\degree$ makes a corner.
|
||||
|
||||
A **supplementary** angle is formed when two positive angles add up to $180\degree$ or $\pi$. One mnemonic device that you can use to remember this is:
|
||||
|
||||
> Supplementary starts with S and S stands for straight. $180\degree$ makes a straight line.
|
||||
|
||||
Angles greater than $90\degree$ have no complement and angles greater than $180\degree$ have no supplement.
|
||||
|
||||
# Triangles
|
||||
Triangles are typically notated using $A$, $B$, and $C$ for the angles of a triangle, and $a$, $b$, and $c$ for the sides of a triangle. $C$ will always be the right angle, and $c$ will always refer to the hypotenuse, but $A$/$a$ and $B$/$b$ are used interchangeably.
|
||||
|
||||
For any valid triangle, all three angles will *always* add up to $180\degree$.
|
||||
|
||||
$$ \angle A + \angle B + \angle C = 180 $$
|
||||
|
||||
## Right Angle Triangle Trigonometry
|
||||
|
||||
| SohCahToa | Inverse |
|
||||
| --------------------------------------------- | --------------------------------------------- |
|
||||
| $$ sin\theta = \frac{opposite}{hypotenuse} $$ | $$ csc\theta = \frac{hypotenuse}{opposite}$$ |
|
||||
| $$ cos\theta = \frac{adjacent}{hypotenuse} $$ | $$ sec\theta = \frac{hypotenuse}{adjacent} $$ |
|
||||
| $$ tan\theta = \frac{opposite}{adjacent} $$ | $$ cot\theta = \frac{adjacent}{opposite} $$ |
|
||||
These rules apply regardless of the orientation of the triangle.
|
||||
|
||||
Cosecant, secant, and tangent are inverses of sine, cosine, and tangent respectively, and so they can be found by taking $\frac{1}{x}$, where $x$ is the function you'd like to find the inverse of.
|
||||
|
||||
## Angle of Elevation/Depression
|
||||
- The **angle of elevation** is the angle between the hypotenuse and the bottom line. As an example, if a ladder was leaning against a building, the angle of elevation would be the angle where the ladder intersects with the ground, and it would be the angle between the ladder and the ground.
|
||||
- The **angle of depression** is the angle between the top of the hypotenuse and an (often imaginary) horizontal line.
|
||||
# Definitions
|
||||
| Term | Description |
|
||||
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| Ray | Directed line segment consisting of an endpoint and a direction. Notated as $\overrightarrow{EF}$, where $E$ denotes the endpoint and $F$ denotes a point along the ray. |
|
||||
| Angle | Union of two rays with a common endpoint. Notated as $\angle DEF$ or $\angle FED$, where $D$ and $F$ are along the points of each ray, and $E$ is the vertex. $\angle EFD$ is not valid notation, because the vertex must be the middle. |
|
||||
| $\theta$ | A lowercase theta is used to represent a (non right) angle in a triangle |
|
||||
| $\phi$ | A lowercase phi is used to represent another unknown angle in a triangle. As an example, in an algebraic equation, $x$ might be used to represent the first unknown and $y$ the second. In trig, $\theta$ would be used to represent the first unknown angle, and $\phi$ the second. |
|
||||
| Initial side | In standard position, the initial side is the ray that extends from the origin along the $x$ axis. |
|
||||
| Terminal side | In standard position, the terminal side is the ray that's being measured relative to the initial side. |
|
||||
| $s$ | The length of a curve along the radius. |
|
||||
| Radian | Denoted with $rad$, one radian is equal to the radius, but it's measured along the arc in a curve instead of from the center. |
|
||||
| Complementary Angles | Two positive angles that add up to $90\degree$ or $\frac{\pi}{2}$. One mnemonic device that you can use to remember this is: <br><br>Complementary starts with C, and C stands for corner. $90\degree$ makes a corner. |
|
||||
| Supplementary Angles | Two positive angles that add up to $180\degree$ or $\pi$. One mnemonic device that you can use to remember this is:<br><br>Supplementary starts with S and S stands for straight. $180\degree$ makes a straight line. |
|
||||
| Hypotenuse | The side opposite the right angle in a triangle. |
|
||||
| Opposite | For a given angle $\theta$ in a right triangle, this is the side that does not touch that angle. |
|
||||
| Adjacent | For a given angle $\theta$ in a right triangle, this side makes up the side of the intersection opposite the hypotenuse. |
|
@ -0,0 +1,33 @@
|
||||
To solve for a double or half angle identity:
|
||||
1. Draw a triangle
|
||||
2. Choose an identity to use
|
||||
3. Substitute into formula
|
||||
# Double Angle Identities
|
||||
Sine:
|
||||
$$ \sin(2\theta) = 2\sin\theta\cos\theta $$
|
||||
Cosine:
|
||||
$$
|
||||
\begin{matrix}
|
||||
\cos(2\theta) = \cos^2\theta - \sin^2\theta\\
|
||||
= 1 - 2sin^2\theta\\
|
||||
= 2cos^2\theta - 1\\
|
||||
\end{matrix}
|
||||
$$
|
||||
|
||||
Tan:
|
||||
$$ \tan(2\theta) = \dfrac{2\tan\theta}{1-\tan^2\theta}$$
|
||||
|
||||
## Half Angle Identities
|
||||
Whether the output is positive or negative depends on what quadrant the output is in.
|
||||
Sine:
|
||||
$$ \sin(\frac{\theta}{2}) = \pm\sqrt{\frac{1-\cos\theta}{2}} $$
|
||||
Cosine:
|
||||
$$ \cos(\frac{\theta}{2}) = \pm \sqrt{\frac{1 + \cos\theta}{2}} $$
|
||||
Tangent:
|
||||
$$
|
||||
\begin{matrix}
|
||||
\tan(\dfrac{\theta}{2}) = \pm\sqrt{\dfrac{1-\cos\theta}{1 + \cos\theta}}\\
|
||||
= \dfrac{\sin\theta}{1 + \cos\theta}\\
|
||||
= \dfrac{1 - cos\theta}{\sin\theta}
|
||||
\end{matrix}
|
||||
$$
|
154
education/math/MATH1060 (trig)/Graphing.md
Normal file
@ -0,0 +1,154 @@
|
||||
|
||||
# Sine/Cosine
|
||||

|
||||
|
||||
Given the above graph:
|
||||
- At the origin, $sin(x) = 0$ and $cos(x) = 1$
|
||||
- A full wavelength takes $2\pi$
|
||||
|
||||
# Manipulation
|
||||
| Formula | Movement |
|
||||
| ---------------- | ---------------------------------- |
|
||||
| $y = cos(x) - 1$ | Vertical shift down by 1 |
|
||||
| $y = 2cos(x)$ | Vertical stretch by a factor of 2 |
|
||||
| $y = -cos(x)$ | Flip over x axis |
|
||||
| $y = cos(2x)$ | Horizontal shrink by a factor of 2 |
|
||||
# Periodic Functions
|
||||
A function is considered periodic if it repeats itself at even intervals, where each interval is a complete cycle, referred to as a *period*.
|
||||
# Sinusoidal Functions
|
||||
A function that has the same shape as a sine or cosine wave is known as a sinusoidal function.
|
||||
|
||||
There are 4 general functions:
|
||||
|
||||
| $$A * sin(B*x - C) + D$$ | $$ y = A * cos(B*x -c) + D$$ |
|
||||
| ----------------------------------------- | -------------------------------------- |
|
||||
| $$ y = A * sin(B(x - \frac{C}{B})) + D $$ | $$ y = A*cos(B(x - \frac{C}{B})) + D$$ |
|
||||
|
||||
|
||||
How to find the:
|
||||
- Amplitude: $|A|$
|
||||
- Period: $\frac{2\pi}{B}$
|
||||
- Phase shift: $\frac{C}{|B|}$
|
||||
- Vertical shift: $D$
|
||||
|
||||
|
||||
$$ y = A * \sin(B(x-\frac{C}{B})) $$
|
||||
# Tangent
|
||||
$$ y = tan(x) $$
|
||||

|
||||
To find relative points to create the above graph, you can use the unit circle:
|
||||
|
||||
If $tan(x) = \frac{sin(x)}{cos(x})$, then:
|
||||
|
||||
| $sin(0) = 0$ | $cos(0) = 1$ | $tan(0) = \frac{cos(0)}{sin(0)} = \frac{0}{1} =0$ |
|
||||
| ----------------------------------------- | ----------------------------------------- | ---------------------------------------------------------------- |
|
||||
| $sin(\frac{\pi}{4}) = \frac{\sqrt{2}}{2}$ | $cos(\frac{\pi}{4}) = \frac{\sqrt{2}}{2}$ | $tan(\frac{\pi}{4}) = \frac{\sqrt{2}}{2}/\frac{\sqrt{2}}{2} = 1$ |
|
||||
| $sin(\frac{\pi}{2}) = 1$ | $cos(\frac{\pi}{2}) = 0$ | $tan(\frac{\pi}{2}) = \frac{1}{0} = DNF$ |
|
||||
Interpreting the above table:
|
||||
- When $x = 0$, $y = 0$
|
||||
- When $x = \frac{\pi}{4}$, $y = 1$
|
||||
- When $x = \frac{\pi}{2}$, there's an asymptote
|
||||
|
||||
Without any transformations applied, the period of $tan(x) = \pi$. Because $tan$ is an odd function, $tan(-x) = -tan(x)$.
|
||||
# Cotangent
|
||||
$$ y = cot(x) $$
|
||||

|
||||
|
||||
To find relative points to create the above graph, you can use the unit circle:
|
||||
|
||||
If $cot(x) = \frac{cos(x)}{sin(x)}$, then:
|
||||
|
||||
| $sin(0) = 0$ | $cos(0) = 1$ | $cot(0) = \frac{sin(0)}{cos(0)} = \frac{1}{0} = DNF$ |
|
||||
| ----------------------------------------- | ----------------------------------------- | ---------------------------------------------------------------- |
|
||||
| $sin(\frac{\pi}{4}) = \frac{\sqrt{2}}{2}$ | $cos(\frac{\pi}{4}) = \frac{\sqrt{2}}{2}$ | $cot(\frac{\pi}{4}) = \frac{\sqrt{2}}{2}/\frac{\sqrt{2}}{2} = 1$ |
|
||||
| $sin(\frac{\pi}{2}) = 1$ | $cos(\frac{\pi}{2}) = 0$ | $tan(\frac{\pi}{2}) = \frac{1}{0} = DNF$ |
|
||||
|
||||
Without any transformations applied, the period of $cot(x) = \pi$. Because $cot$ is an odd function, $cot(-x) = -cot(x)$.
|
||||
|
||||
# Features of Tangent and Cotangent
|
||||
Given the form $y = A\tan(Bx - C) + D$ (the same applies for $\cot$)
|
||||
- The stretching factor is $|A|$
|
||||
- The period is $\frac{\pi}{|B|}$
|
||||
- The domain of $tan$ is all of $x$, where $x \ne \frac{C}{B} + \frac{\pi}{2} + {\pi}{|B|}k$, where $k$ is an integer. (everywhere but the asymptotes)
|
||||
- The domain of $cot$ is all of $x$, where $x \ne \frac{C}{B} + \frac{\pi}{|B|}k$, where $k$ is an integer (everywhere but the asymptotes)
|
||||
- The range of both is $(-\infty, \infty)$
|
||||
- The phase shift is $\frac{C}{B}$
|
||||
- The vertical shift is $D$
|
||||
|
||||
# Secant
|
||||
$$ y = \sec(x) $$
|
||||

|
||||
|
||||
$$ sec(x) = \frac{1}{\cos{x}} $$
|
||||
Because secant is the reciprocal of cosine, when $\cos{x} = 0$, then secant is undefined. $|\cos$| is never *greater than* 1, so secant is never *less than* 1 in absolute value. When the graph of cosine crosses the x axis, an asymptote for a matching graph of secant will appear there.
|
||||
|
||||
The general form of secant is:
|
||||
$$ y = A\sec(B{x} - C) + D $$
|
||||
$A$, $B$, $C$, and $D$ will have similar meanings to the secant function as they did to the sine and cosine functions.
|
||||
|
||||
# Cosecant
|
||||
$$ y = \csc(x) $$
|
||||

|
||||
|
||||
$$ \csc(x) = \frac{1}{\sin(x)} $$
|
||||
|
||||
Because cosecant is the reciprocal of sine, when $\sin{x} = 0$, then cosecant is undefined. $|\sin$| is never *greater than* 1, so secant is never *less than* 1 in absolute value. When the graph of sine crosses the x axis, an asymptote for a matching graph of cosecant will appear there.
|
||||
|
||||
The general form of cosecant is:
|
||||
$$ y = A\csc(B{x} - C) + D $$
|
||||
$A$, $B$, $C$, and $D$ will have similar meanings to the cosecant function as they did to the sine and cosine functions.
|
||||
|
||||
# Features of Secant and Cosecant
|
||||
- The stretching factor is $|A|$
|
||||
- The period is $\frac{2\pi}{|B|}$
|
||||
- The domain of secant is all $x$, where $x \ne \frac{C}{B} + \frac{\pi}{2} + \frac{\pi}{|B|}k$, where $k$ is an integer. (Every half period + phase shift is where asymptotes appear)
|
||||
- The domain of cosecant is all $x$, where $x \ne \frac{C}{B} + \frac{\pi}{|B|}k$, where $k$ is an integer.
|
||||
- The range is $(\infty, -|A| +D]\cup [|A| + D], \infty)$
|
||||
- The vertical asymptotes of secant occur at $x = \frac{C}{B} + \frac{\pi}{2} + \frac{\pi}{2} + \frac{\pi}{|B|}k$, where $k$ is an integer.
|
||||
- The vertical asymptotes of cosecant occur at $x = \frac{C}{B} + \frac{\pi}{|B|}k$, where $k$ is an integer.
|
||||
- The vertical shift is $D$.
|
||||
# Inverse Functions
|
||||
For any one to one function $f(x) = y$, a function $f^{-1}(y) = x)$. A function is considered one-to-one if every input only has one output, and every output can only be created from a single input.
|
||||
|
||||
The inverse of a trig function is denoted as $sin^{-1}$, or $arcsin$ respectively.
|
||||
|
||||
The inverse of a trig function is **not** the same as the reciprocal of a trig function, $\frac{1}{sin}$ is not the same as $sin^{-1}$.
|
||||
|
||||
- The *domain* of $f$ is the *range* of $f^{-1}$.
|
||||
- The *range* of $f$ is the *domain* of $f^{-1}$.
|
||||
|
||||
| Trig functions | Inverse trig functions |
|
||||
| ----------------------------------- | ------------------------------------ |
|
||||
| Domain: Angle measures | Domain: Ratio of sides of a triangle |
|
||||
| Range: Ratio of sides of a triangle | Range: Angle Measure |
|
||||
- To find the inverse of sin, you need to restrict the domain to $[-\frac{\pi}{2}, \frac{\pi}{2}]$
|
||||
- To find the inverse of cos, you need to restrict the domain to $[0, \pi]$
|
||||
- To find the inverse of tangent, you need to restrict the domain to $(-\frac{\pi}{2}, \frac{\pi}{2})$.
|
||||
|
||||
The graphs of an inverse function can be found by taking the graph of $f$, and flipping it over the line $y=x$.
|
||||
|
||||
# Examples
|
||||
> Given $-2\tan(\pi*x + \pi) - 1$
|
||||
|
||||
$A = -2$, $B = \pi$, $C = -\pi$, $D = -1$
|
||||
|
||||
> Identify the vertical stretch/compress factor, period, phase shift, and vertical shift of the function $y = 4\sec(\frac{\pi}{3}x - \frac{\pi}{2}) + 1$
|
||||
|
||||
$A = 4$, $B = \frac{\pi}{3}$, $C = \frac{\pi}{2}$, $D = 4$
|
||||
|
||||
Vertical stretch: $|4| = 4$
|
||||
Period: $\frac{2\pi}{\frac{\pi}{3}} = \frac{2\pi}{1} * \frac{3}{\pi} = 6$
|
||||
Phase shift: $\dfrac{\frac{\pi}{2}}{\frac{\pi}{3}} = \frac{3}{2}$
|
||||
Vertical shift: $1$
|
||||
|
||||
| Transformation | Equation |
|
||||
| -------------- | ------------------------- |
|
||||
| Stretch | $\|-2\| = 2$ |
|
||||
| Period | $\frac{\pi}{\|\pi\|} = 1$ |
|
||||
| Phase shift | $\frac{-\pi}{\pi} = -1$ |
|
||||
| Vertical shift | $-1$ |
|
||||
> Evaluate $\arccos{\frac{1}{2}}$ using the unit circle.
|
||||
|
||||
Taking the inverse of the above function, we get this. Because the domain of $cos$ ranges from $0$ to $\pi$ inclusive, the answer is going to be in quadrant 1 or quadrant 2.
|
||||
$$ cos(a) = \frac{1}{2} $$
|
||||
When $x$ is equal to one half, the angle is equal to $\frac{\pi}{3}$.
|
79
education/math/MATH1060 (trig)/Identities.md
Normal file
@ -0,0 +1,79 @@
|
||||
An **identity** is an equation that is true for all values of the variable for which the expressions in the equation are defined.
|
||||
# Trigonometric Identities
|
||||
|
||||
All of the following only apply when the denominator is not equal to zero.
|
||||
|
||||
$$ tan \theta = \frac{y}{x} $$
|
||||
Because the following are inverses of their counterparts, you only need to remember the equivalents for $sin$, $cos$, and $tan$, then just find the inverse by taking $1/v$.
|
||||
|
||||
| Base Identity | Inverse Identity | Alternate Identities | Alternate Inverse Identities |
|
||||
| ----------------------------- | ------------------------------ | --------------------------------------------- | --------------------------------------------------------------------- |
|
||||
| $$ sin\theta = y $$ | $$ csc\theta = \frac{1}{y} $$ | | $$ csc\theta = \frac{1}{sin\theta} $$ |
|
||||
| $$ cos\theta = x $$ | $$ sec \theta = \frac{1}{x} $$ | | $$ sec\theta = \frac{1}{cos\theta} $$ |
|
||||
| $$ tan\theta = \frac{y}{x} $$ | $$ cot\theta = \frac{x}{y} $$ | $$ tan\theta = \frac{sin\theta}{cos\theta} $$ | $$ cot\theta = \frac{1}{tan\theta} = \frac{cos\theta}{sin{\theta}} $$ |
|
||||
# Pythagorean Identities
|
||||
The Pythagorean identity expresses the Pythagorean theorem in terms of trigonometric functions. It's a basic relation between the sine and cosine functions.
|
||||
$$ sin^2 \theta + cos^2 \theta = 1 $$
|
||||
There are more forms that are useful, but they can be derived from the above formula:
|
||||
$$ 1 + tan^2\theta = sec^2\theta $$
|
||||
$$ cot^2 \theta + 1 = csc^2\theta $$
|
||||
# Even and Odd Identities
|
||||
- A function is even if $f(-x) = f(x)$.
|
||||
- A function is odd if $f(-x) = -f(x)$
|
||||
- Cosine and secant are **even**
|
||||
- Sine, tangent, cosecant, and cotangent are **odd**.
|
||||
## Examples
|
||||
### Even and Odd Functions
|
||||
> If $cot\theta = -\sqrt{3}$, what is $cot(-\theta)$?
|
||||
|
||||
$cot$ is an odd function, and so $cot(-\theta) = \sqrt{3}$
|
||||
### Simplifying Using Identities
|
||||
> Simplify $\frac{sin\theta}{cos\theta}$
|
||||
|
||||
1. The above equation can be split into two components
|
||||
$$ \frac{sin\theta}{cos\theta} = \frac{sin\theta}{1} * \frac{1}{csc\theta} $$
|
||||
2. Referring to the list of trig identities, we know that $\frac{1}{csc\theta}$ is equal to $sin\theta$.
|
||||
$$ \frac{sin\theta}{1} * \frac{1}{csc\theta} = sin\theta * sin\theta $$
|
||||
3. Simplifying further, we get:
|
||||
$$ sin^2\theta $$
|
||||
### Finding all values using identities
|
||||
If $sec\theta = -\frac{25}{7}$ and $0 < \theta < \pi$, find the values of the other 5 trig functions:
|
||||
|
||||
1. To find $tan\theta$, we can use the trig identity $1 + tan^2\theta = sec^2\theta$:
|
||||
$$ 1 + tan^2\theta = (-\frac{25}{7})^2 $$
|
||||
Shuffling things around, we get this:
|
||||
$$ tan^2\theta = \frac{625}{49} - 1 $$
|
||||
|
||||
Performing that subtraction gives us this:
|
||||
$$ \frac{625}{49} - \frac{49}{49} = \frac{576}{49} = tan^2\theta $$
|
||||
You can get rid of the exponent:
|
||||
|
||||
$$ \sqrt{\frac{576}{49}} = tan\theta $$
|
||||
$\sqrt{576} = 24$ and $\sqrt{49} = 7$, so:
|
||||
$$ tan\theta = \frac{24}{7} $$
|
||||
2. To find $cos\theta$, because $sec$ is the inverse of $cos$, we can use the identity $sec\theta = \frac{1}{cos\theta}$:
|
||||
$cos\theta = -\frac{7}{25}$
|
||||
|
||||
3. To find $sin\theta$, we can use the trig identity $sin^2\theta + cos^2\theta = 1$:
|
||||
$$ sin^2\theta + (-\frac{7}{25}) = 1 $$
|
||||
Rearranging, we get:
|
||||
$$ 1 - (-\frac{7}{25})^2 = sin^2\theta $$
|
||||
Applying the exponent gives us $\frac{49}{625}$, so we can do this:
|
||||
$$ \frac{625}{625} - \frac{49}{625} = \frac{576}{625} = sin^2\theta $$
|
||||
|
||||
Getting rid of the exponent:
|
||||
$$ \sqrt{\frac{576}{625}} = \frac{24}{25} = sin\theta $$
|
||||
|
||||
From there, you can find the rest of the identities fairly easily.
|
||||
|
||||
# Simplifying trig expressions using identities
|
||||
Given the difference of square formula:
|
||||
$$ a^2 - b^2 = (a-b)(a+b) $$
|
||||
|
||||
## Examples
|
||||
Simplify $\tan\theta\sin\theta + \cos\theta$:
|
||||
1. $\dfrac{\sin\theta}{\cos\theta} * \sin\theta + \cos\theta$
|
||||
2. $\dfrac{\sin^2\theta}{cos\theta} + \cos\theta$
|
||||
3. $(\dfrac{\sin^2\theta}{cos\theta} + \cos\theta)\dfrac{\cos\theta}{\cos\theta} = \sin^2\theta*\cos^2\theta + \cos\theta$
|
||||
|
||||
Si\
|
6
education/math/MATH1060 (trig)/Law of Cosines.md
Normal file
@ -0,0 +1,6 @@
|
||||
The Law of Cosines is useful when solving for SAS or SSS triangles.
|
||||
$$ a^2 = b^2 + c^2 -2bc\cos(\alpha) $$
|
||||
$$ b^2 = a^2 + c^2 -2ac\cos(\beta) $$
|
||||
$$ c^2 = a^2 + b^2 -2ab\cos(\gamma) $$
|
||||
- When using the Law of Cosines to solve for SSS triangles, start solving for the largest angle.
|
||||
- When correctly solved, the smallest angle will be opposite the smallest side, and the largest angle will be opposite the largest side.
|
33
education/math/MATH1060 (trig)/Law of Sines.md
Normal file
@ -0,0 +1,33 @@
|
||||
# Intro
|
||||
Tl;dr, the law of sines is:
|
||||
$$ \frac{\sin(\alpha)}{a} = \frac{\sin(\beta)}{b} = \frac{\sin(\gamma)}{c} $$
|
||||
Under convention:
|
||||
- Angle $\alpha$ is opposite side $a$
|
||||
- Angle $\beta$ is opposite side $b$
|
||||
- Angle $\gamma$ is opposite side $c$
|
||||
|
||||
- Any triangle that is *not a right triangle* is called an oblique triangle. There are two types of oblique triangles:
|
||||
- **Acute triangles**: This is an oblique triangle where all three interior angles are less than $90\degree$ or $\dfrac{\pi}{2}$ radians.
|
||||
- **Obtuse Triangle**: This is an oblique triangle where one of the interior angles is greater than $90\degree$.
|
||||
## Different types of oblique triangles
|
||||
1. **ASA Triangle**: (Angle Side Angle) - We know the measurements of two angles and the side between them
|
||||
2. **AAS**: We know the measurements of two angles and a side that is not between the known angles.
|
||||
3. **SSA**: We know the measurements of two sides and an angle that is not between the known sides.
|
||||
These triangles can be solved by adding a line that goes from one vertex to intersect perpendicular to the opposite side, forming two right triangles ($h$).
|
||||
|
||||
## Solving for the law of sines
|
||||
We know that $\sin\alpha = \dfrac{h}{b}$ and $\sin\beta = \dfrac{h}{a}$. We can sole both equations for $h$ to get:
|
||||
- $h = b\sin\alpha$
|
||||
- $h = a\sin\beta$
|
||||
Setting both equations equal to each other gives us:
|
||||
$b\sin\alpha = a\sin\beta$
|
||||
|
||||
Multiply both sides by $\dfrac{1}{ab}$ gives yields $\dfrac{\sin\alpha}{a} = \dfrac{\sin\beta}{b}$
|
||||
|
||||
# SSA triangles
|
||||
Side side angle triangles may be solved to have one possible solution, two possible solutions, or no possible solutions.
|
||||
|
||||
- No triangle: $a < h$
|
||||
- One triangle: $a \ge b$
|
||||
- Two triangles: $h < a < b$
|
||||
- One right triangle: $a = h$
|
34
education/math/MATH1060 (trig)/The Unit Circle.md
Normal file
@ -0,0 +1,34 @@
|
||||
# Introduction
|
||||
The unit circle has a center a $(0, 0)$, and a radius of $1$ with no defined unit.
|
||||
|
||||
Sine and cosine can be used to find the coordinates of specific points on the unit circle.
|
||||
|
||||
**Sine likes $y$, and cosine likes $x$.**
|
||||

|
||||
When sine is positive, the $y$ value is positive. When $x$ is positive, the cosine is positive.
|
||||
|
||||
$$ cos(\theta) = x $$
|
||||
$$ sin(\theta) = y $$
|
||||
|
||||
## Sine and Cosine
|
||||
| Angle | $0$ | $\frac{\pi}{6}$ or $30 \degree$ | $\frac{\pi}{4}$ or $45\degree$ | $\frac{\pi}{2}$ or $90\degree$ |
|
||||
| ------ | --- | ------------------------------- | ------------------------------ | ------------------------------ |
|
||||
| Cosine | 1 | $\frac{\sqrt{3}}{2}$ | $\frac{\sqrt{2}}{2}$ | $0$ |
|
||||
| Sine | 0 | $\frac{1}{2}$ | $\frac{\sqrt{2}}{2}$ | <br>$1$ |
|
||||
|
||||

|
||||
|
||||
Finding a reference angle:
|
||||
|
||||
| Quadrant | Formula |
|
||||
| -------- | --------------------- |
|
||||
| 1 | $\theta$ |
|
||||
| 2 | $180\degree - \theta$ |
|
||||
| 3 | $\theta - 180\degree$ |
|
||||
| 4 | $360\degree - \theta$ |
|
||||
# Definitions
|
||||
|
||||
| Term | Description |
|
||||
| ---------------- | ----------------------------------------------------------------------------- |
|
||||
| $\theta$ (theta) | Theta refers to the angle measure in a unit circle. |
|
||||
| $s$ | $s$ is used to the length of the arc created by angle $\theta$ on the circle. |
|
57
education/math/MATH1060 (trig)/Vectors.md
Normal file
@ -0,0 +1,57 @@
|
||||
A vector is a mathematical concept that denotes direction and magnitude. They're often notated using an arrow ($\vec{v}$), or with a bold, lowercase letter. (**v**).
|
||||
|
||||
|
||||
Vectors are often denoted as a matrix with two rows: $\begin{bmatrix}1 \\2\end{bmatrix}$
|
||||
# Component Form
|
||||
If $\vec{v}$ is a vector with the initial point $(x_y,\ y_i)$, and a terminal point $(x_t,\ y_t)$, we can express $\vec{v}$ in component form as $\vec{v} = \langle x_t - x_i,\ y_t, -y_i \rangle$
|
||||
# Magnitude
|
||||
The magnitude of a vector is $|\vec{v}| = \sqrt{a^2 + b^2}$
|
||||
|
||||
# Direction
|
||||
The direction of a vector is $\theta = \tan^-1(\frac{b}{a})$.
|
||||
|
||||
# Addition
|
||||
To find $\vec{u} + \vec{v}$, we can put one vector on the end of another vector. The resulting vector will share the same tail as the first vector, and the same head as the second vector.
|
||||
|
||||
# Scalar Multiplication
|
||||
A **scalar** is just a real number. Scalar multiplication is multiplying a vector with a real number. This will scale or shrink a vector, but does not change the direction it points at.
|
||||
|
||||
We do not multiply two vectors together.
|
||||
# Unit Vector
|
||||
A vector with a magnitude of 1 is a **unit vector**.
|
||||
|
||||
If $\vec{v}$ is a nonzero vector, the unit vector can be found using the equation $\vec{u} = \dfrac{1}{|\vec{v}|}\vec{v}$ . In other words, to find a unit vector, divide the vector by its magnitude.
|
||||
|
||||
# $i$, $j$ Notation
|
||||
Every 2D vector has a horizontal component and a vertical component. The horizontal unit vector could be written as $i = \langle 1, 0 \rangle$, and the vertical unit vector could be written as $j = \langle 0, 1 \rangle$ Every vector can be made up using a combination of these standard unit vectors.
|
||||
|
||||
# Trigonometric Form
|
||||
Given a vector $\vec{v}$ with a magnitude $|\vec{v}|$ and direction $\theta$:
|
||||
|
||||
The component form is given as:
|
||||
|
||||
$$ \vec{v} = \langle |\vec{v}||\cos \theta,\ |\vec{v}|\sin\theta \rangle $$
|
||||
|
||||
# Standard position
|
||||
- A vector is in standard position if the initial point is at $(0, 0)$.
|
||||
|
||||
# The Dot Product
|
||||
The dot product of two vectors $\vec{u} = \langle a, b \rangle$ and $\vec{v} = \langle c, d \rangle$ is $\vec{u} * \vec{v} = ac + bd$.
|
||||
|
||||
- Given that $\vec{u} = \langle -7, 3 \rangle$, and $\vec{v} = \langle -3, 4 \rangle$, find $\vec{u} \cdot \vec{v}$.
|
||||
- $\vec{u} \cdot \vec{v} = -7 \cdot -4 + 3 \cdot 4$
|
||||
|
||||
The dot product can be used to find the angle between two vectors.
|
||||
|
||||
If $\theta (0\degree < \theta < 180\degree)$, is the angle between two nonzero vectors $\vec{u}$ and $\vec{v}$, then
|
||||
$$ \cos\theta = \dfrac{\vec{u}\cdot\vec{v}}{|\vec{u}||\vec{v}|} $$
|
||||
|
||||
# Work
|
||||
The dot product can be used to compute the work required to move an object a certain distance.
|
||||
|
||||
To compute work, you need a force and direction. If the force is applied in the same direction:
|
||||
|
||||
$$ W = Fd $$
|
||||
|
||||
The work $W$ is done by a constant force $\vec{F}$ in moving an object from a point $P$ to a point $Q$ is defined by:
|
||||
$$ W = \vec{F} \cdot\vec{PQ} = |\vec{F}||\vec{PQ}|\cos\theta $$Where $\theta$ is the angle between $\vec{F}$ and $\vec{PQ}$.
|
1
education/math/MATH1060 (trig)/assets/graphcot.svg
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
education/math/MATH1060 (trig)/assets/graphcsc.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
education/math/MATH1060 (trig)/assets/graphsec.jpg
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
education/math/MATH1060 (trig)/assets/graphsincos.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
education/math/MATH1060 (trig)/assets/graphtan.png
Normal file
After Width: | Height: | Size: 201 KiB |
BIN
education/math/MATH1060 (trig)/assets/sincoscirc.png
Normal file
After Width: | Height: | Size: 56 KiB |