init
commit
9cb2a60ffd
|
@ -0,0 +1,9 @@
|
|||
# CSS
|
||||
|
||||
Ah the design and creative part of front end coding. This is what I started out doing when I was around 12 years old on neopets.com. The world has gotten a lot better since then now and we have many options for web design and front end programming.
|
||||
|
||||
---
|
||||
|
||||
|
||||
- One of the best tools to use for CSS is https://tailwindcss.com/
|
||||
- for more info on how to set it up: https://tailwindcss.com/docs/installation
|
|
@ -0,0 +1,376 @@
|
|||
# Code Conventions for the JavaScript Programming Language
|
||||
|
||||
written by Douglass Crockford on 2019-05-15. read via browser [here](https://www.crockford.com/code.html).
|
||||
|
||||
---
|
||||
This is a set of coding conventions and rules for use in JavaScript programming.
|
||||
|
||||
The long-term value of software to an organization is in direct proportion to the quality of the codebase. Over its lifetime, a program will be handled by many pairs of hands and eyes. If a program is able to clearly communicate its structure and characteristics, it is less likely that it will break when modified in the never-too-distant future. Code conventions can help in reducing the brittleness of programs.
|
||||
|
||||
All of our JavaScript code is sent directly to the public. It should always be of publication quality. Neatness counts. Diversity of people, culture, and perspective is a good and valueable thing. Diversity of programming styles is a bad thing. It creates friction, impeding the ability of people to work together. It can make it easier for bugs to form and hide.
|
||||
|
||||
## JavaScript Files
|
||||
|
||||
JavaScript programs should be stored in and delivered as `.js` files.
|
||||
|
||||
JavaScript code should not be embedded in HTML files unless the code is specific to a single session. Code in HTML adds significantly to pageweight with no opportunity for mitigation by caching, minification, and compression.
|
||||
|
||||
## Whitespace
|
||||
|
||||
Where possible, these rules are consistent with centuries of good practice with literary style. Deviations from literary style should only be tolerated if there is strong evidence of a significant benefit. Personal preference is not a significant benefit.
|
||||
|
||||
Blank lines improve readability by setting off sections of code that are logically related.
|
||||
|
||||
Blank spaces should always be used in the following circumstances:
|
||||
circumstances:
|
||||
|
||||
- A keyword followed by `(` left parenthesis should be separated by a space. Spaces are used to make things that are not invocations look less like invocations, so for example, there should be space after `if` or `while`.
|
||||
|
||||
while (true) {
|
||||
|
||||
- A blank space should not be used between a function value and its invoking `(` left parenthesis. This helps to distinguish between keywords and function invocations.
|
||||
- The word `function` is always followed with one space.
|
||||
- No space should separate a unary operator and its operand except when the operator is a word such as `typeof`.
|
||||
- All binary operators should be separated from their operands by a space on each side except `.` period and `(` left parenthesis and `[` left bracket.
|
||||
- Every , comma should be followed by a space or a line break.
|
||||
- Each ; semicolon at the end of a statement should be followed with a line break.
|
||||
- Each ; semicolon in the control part of a `for`statement should be followed with a space.
|
||||
|
||||
Every statement should begin aligned with the current indentation. The outermost level is at the left margin. The indentation increases by 4 spaces when the last token on the previous line is `{` left brace, `[` left bracket, `(` left paren. The matching closing token will be the first token on a line, restoring the previous indentation.
|
||||
|
||||
The ternary operator can be visually confusing, so wrap the entire ternary expression in parens. The condition, the `?` question mark, and the `:` colon always begins a line, indented 4 spaces.
|
||||
|
||||
let integer = function (
|
||||
value,
|
||||
default_value
|
||||
) {
|
||||
value = resolve(value);
|
||||
return (
|
||||
typeof value === "number"
|
||||
? Math.floor(value)
|
||||
: (
|
||||
typeof value === "string"
|
||||
? value.charCodeAt(0)
|
||||
: default_value
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
Clauses (`case`, `catch`, `default`, `else`, `finally`) are not statements and so should not be indented like statements.
|
||||
|
||||
Use of tabs invites confusion, argument,and crying, with little compensating value. Do not use tabs. Use space.
|
||||
|
||||
## Comments
|
||||
|
||||
Be generous with comments. It is useful to leave information that will be read at a later time by people (possibly your future self) who will need to understand what you have done and why. The most valuable comments talk about intentions and reasons, things that are not easily discovered by reading the code. The comments should be well-written and clear, just like the code they are annotating. An occasional nugget of humor might be appreciated. Frustrations and resentments will not.
|
||||
|
||||
It is important that comments be kept up-to-date. Erroneous comments can make programs even harder to read and understand.
|
||||
|
||||
Make comments meaningful. Focus on what is not immediately visible. Don't waste the reader's time with stuff like
|
||||
|
||||
// Set i to zero.
|
||||
|
||||
i = 0;
|
||||
|
||||
Use line comments, not block comments. The comments should start at the left margin.
|
||||
|
||||
## Variable Declarations
|
||||
|
||||
All variables should be declared before used. JavaScript does not require this, but doing so makes the program easier to read and makes it easier to detect undeclared variables that may become implied. Implied global variables should never be used. Use of global variables should be minimized.
|
||||
|
||||
let current_entry; // currently selected table entry
|
||||
let level; // indentation level
|
||||
let size; // size of the table
|
||||
|
||||
## Function Declarations
|
||||
|
||||
All functions should be declared before they are used. Inner functions should come after the outer function's variable declarations. This helps make it clear what variables are included in its scope.
|
||||
|
||||
There should be no space between the name of a function and the `(` left parenthesis of its parameter list. There should be one space between the `)` right parenthesis and the `{` left curly brace that begins the statement body. The body itself is indented four spaces. The `}` right curly brace is aligned with the line containing the beginning of the declaration of the function.
|
||||
|
||||
function outer(c, d) {
|
||||
let e = c * d;
|
||||
|
||||
function inner(a, b) {
|
||||
return (e * a) + b;
|
||||
}
|
||||
|
||||
return inner(0, 1);
|
||||
}
|
||||
|
||||
This convention works well with JavaScript because in JavaScript, functions and object literals can be placed anywhere that an expression is allowed. It provides the best readability with inline functions and complex structures.
|
||||
|
||||
function getElementsByClassName(className) {
|
||||
let results = [];
|
||||
walkTheDOM(
|
||||
document.body,
|
||||
function (node) {
|
||||
let array; // array of class names
|
||||
let ncn = node.className; // the node's classname
|
||||
|
||||
// If the node has a class name, then split it into a list of simple names.
|
||||
// If any of them match the requested name, then append the node to the list of results.
|
||||
|
||||
if (ncn && ncn.split(" ").indexOf(className) >= 0) {
|
||||
results.push(node);
|
||||
}
|
||||
}
|
||||
);
|
||||
return results;
|
||||
}
|
||||
|
||||
If a function literal is anonymous, there should be one space between the word `function` and the `(` left parenthesis. If the space is omitted, then it can appear that the function's name is `function`, which is an incorrect reading.
|
||||
|
||||
div.onclick = function (e) {
|
||||
return false;
|
||||
};
|
||||
|
||||
that = {
|
||||
method: function () {
|
||||
return this.datum;
|
||||
},
|
||||
datum: 0
|
||||
};
|
||||
|
||||
Use of global functions should be minimized.
|
||||
|
||||
When a function is to be invoked immediately, the entire invocation expression should be wrapped in parens so that it is clear that the value being produced is the result of the function and not the function itself.
|
||||
|
||||
let collection = (function () {
|
||||
let keys = [];
|
||||
let values = [];
|
||||
|
||||
return {
|
||||
get: function (key) {
|
||||
let at = keys.indexOf(key);
|
||||
if (at >= 0) {
|
||||
return values[at];
|
||||
}
|
||||
},
|
||||
set: function (key, value) {
|
||||
let at = keys.indexOf(key);
|
||||
if (at < 0) {
|
||||
at = keys.length;
|
||||
}
|
||||
keys[at] = key;
|
||||
values[at] = value;
|
||||
},
|
||||
remove: function (key) {
|
||||
let at = keys.indexOf(key);
|
||||
if (at >= 0) {
|
||||
keys.splice(at, 1);
|
||||
values.splice(at, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
## Names
|
||||
|
||||
Names should be formed from the 26 upper and lower case letters (`A` .. `Z`, `a` .. `z`), the 10 digits (`0` .. `9`), and `_` underbar. Avoid use of international characters because they may not read well or be understood everywhere. Do not use `$` dollar sign or `\` backslash in names.
|
||||
|
||||
Do not use `_` underbar as the first or last character of a name. It is sometimes intended to indicate privacy, but it does not actually provide privacy. If privacy is important, use closure. Avoid conventions that demonstrate a lack of competence.
|
||||
|
||||
Most variables and functions should start with a lower case letter.
|
||||
|
||||
Constructor functions that must be used with the `new`prefix should start with a capital letter. JavaScript issues neither a compile-time warning nor a run-time warning if a required `new` is omitted. Bad things can happen if `new` is missing, so the capitalization convention is an important defense.
|
||||
|
||||
Global variables should be avoided, but when used should be in `ALL_CAPS`.
|
||||
|
||||
## Statements
|
||||
|
||||
### Simple Statements
|
||||
|
||||
Each line should contain at most one statement. Put a `;` semicolon at the end of every statement that does not end with a `{`block`}`. Note that an assignment statement that is assigning a function literal or object literal is still an assignment statement and must end with a semicolon.
|
||||
|
||||
JavaScript allows any expression to be used as a statement. This can mask some errors, particularly in the presence of semicolon insertion. The only expressions that should be used as statements are assignments, invocations, and `delete`.
|
||||
|
||||
### Compound Statements
|
||||
|
||||
Compound statements are statements that contain lists of statements enclosed in `{ }` curly braces.
|
||||
|
||||
- The enclosed statements should be indented four more spaces.
|
||||
- The `{` left curly brace should be at the end of the line that begins the compound statement.
|
||||
- The `}` right curly brace should begin a line and be indented to align with the beginning of the line containing the matching `{` left curly brace.
|
||||
- Braces should be used around all statements, even single statements, when they are part of a control structure, such as an `if` or `for` statement. This makes it easier to add statements without accidentally introducing bugs.
|
||||
|
||||
### Labels
|
||||
|
||||
Statement labels should be avoided. Only these statements should be labeled: `while`, `do`, `for`, `switch`.
|
||||
|
||||
### `return` Statement
|
||||
|
||||
The return value expression must start on the same line as the `return` keyword in order to avoid semicolon insertion.
|
||||
|
||||
### `if` Statement
|
||||
|
||||
An `if` statement should have one of these forms:
|
||||
|
||||
```
|
||||
if (condition) {
|
||||
statements
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
if (condition) {
|
||||
statements
|
||||
} else {
|
||||
statements
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
if (condition) {
|
||||
statements
|
||||
} else if (condition) {
|
||||
statements
|
||||
} else {
|
||||
statements
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
### `for` Statement
|
||||
|
||||
The `for` should be avoided, preferring the array methods if possible. When the `for` statement is used, it should one of these forms:
|
||||
|
||||
```
|
||||
for (initialization; condition; update) {
|
||||
statements
|
||||
}
|
||||
|
||||
for (
|
||||
initialization;
|
||||
condition;
|
||||
update
|
||||
) {
|
||||
statements
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### while Statement
|
||||
|
||||
A `while` statement should have the following form:
|
||||
|
||||
```
|
||||
while (condition) {
|
||||
statements
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### `do` Statement
|
||||
|
||||
A `do` statement should have this form:
|
||||
|
||||
```
|
||||
do {
|
||||
statements
|
||||
} while (condition);
|
||||
|
||||
```
|
||||
|
||||
Unlike the other compound statements, the `do`statement always ends with a `;` semicolon.
|
||||
|
||||
### `switch` Statement
|
||||
|
||||
A `switch` statement should be avoided, but when used should have this form:
|
||||
|
||||
```
|
||||
switch (expression) {
|
||||
case expression:
|
||||
statements
|
||||
default:
|
||||
statements
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Each `case` is aligned with the `switch`. This avoids over-indentation. A `case` label is not a statement, and should not be indented like one.
|
||||
|
||||
Each group of statements (except the `default`) should end with `break`, `return`, or `throw`. Do not fall through.
|
||||
|
||||
### `try` Statement
|
||||
|
||||
The `try` statement should have this form:
|
||||
|
||||
```
|
||||
try {
|
||||
statements
|
||||
} catch (variable) {
|
||||
statements
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
The `finally` clause should be avoided. If it is used, it should have this form:
|
||||
|
||||
```
|
||||
try {
|
||||
statements
|
||||
} catch (variable) {
|
||||
statements
|
||||
} finally {
|
||||
statements
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### `continue` Statement
|
||||
|
||||
Avoid use of the `continue` statement. It tends to obscure the control flow of the function.
|
||||
|
||||
### `with` Statement
|
||||
|
||||
The `with` statement [should not be used](http://yuiblog.com/blog/2006/06/01/global-domination/).
|
||||
|
||||
## `{}` and `[]`
|
||||
|
||||
Use `{}` instead of `new Object()`. Use `[]` instead of `new Array()`.
|
||||
|
||||
Use arrays when the member names would be sequential integers. Use objects when the member names are arbitrary strings or names.
|
||||
|
||||
### `,` comma Operator
|
||||
|
||||
Avoid the use of the comma operator. (This does not apply to the comma separator, which is used in object literals, array literals, and parameter lists.) Having a character that is sometimes a separator and sometimes an operator is a source of confusion.
|
||||
|
||||
### Assignment Expressions
|
||||
|
||||
Avoid doing assignments in the condition part of `if`and `while` statements.
|
||||
|
||||
Is
|
||||
|
||||
if (a = b) {
|
||||
|
||||
a correct statement? Or was
|
||||
|
||||
if (a == b) {
|
||||
|
||||
intended? Avoid constructs that cannot easily be determined to be correct.
|
||||
|
||||
### `===` and `!==` Operators.
|
||||
|
||||
Use the `===` and `!==` operators. The `==` and `!=` operators produce false positives and false negatives, so they should not be used.
|
||||
|
||||
### Confusing Pluses and Minuses
|
||||
|
||||
Be careful to not follow a `+` with `+` or `++`. This pattern can be confusing. Insert parens between them to make your intention clear.
|
||||
|
||||
total = subtotal + +myInput.value;
|
||||
|
||||
is better written as
|
||||
|
||||
total = subtotal + Number(myInput.value);
|
||||
|
||||
so that the `+ +` is not misread as `++`. Avoid `++`.
|
||||
|
||||
### `eval` is Evil
|
||||
|
||||
The `eval` function is the most misused feature of JavaScript. Avoid it.
|
||||
|
||||
`eval` has aliases. Do not use the `Function` constructor. Do not pass strings to `setTimeout` or `setInterval`.
|
|
@ -0,0 +1,11 @@
|
|||
# JSLint
|
||||
|
||||
According to the [instructions](https://www.jslint.com/help.html) doc, JSLint is a code quality tool for JavaScript.
|
||||
|
||||
The Principle of the Good Parts is
|
||||
|
||||
> If a feature is sometimes useful and sometimes dangerous and if there is a better option then always use the better option.
|
||||
|
||||
It can be accessed [here](https://www.jslint.com). Really understanding what is being explained here is key to using JSLint properly when debugging JavaScript.
|
||||
|
||||
And it was written in [BBEdit](obsidian://open?vault=Coding%20Tips&file=Computers%2FMac%20OS%20X%2FBBEdit).
|
|
@ -0,0 +1,5 @@
|
|||
# Welcome
|
||||
|
||||
Everyone will have to use JavaScript in some capacity when being on the web. Might as well pick up some hints as you go. Here are a few resources.
|
||||
|
||||
- [8 ways to learn javascript](https://www.fosslife.org/8-ways-learn-javascript-online)
|
|
@ -0,0 +1,3 @@
|
|||
# Extensions
|
||||
|
||||
You haven't properly pimped out your browser if you haven't installed some extensions. That's what make browsers so fun anyhow, all the customizeability!
|
|
@ -0,0 +1,18 @@
|
|||
# Gitlab
|
||||
|
||||
Gitlab is a lot more open source than Github seems to be which is bought out by
|
||||
Microsoft and so runs very much most of the world in that sense, right? It is one
|
||||
of the largest codebase platforms that people use for simple version control
|
||||
for their programs but similar in the way that google docs is hosted by Google, the
|
||||
very code that we use is technically all under Microsoft.
|
||||
|
||||
Also since you haven't signed anything yet for Windtelligent.ai this can still
|
||||
technically apply to you: https://about.gitlab.com/solutions/startups/
|
||||
|
||||
Similar to github gists, gitlab uses snippets. https://gitlab.com/-/snippets/new
|
||||
|
||||
GitDock is a GUI for your git projects: https://www.youtube.com/watch?v=WkVS38wo4_w
|
||||
|
||||
This is my gitlab profile: https://gitlab.com/shwetha729
|
||||
|
||||
..made with BBEdit
|
|
@ -0,0 +1,14 @@
|
|||
# Prototyping tools
|
||||
|
||||
|
||||
There are many tools to use when it comes to organization and design of a prototype. Yes of course it is easier to build this with a team but also it can entirely be done by yourself too if you have the creative passion to see it to completion.
|
||||
|
||||
Take all the time you need remember. This is your creation.
|
||||
|
||||
|
||||
Tools for motion prototyping:
|
||||
https://www.framer.com/motion/
|
||||
|
||||
Tools for mobile app prototyping:
|
||||
https://cloud.justinmind.com/usernote/toLogin.action
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
# Webscraping
|
||||
|
||||
|
||||
Webscraping is a common task in the CS world that makes it easy and efficient to extract large amounts of data. It is part of a larger topic of data mining which allows for the human understandable analysis of all the data that is out there.
|
||||
|
||||
You will often use requests and beautifulsoup libraries.
|
||||
|
||||
---
|
||||
|
||||
#### Comparing web scraping libraries:
|
||||
![[Pasted image 20220730121832.png]]
|
||||
|
||||
## Sample scraper
|
||||
```python
|
||||
import pandas as pd
|
||||
from bs4 import BeautifulSoup
|
||||
from selenium import webdriver
|
||||
driver = webdriver.Chrome(executable_path='/nix/path/to/webdriver/executable') driver.get('https://your.url/here?yes=brilliant')
|
||||
results = []
|
||||
other_results = []
|
||||
content = driver.page_source
|
||||
soup = BeautifulSoup(content)
|
||||
for a in soup.findAll(attrs={'class': 'class'}):
|
||||
name = a.find('a')
|
||||
if name not in results:
|
||||
results.append(name.text)
|
||||
for b in soup.findAll(attrs={'class': 'otherclass'}):
|
||||
name2 = b.find('span')
|
||||
other_results.append(name.text)
|
||||
series1 = pd.Series(results, name = 'Names')
|
||||
series2 = pd.Series(other_results, name = 'Categories')
|
||||
df = pd.DataFrame({'Names': series1, 'Categories': series2})
|
||||
df.to_csv('names.csv', index=False, encoding='utf-8')
|
||||
```
|
||||
|
||||
You can also use asyncio or multithreading to make web scraping even [faster](https://oxylabs.io/blog/how-to-make-web-scraping-faster).
|
||||
Right click > Inspect > Network
|
||||
|
||||
##### More helpful tutorials
|
||||
- [How To Scraper Yelp Review For Free [No Coding Required] | ProWebScraper](https://medium.com/prowebscraper/how-to-scraper-yelp-reviews-899b7480eb8d)
|
||||
|
||||
- [How to Build a Web Scraper With Python [Step-by-Step Guide] | HackerNoon](https://hackernoon.com/how-to-build-a-web-scraper-with-python-step-by-step-guide-jxkp3yum)
|
||||
|
||||
- [Python Web Scraping Tutorial: Step-By-Step [2022 Guide] | Oxylabs](https://oxylabs.io/blog/python-web-scraping)
|
||||
- [ Intro to Yelp Scraping using Python ](https://towardsdatascience.com/intro-to-yelp-web-scraping-using-python-78252318d832)
|
||||
|
||||
|
||||
## Alternative tools:
|
||||
- [Octoparse](https://developer.chrome.com/docs/devtools/workspaces/?utm_source=devtools) is a good one which is free for 14 days.
|
|
@ -0,0 +1,5 @@
|
|||
# Workspaces
|
||||
|
||||
Found first within Right Click > Inspect on Brave browser. Checked out the learn more link and here we are.
|
||||
|
||||
Go through the full demo walkthrough to learn more [here](https://developer.chrome.com/docs/devtools/workspaces/?utm_source=devtools).
|
|
@ -0,0 +1,4 @@
|
|||
# Aka the URI
|
||||
|
||||
|
||||
not to be confused with the URL ;)
|
|
@ -0,0 +1,5 @@
|
|||
# Xpath
|
||||
|
||||
XPath stands for XML Path Language. It is a language that allows you to navigate to a specific element in an XML document.
|
||||
|
||||
XPaths will often be used in [BBEdit](obsidian://open?vault=Coding%20Tips&file=Computers%2FMac%20OS%20X%2FBBEdit).
|
|
@ -0,0 +1,25 @@
|
|||
# BBEdit
|
||||
|
||||
*BBEdit : the Swiss Army **Chainsaw** of Programmers' Editor*
|
||||
|
||||
|
||||
|
||||
It simple but powerful text editor with lots of [new](http://www.barebones.com/products/bbedit/bbedit14.html) [features](http://www.barebones.com/products/bbedit/features.html) with its [BBEdit 1](http://www.barebones.com/support/bbedit/notes-14.0.html)4 release.
|
||||
|
||||
|
||||
### Language Modules:
|
||||
Notice, that it doesn't have python, html, java/javascript or more popular languages among the list..
|
||||
- interestingly, there is a feature where if you are designing your own language, you may be able to create am "Edit in BBEdit" command.
|
||||
- in fact, it even seems to be [encouraged](http://www.barebones.com/support/develop/).
|
||||
|
||||
|
||||
- the [codeless language module reference](http://www.barebones.com/support/develop/clm.html#TypesOfCodelessLanguageModules) is made to make things extremely easy for you
|
||||
- there is even a section where you can pull up docs for a language within a keyword.
|
||||
- ![[Pasted image 20220908174202.png]]
|
||||
- In this context, “symbols” are any runs of text defined by the “[Identifier and Keyword](http://www.barebones.com/support/develop/clm.html#IdentifyingKeywordStrings)” character sets. Spelling-dictionary words will be offered only if the user has enabled the feature in the “Editing” preferences panel.
|
||||
|
||||
|
||||
|
||||
For any questions or issues you encounter, start a post on the [BBEdit google group](https://groups.google.com/g/bbedit). Or if something crashes, contact [tech support](https://www.barebones.com/contact/technical.html).
|
||||
|
||||
P.S. [Yojimbo](http://www.barebones.com/products/yojimbo/tour-end.html) is a fantastic partner to work alongside BBEdit for quickly storing your files for viewing. The benefit of this is that you can use BBEdit to simply write, and you can use Yojimbo to view, store, collect, and take out pretty much anything your mind can think of. This is so fantastic because it is intuitively how we organize information even in the real world as well, part of the "stutter" that happens with human/computer interaction is when things are not intuitive. By providing this metaphorical interface, Yojimbo is infinitely ahead of the cloud game which, although may be fast and can store more data "online", is terrible for the environment and doesn't lead to actual real-world outputs.
|
|
@ -0,0 +1,11 @@
|
|||
# CLM
|
||||
|
||||
|
||||
CLM stands for Codeless Language Module done via BBEdit most commonly. It is the easiest way to define things in actionable ways within your machine. And the possibiltiies are truly endless.
|
||||
Here is the [example](obsidian://open?vault=Coding%20Tips&file=Computers%2FMac%20OS%20X%2FBBEdit%2FExample%20CLM) for a simple CLM.
|
||||
|
||||
CLMs take the form of property list files (plists)
|
||||
There are tons of information about CLMs on this [page](http://www.barebones.com/support/develop/clm.html). Read very carefully ;)
|
||||
|
||||
|
||||
And, indeed, this is different than [Language Server Protocols](http://www.barebones.com/support/bbedit/lsp-notes.html), or LSPs, for short.
|
|
@ -0,0 +1,65 @@
|
|||
# Example
|
||||
|
||||
This is an example as given in the CLM doc of a "My Language" file, a severe subset of the Ruby scripting language.
|
||||
|
||||
```
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
|
||||
<!-- The smallest CLM that will color keywords.
|
||||
Copyright (c) 2012 Bare Bones Software, Inc. -->
|
||||
|
||||
<dict>
|
||||
<!-- You must identify the plist as a CLM: -->
|
||||
<key>BBEditDocumentType</key>
|
||||
<string>CodelessLanguageModule</string>
|
||||
|
||||
<!-- You must identify your language: -->
|
||||
<key>BBLMLanguageDisplayName</key> <string>My Language</string>
|
||||
<key>BBLMLanguageCode</key> <string>MyL!</string>
|
||||
|
||||
<!-- Not required, but there’s not much point to
|
||||
a language module if it doesn’t color syntax: -->
|
||||
<key>BBLMColorsSyntax</key> <true/>
|
||||
|
||||
<!-- Specify some keywords. This isn’t required, either,
|
||||
but it provides something to color: -->
|
||||
<key>BBLMKeywordList</key>
|
||||
<array>
|
||||
<string>class</string>
|
||||
<string>def</string>
|
||||
<string>if</string>
|
||||
<string>elsif</string>
|
||||
<string>else</string>
|
||||
<string>end</string>
|
||||
<string>do</string>
|
||||
<string>for</string>
|
||||
<string>return</string>
|
||||
</array>
|
||||
|
||||
<!-- Specify a comment-out string: -->
|
||||
<key>BBLMCommentLineDefault</key> <string>#</string>
|
||||
|
||||
<!-- You must specify the character set for
|
||||
keywords and identifiers. Substitute your own: -->
|
||||
<key>Language Features</key>
|
||||
<dict>
|
||||
<key>Identifier and Keyword Character Class</key>
|
||||
<string>A-Za-z0-9_\?!</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
```
|
||||
|
||||
**Things to notice here:**
|
||||
|
||||
- If you don’t want the module to do anything other than take up space in the language pop-up, just specify `BBEditDocumentType`, `BBLMLanguageDisplayName`, and `BBLMLanguageCode`. But this is the minimal _useful_ language module.
|
||||
- For syntax coloring, you must turn on `BBLMColorsSyntax`.
|
||||
- For something to color, you must provide a list of keywords in `BBLMKeywordList`.
|
||||
- BBEdit requires that you provide a method — line or block — for commenting-out lines with the Un/Comment Selection command. In this case, `BBLMCommentLineDefault` specifies the # line-comment token.
|
||||
- You must also specify how to identify keywords, in the `Language Features `dictionary, using either `Identifier` and `Keyword Characters `or `Identifier` and `Keyword Character` `Class`.
|
||||
- You _don’t_ have to provide a `BBLMSuffixMap` or `BBLMFileNamesToMatch` list. Without them, your user will have to pick the language out of the pop-up.
|
||||
|
||||
For more info, go [here](http://www.barebones.com/support/develop/clm.html#Examples).
|
|
@ -0,0 +1,9 @@
|
|||
# List of Language Modules
|
||||
|
||||
Here is a more complete list of language modules made via BBEdit that are more useful for me rather than what they list on the official site.
|
||||
|
||||
|
||||
|
||||
- **Nim** - plist link: https://gist.github.com/ytomino/4c9d186d78a27ad202ac
|
||||
- orgASM - (IDE for any microprocessor) - http://www.hinton-instruments.co.uk/archive/macide.html
|
||||
-
|
|
@ -0,0 +1,5 @@
|
|||
# XML
|
||||
|
||||
Extensible Markup Language (**XML**) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.
|
||||
|
||||
Utilized often in [BBEdit](obsidian://open?vault=Coding%20Tips&file=Computers%2FMac%20OS%20X%2FBBEdit) for CLMs.
|
|
@ -0,0 +1,4 @@
|
|||
# plist
|
||||
|
||||
|
||||
plists are simple XML document types used throughout Mac OS X. This format defines a set of primitive types, and is used within CLM for definition.
|
|
@ -0,0 +1,6 @@
|
|||
# Mac OSX & Apple
|
||||
|
||||
|
||||
- [Monitor](https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/MonitoringEnergyUsage.html) the activity of your laptop through XCode
|
||||
- [BBEdit](obsidian://open?vault=Coding%20Tips&file=Computers%2FMac%20OS%20X%2FBBEdit) is a fantastic text editor and not even just that is entirely worth the learn.
|
||||
- Mac tips:
|
|
@ -0,0 +1,26 @@
|
|||
# VOQC
|
||||
|
||||
VOQC, also pronounced as *vox*, is short for verfied optimizer for quantum circuits. Since many current quantum frameworks use qasm files, voqc was created as a way to debug circuits from compile error upon construction, as is my understanding anyways. The official paper though can be found [here](https://arxiv.org/pdf/1912.02250.pdf). And it is pretty informative! In order to install fully though, you will also need to install [opam](obsidian://open?vault=Coding%20Tips&file=Opam).
|
||||
|
||||
---
|
||||
|
||||
**Example: Quantum teleportation:**
|
||||
|
||||
The idea behing quantum teleportation is transmit a state psi from one party (Alice) to another (Bob) using a shared entangled state. A circuit for this is shown in a corresponding SQIR program.
|
||||
|
||||
```
|
||||
Definition bell: ucom base 3 := H 1; CNOT 1 2
|
||||
Definition alice: com base 3 := CNOT 0 1 ; H 0; measure 0; measure 1.
|
||||
Definition bob : com base 3 := CNOT 1 2; Cz 0 1; reset 0; reset 1.
|
||||
Definition teleport : com base 3 := bell; alice, bob
|
||||
```
|
||||
|
||||
SQIR : a quantum language pronounced *squire* which stands for small quantum intermediate representation. They maintain a [github](https://github.com/inQWIRE/SQIR) with several examples of implementation. Upon implementation, there seems to be an extraction process as well which is further documented [here](https://github.com/inQWIRE/mlvoqc). It takes a highly mathematical approach and is compatibly based on COQ.
|
||||
|
||||
More information of Verified Quantum Computing can also be found [here](http://www.cs.umd.edu/~rrand/vqc/index.html).
|
||||
|
||||
---
|
||||
|
||||
## An example of optimization!
|
||||
|
||||
- Reading this [tutorial](https://nbviewer.org/github/inQWIRE/pyvoqc/blob/main/tutorial.ipynb) is extremely helpful in understanding what the point of voqc is. It makes constructing circuits a lot easier than having to understand all the gate logic and needing to create them all by hand.
|
|
@ -0,0 +1,8 @@
|
|||
# Intro/Summary of Quantum Mechanics
|
||||
The formalisms of somewhat knowing what each part of this is called will be somewhat important for you to seem knowledgeable in what you're talking about but might not be as necessary in application. Regardless, it'll give you major street cred around the quantum realm.
|
||||
|
||||
- Quantum formalism will help understand what kind of math it's based on
|
||||
- primarily linear algebra & matrices
|
||||
- Funny enough, another Obsidian user has made a **much** more extensive guide called [The Quantum Well ](https://publish.obsidian.md/myquantumwell/Welcome+to+The+Quantum+Well!)which presents most of the math and physics you will ever need to know.
|
||||
- since my Obsidian focuses primarily on the programming and tech, the above foundational knowledge will be useful for those that are curious.
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Formalism
|
||||
|
||||
|
||||
|
||||
**Abstract: **
|
||||
|
||||
|
||||
Please humor me if this is a stretch but I thought this something worth exploring from a more mathematical perspective and proof: As radio waves are currently the longest emitting electromagnetic frequencies, would they play a role in accounting for noise specifically in wind by formulating a way in which radio waves detecting noise via wind can communicate this rather naturally in a math formulation to quantum computing. There seems to be a lot of similarity between these two industries and rather than approaching it from a photonic or superconducting/circuit perspective, I wanted to take a moment to understand if this can be better formalized in an equation demonstrating the relationship between the earth’s wind, radio waves tested via ham amateur radio, and factoring these into error mitigation in quantum computing. Although many things may account for the noise that leaves quantum computers largely still unusable today, such as natural earth perturbations, I am still interested in primarily exploring atmospheric wind in a mathematical approach.
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Quantum Computers
|
||||
|
||||
Quantum computers are here and very much real. And there's lot's to choose from. Similar to how regular computers started out in the 70s, the most common ones today are the IBM Quantum Computers, more appropriate to call them servers though as they are often accessed via the cloud nowadays.
|
||||
|
||||
Hardware
|
||||
|
||||
|
||||
|
||||
Cloud Hybrid
|
||||
|
||||
|
||||
|
||||
Annealers
|
||||
- the one and only and first quantum computer, D-Wave, is the choice here
|
|
@ -0,0 +1,3 @@
|
|||
# Quantum Internet
|
||||
|
||||
A cryptographic application to send information through.
|
|
@ -0,0 +1,45 @@
|
|||
# Quantum Tech
|
||||
|
||||
|
||||
Quantum technologies have the potential to dramatically change certain areas and industries as know it as we apply it and as the sector develops. There are 4 main kinds of quantum technologies that will come up:
|
||||
|
||||
## 1. Quantum computers
|
||||
|
||||
- These devices are here and san speed up certain calculations dramatically
|
||||
- Not just both 0 and 1 but rather in between 0 and 1
|
||||
- Can process much more information with qubits than bits
|
||||
- This speedup only works with certain calculations
|
||||
- To be useful - need to bring a large number of qubits (~1 mill qubits)
|
||||
- Question is not will it work, it is rather **will it scale**
|
||||
- quantum computers already exist today
|
||||
- yet status is similar to how nuclear fusion worked 50 years ago, effective and still in process
|
||||
|
||||
## 2. Quantum internet
|
||||
|
||||
- Information transmitted with quantum effects
|
||||
- Uses quantum cryptography as a security protocol
|
||||
- It irreversibly changes the state of an information particle
|
||||
- Cannot transfer info faster than speed of light or with any other quantum effect
|
||||
- quantum computer can break current protocols
|
||||
- Quantum internet can be safe from hacking by quantum computers
|
||||
- Caveat - Post quantum or quantum-safe cryptography
|
||||
- People that work on quantum things dont like to mention this though
|
||||
|
||||
## 3. Quantum metrology
|
||||
|
||||
- Collection of measurements to improve quantum effects
|
||||
- Medicine and material science
|
||||
- Can make do with very few particles with minimal damage to sample
|
||||
- Most promising quantum technology
|
||||
|
||||
## 4. Quantum simulations
|
||||
|
||||
- Very useful in trying to understand complicated system
|
||||
- By reproducing system that you can control better to better predict system
|
||||
- Dramatic shift in modern physics as you can take out mathematics
|
||||
- Instead of simulating with mathematics you model it directly with another system
|
||||
- Simulate particles similar to the higgs which you cannot do in any other way
|
||||
- though headlines like the simulated wormhole is nonsense
|
||||
|
||||
|
||||
via [source](https://www.youtube.com/watch?v=b-aGIvUomTA)
|
|
@ -0,0 +1,56 @@
|
|||
# Machine Learning (QML)
|
||||
|
||||
Quantum machine learning is one of the biggest pillars of quantum computing application that we will see in the workforce of the future
|
||||
One of the big contenders in this field is Xanadu.ai's [pennylane](https://pennylane.ai/) software. Recently version 0.25 was just released and a lot more applications can be created.
|
||||
|
||||
|
||||
|
||||
The following questions can finally be answered with [this](https://pennylane.ai/blog/2022/08/pennylane-v025-released/#new-return-types-for-qnodes-with-multiple-measurements) release:
|
||||
|
||||
|
||||
|
||||
#### How many qubits/gates do I need to run this algorithm?
|
||||
|
||||
module for estimating through process of first and second quantization:
|
||||
|
||||
```
|
||||
# first quantization
|
||||
|
||||
>>> n = 100000 # number of plane waves
|
||||
>>> eta = 156 # number of electrons
|
||||
>>> omega = 1145.166 # unit cell volume in atomic units
|
||||
>>> algo = FirstQuantization(n, eta, omega)
|
||||
>>> algo.gates
|
||||
1.10e+13
|
||||
>>> algo.qubits
|
||||
4416
|
||||
```
|
||||
```
|
||||
# second quantization with double factored Hamiltonian
|
||||
# Hamiltonia
|
||||
|
||||
symbols = ['O', 'H', 'H']
|
||||
geometry = np.array([[0.00000000, 0.00000000, 0.28377432],
|
||||
[0.00000000, 1.45278171, -1.00662237],
|
||||
[0.00000000, -1.45278171, -1.00662237]], requires_grad = False)
|
||||
|
||||
mol = qml.qchem.Molecule(symbols, geometry, basis_name='sto-3g')
|
||||
core, one, two = qml.qchem.electron_integrals(mol)()
|
||||
|
||||
algo = DoubleFactorization(one, two)
|
||||
```
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
and voila!
|
||||
|
||||
```
|
||||
|
||||
>>> print(algo.gates, algo.qubits)
|
||||
103969925, 290
|
||||
```
|
||||
|
||||
|
||||
|
||||
and even more capabilities are available the more you explore! :)
|
|
@ -0,0 +1,3 @@
|
|||
# Quantum Metrology
|
||||
|
||||
In which special tools are being created to observe quantum effects
|
|
@ -0,0 +1,3 @@
|
|||
# Quantum Optimizations
|
||||
|
||||
Using QAOA
|
|
@ -0,0 +1,47 @@
|
|||
# Qiskit -Nature
|
||||
|
||||
|
||||
The main cloud application that uses superconducting qubits is qisket. Qisket Nature depends on the main package.
|
||||
|
||||
- [Thermodynamic observable calculations ](https://qiskit.org/documentation/nature/tutorials/06_calculating_thermodynamic_observables.html)with IBM quantum
|
||||
|
||||
### Installation
|
||||
|
||||
```
|
||||
pip install qiskit[nature]
|
||||
```
|
||||
|
||||
Further instructions can be read [here](https://qiskit.org/documentation/nature/getting_started.html). Installed via xonsh.
|
||||
|
||||
---
|
||||
For hydrogen storage notebook --> use the ground state solver docs:
|
||||
|
||||
### 1. Define a molecular system:
|
||||
|
||||
Ask for the electronic part of a hydrogen molecule:
|
||||
```
|
||||
from qiskit import Aer
|
||||
from qiskit_nature.drivers import UnitsType, Molecule
|
||||
from qiskit_nature.drivers.second_quantization import (
|
||||
ElectronicStructureDriverType,
|
||||
ElectronicStructureMoleculeDriver,
|
||||
)
|
||||
from qiskit_nature.problems.second_quantization import ElectronicStructureProblem
|
||||
from qiskit_nature.converters.second_quantization import QubitConverter
|
||||
from qiskit_nature.mappers.second_quantization import JordanWignerMapper
|
||||
|
||||
molecule = Molecule(
|
||||
geometry=[["H", [0.0, 0.0, 0.0]], ["H", [0.0, 0.0, 0.735]]], charge=0, multiplicity=1
|
||||
)
|
||||
driver = ElectronicStructureMoleculeDriver(
|
||||
molecule, basis="sto3g", driver_type=ElectronicStructureDriverType.PYSCF
|
||||
)
|
||||
|
||||
es_problem = ElectronicStructureProblem(driver)
|
||||
qubit_converter = QubitConverter(JordanWignerMapper())
|
||||
```
|
||||
|
||||
### 2. Define solver:
|
||||
A solver aka the algorithm that the ground state is computed with. In chemistry the gound state is found with **variational quantum eignesolver (VQE)**
|
||||
|
||||
### 3.
|
|
@ -0,0 +1,10 @@
|
|||
# Qiskit
|
||||
|
||||
Qiskit is the fundamental thingy(best way to describe it at this point) that a lot of quantum computers will refer to nowadays (at least for the moment) from IBM. We first have to create a conda environment (or a xonsh one!) in which we install qiskiet and all necessary distributions. Here are the docs to get [started](https://qiskit.org/documentation/getting_started.html).
|
||||
|
||||
---
|
||||
|
||||
There seems to be qiskit distributions for:
|
||||
- qiskit-visualization
|
||||
- [qiskit-nature](obsidian://open?vault=Coding%20Tips&file=Qiskit-Nature)
|
||||
- qiskiet-metal
|
|
@ -0,0 +1,68 @@
|
|||
# LaTeX
|
||||
|
||||
LaTex is an extremely high quality document creator and type-setting software. You can produce sophisticated ``articles``, ``reports``, ``books``, ``letters``, and ``slides`` this way for presentation of information to the scientific community.
|
||||
|
||||
Make sure to read the README.md file upon installation also found [here](https://www.tug.org/mactex/READ_ME_FIRST.pdf).
|
||||
|
||||
You can learn more at[ learnlatex.org. ](https://www.learnlatex.org/en/lesson-05)
|
||||
|
||||
---
|
||||
|
||||
|
||||
For a ``letter`` for instance, a document class will look like this:
|
||||
|
||||
```
|
||||
\documentclass{letter}
|
||||
\usepackage[T1]{fontenc}
|
||||
\begin{document}
|
||||
|
||||
\begin{letter}{Some Address\\Some Street\\Some City}
|
||||
|
||||
\opening{Dear Sir or Madam,}
|
||||
|
||||
This is an example of a highly sophisticated & educated correspondence.
|
||||
|
||||
\closing{Yours,}
|
||||
|
||||
\end{letter}
|
||||
|
||||
\end{document}
|
||||
```
|
||||
|
||||
|
||||
In another example, we may see an ``article`` document may be written:
|
||||
|
||||
```
|
||||
\documentclass{article} % Change the class here
|
||||
\usepackage[T1]{fontenc}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\section{Introduction}
|
||||
|
||||
This is a sample document with some dummy
|
||||
text\footnote{and a footnote}. This paragraph is quite
|
||||
long as we might want to see the effect of making the
|
||||
document have two columns.
|
||||
|
||||
\end{document}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### LaTeX Presentations
|
||||
|
||||
- some examples and templates can be found [here](atextemplates.com/template/beamer-presentation)
|
||||
- They are very clean and academic-looking
|
||||
- How to create your own LaTeX Presentation!
|
||||
- follow [this](https://texblog.org/2008/01/21/create-your-slides-presentations-with-latex/) tutorial to get started :)
|
||||
|
||||
We start by defining the document-class
|
||||
|
||||
```
|
||||
\documentclass[landscape]{slides}
|
||||
```
|
||||
|
||||
But you may be better off editing a document simply through [Overleaf](https://www.overleaf.com/project/6306feb35a99fd317a79ec3a) as well.
|
||||
|
||||
![[Pasted image 20220825004820.png]]
|
|
@ -0,0 +1,5 @@
|
|||
# Quantum Simulations
|
||||
|
||||
Whole systems are simulated without need for data or equations of mathematics by altering the options/probabilities of systems themselves. Helps us better understand complex systems.
|
||||
|
||||
The[ qiskit-nature](obsidian://open?vault=Coding%20Tips&file=Computers%2FQuantum%20Realm%2FTechnologies%2FComputer%20choices%2FIBM%2FQiskit-Nature) package would be a good one to use here.
|
|
@ -0,0 +1,33 @@
|
|||
# Arline Benchmarks
|
||||
|
||||
The Arline Benchmarks are an independent third-party analysis tool to compare all the quantum processors that exist today with no affiliation to any of them. This then removes any bias and only looks at processors in terms of efficiency and speed-up. It has been used for compiler performance testing and more. Furthermore, it autogenerates benchmarking reports in LaTeX so you can get to experience that as well. You may also run it online [here](https://www.arline.io/arline-benchmarks) by uploading the qasm files and comparing. It currently works with Qiskit, Tket, PyZX, & VOQC.
|
||||
|
||||
### Folder Structure
|
||||
The folder structure for Arline Benchmarks once installed looks like this:
|
||||
|
||||
```
|
||||
arline_benchmarks
|
||||
│
|
||||
├── arline_benchmarks # platform classes
|
||||
│ ├── config_parser # parser of pipeline configuration
|
||||
│ ├── engine # pipeline engine
|
||||
│ ├── metrics # metrics for pipeline comparison
|
||||
| ├── pipeline # pipeline
|
||||
│ ├── reports # LaTeX report generator
|
||||
│ ├── strategies # list of strategies for mapping/compression/rebase
|
||||
│ └── targets # target generator
|
||||
│
|
||||
├── circuits # qasm circuits dataset
|
||||
│
|
||||
├── configs # configuration files
|
||||
│ └── compression # config .jsonnet file and .sh scripts
|
||||
│
|
||||
├── docs # documentation
|
||||
│
|
||||
├── scripts # run files
|
||||
│
|
||||
└── test # tests
|
||||
├── qasm_files # .qasm files for test
|
||||
└── targets # test for targets module
|
||||
```
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Agnostiq
|
||||
|
||||
Agnostiq is a platform that helps streamline the tools needed to build quantum solutions for the future.
|
||||
|
||||
There is an open source version called covalent as well which is worth trying as well.
|
||||
|
||||
![[Pasted image 20220827183015.png]]
|
||||
|
||||
Covalent allows for an easy workflow environment as well and can be used to further coordinate your quantum work as you delve further.
|
|
@ -0,0 +1,18 @@
|
|||
# Womanium 2022
|
||||
|
||||
Here I will go through all research, steps, processes, tests, and methods used for the Womanium Hackathon.
|
||||
|
||||
The main github repo: https://github.com/spendierk/Womanium_Hackathon_TKET_2022
|
||||
|
||||
*Primary Goals include:*
|
||||
- [Building](https://github.com/spendierk/Womanium_Hackathon_TKET_2022/blob/main/Building%20circuits%20with%20pytket.ipynb) circuits with ``pytket``
|
||||
- comparing againsts others with [Arline Benchmarks](obsidian://open?vault=Coding%20Tips&file=Arline%20Benchmarks)
|
||||
- Solving for the hydrogen storage problem with LiCl molecule as found [here](https://qiskit.org/documentation/nature/tutorials/03_ground_state_solvers.html).
|
||||
|
||||
---
|
||||
|
||||
|
||||
## A-Z: Arline Benchmarks:
|
||||
1. Firstly, it was discussed that the [arline benchmark](https://github.com/ArlineQ/arline_benchmarks)s will be a good place to begin to compare quantum processing speeds! Begin by following that and installing that on your machine.
|
||||
|
||||
- the verified optimizer for quantum circuits or [VOQC](https://github.com/inQWIRE/pyvoqc) is another analysis tool we will need. Install that as well.
|
|
@ -0,0 +1,21 @@
|
|||
# Welcome!
|
||||
|
||||
You've become curious as any adventurer would and have decided to embark on a grand journey: the journey to understand quantum - in all of its computation, application, and more. It's a journey I'm undergoing myself as I begin to write this and instead of creating an archive of quantum papers, code, games, platforms, tools, research, or more I thought it'd be more impactful to create an obsidian knowledge base as I continue to grow into the quantum journey along with you all.
|
||||
|
||||
This will be helpful to me as both review and discovery as well as hopefully to you and others who have decided in various moments in life to begin the path to conquer what lies at the end of the quantum quest.
|
||||
|
||||
|
||||
|
||||
[Next up](obsidian://open?vault=Coding%20Tips&file=Computers%2FQuantum%20Realm%2FIntro%20to%20Quantum%20Technologies): Look over at THE intro to quantum tech to get up to speed. [--> ](obsidian://open?vault=Coding%20Tips&file=Computers%2FQuantum%20Realm%2FTechnologies%2FIntro%20to%20Quantum%20Technologies)
|
||||
|
||||
Welcome & Good Luck! ^-^
|
||||
|
||||
---
|
||||
|
||||
##### When finished: the 3 current main applications
|
||||
As said by Konstantinos there are generally **three large pillars** of application to use QC for:
|
||||
|
||||
1. [Optimizations](obsidian://open?vault=Coding%20Tips&file=Quantum%20Optimizations)
|
||||
2.[ Machine Learning ](obsidian://open?vault=Coding%20Tips&file=Quantum%20Machine%20Learning)
|
||||
3. [Simulations](obsidian://open?vault=Coding%20Tips&file=Quantum%20Simulations)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# Your terminal is everything!
|
||||
|
||||
Your terminal is the main way that you interact with the machine. So you have to make sure that it is optimized to be as lightweight as possible.
|
||||
|
||||
If you ever want to take a screen recording of the terminal just type in:
|
||||
```
|
||||
asciinema rec
|
||||
```
|
||||
|
||||
Copy and paste with [xclip](https://github.com/astrand/xclip)! You can even [share](https://www.fosslife.org/2-tools-linux-terminal-sharing?cmid=4a5288c5-330b-4694-a774-0e44f9a5fa28) your terminal screen with multiple users using screen & tmux.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Eventually the goal is to port the info I've gather on [this](https://docs.google.com/document/d/1HSj4i64hM6291LXvIoWxMJfYn35geWJaAWY9oXkOmm0/edit#) document over to here..eventually.
|
||||
|
||||
|
||||
- The whole bash versus zsh debate is nicely compared to on [this](https://stackabuse.com/zsh-vs-bash/) site. Both are great, use whichever you prefer.
|
||||
|
||||
- There is a near infinite amount of things to play around and improve on in your terminal - thus [Terminal To-do's](obsidian://open?vault=Coding%20Tips&file=Terminal%20To-do's) are born.
|
|
@ -0,0 +1,3 @@
|
|||
# Bash
|
||||
|
||||
Bash is a classic and should always be understood. After all, it was the first shell that you used so there's a bit of nostalgia surrounding it.
|
|
@ -0,0 +1,7 @@
|
|||
# Zsh
|
||||
|
||||
Zsh is a bit trendier nowadays and it is the current shell of choice for my system now. So, having tips of navigation here is a bit important.
|
||||
|
||||
---
|
||||
|
||||
- Oh-my-zsh is a very popular customization tool to [pimp](https://stackabuse.com/pimp-my-terminal-an-introduction-to-oh-my-zsh/) out your terminal
|
|
@ -0,0 +1,58 @@
|
|||
# Fink
|
||||
|
||||
Fink is a really useful package that allows you to use those **"sudo apt-get**" commands that you love so well rather than just relying on mac OS's "brew" commands. This is awesome because it opens up a whole new world of Linux packages that aren't previously as easily available with the Apple command-tools.
|
||||
|
||||
And you get to go back to using your more familiar Linux commands that you are more comfortable with anyways! YAY! Time to work
|
||||
|
||||
|
||||
---
|
||||
|
||||
#### quick how-to learned via [the internet](**[https://www.digimantra.com/howto/apple-aptget-command-mac/](https://www.digimantra.com/howto/apple-aptget-command-mac/)**) :')
|
||||
1. Go to the [source](https://www.finkproject.org/download/srcdist.php) release page and download appropriate package. Since I am mac 10.14 I am able to download the [helper script](https://github.com/fink/scripts/releases/tag/setup/0.45.6) package. (A note: this works only on macOS 10.9-10.15 currently) You should download all the three files you see on the page. **![](https://lh6.googleusercontent.com/THW3OubFhoTD6gnwGVSr4dr7ewVvRmvZSbbyDP80YJJjlLMdbKdqZElReaeeuM2E6dptw84Yb8I2HSuQa0zF4l6mF7T1PMvyHuqCu1I0ytR-0OxGw5VN8zcZpZOsnhqY7Oqo3eqFfYaTE8MrLFtMsQE)**
|
||||
|
||||
2. You will make sure that you have xcode installed (or if you're like me and never bothered to download xcode because it takes up WAYY too much storage space, just the command tools should suffice for ] 10.14) You can check for this by ```sudo xcode-select --install```
|
||||
|
||||
3. When you double click on InstallFink (right click on "Open with" > "Terminal" if you're not using the safari browser like me) and it will open up in the terminal
|
||||
|
||||
4. Press any key to continue and press "n" if you are not installing xcode (like previously stated, just the commant tools will suffice for 10.14)
|
||||
|
||||
5. Allow it to finish setting up and installing and voila!
|
||||
|
||||
6. Log off and log in and set up the environment via ```/sw/bin/pathsetup.sh```
|
||||
|
||||
7. You can press enter through a lot of the default configurations (side note - your proxy: http://shway:moon@jedisailor:00711 , FTP: http://shway:moon@jedisailor:00719)
|
||||
|
||||
8. The basic commands to completing full set up is:
|
||||
```
|
||||
>>>cd fink-0.45.6
|
||||
|
||||
>>>./bootstrap (to start bootstrap)
|
||||
|
||||
>>>./bootstrap /path (where path is where your directory will be)
|
||||
|
||||
>>>/sw/bin/pathsetup.sh (the default path if not specified)
|
||||
|
||||
```
|
||||
|
||||
9. Then open a new terminal and in the /sw folder run the following:
|
||||
```
|
||||
>>>fink selfupdate-rsync
|
||||
>>>fink index -f
|
||||
|
||||
OR
|
||||
|
||||
>>>fink selfupdate-git
|
||||
>>>fink index -f
|
||||
```
|
||||
|
||||
10. To use ```fink``` in terminals going forward the setup.sh script will automatically set up in your .profile
|
||||
11. Ta da! You can use fink install or sudo apt-get now! For any further info, refer to the [docs](https://www.finkproject.org/doc/index.php). And also make sure to refer to [this](https://www.finkproject.org/doc/usage/index.php) for info on fink keyword usage :) Enjoy.
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
#### Things installed via Fink
|
||||
- **[Wikit](https://www.tecmint.com/wikipedia-commandline-tool/)** - package that allows you to wikipedia summary anything through terminal
|
||||
- usage: ```wikit <search-term> ```
|
||||
-
|
|
@ -0,0 +1,192 @@
|
|||
# Git
|
||||
|
||||
Git is a way to upload your packages onto a version control system of your choice (as in either Gitlab, Github, or other version control site of your choice)
|
||||
|
||||
Here are some key commands to know:
|
||||
|
||||
|
||||
---
|
||||
|
||||
### CLI instructions:
|
||||
|
||||
#### Git global setup:
|
||||
|
||||
```
|
||||
git config --global user.name "Shwetha Jayaraj"
|
||||
git config --global user.email "shwetha.jayaraj@uconn.edu"
|
||||
```
|
||||
|
||||
#### Create a new repository:
|
||||
```
|
||||
git clone git@gitlab.com:shwetha729/coding-tips.git
|
||||
cd coding-tips
|
||||
git switch -c main
|
||||
touch README.md
|
||||
git add README.md
|
||||
git commit -m "add README"
|
||||
git push -u origin main
|
||||
|
||||
```
|
||||
|
||||
- When you have an empty folder to add to git repo
|
||||
```
|
||||
Git init
|
||||
Git add .
|
||||
Git status
|
||||
Git commit -m ‘your message’ # commit to local repo
|
||||
Git remote add origin ‘urlname’ # add url from repo
|
||||
Git push -u origin master # push local content to github
|
||||
```
|
||||
|
||||
|
||||
#### Push an existing folder:
|
||||
```
|
||||
cd existing_folder
|
||||
git init --initial-branch=main
|
||||
git remote add origin git@gitlab.com:shwetha729/coding-tips.git
|
||||
git add .
|
||||
git commit -m "Initial commit"
|
||||
git push -u origin main
|
||||
```
|
||||
|
||||
Example 2: pushing changes from commit into your branch
|
||||
```
|
||||
git push [nameofyournewremote] [url]
|
||||
```
|
||||
|
||||
Example 3:
|
||||
|
||||
#### Push an existing Git repository:
|
||||
|
||||
Example 1:
|
||||
```
|
||||
cd existing_repo
|
||||
git remote rename origin old-origin
|
||||
git remote add origin git@gitlab.com:shwetha729/coding-tips.git
|
||||
git push -u origin --all
|
||||
git push -u origin --tags
|
||||
|
||||
```
|
||||
|
||||
Example 2:
|
||||
```
|
||||
Git remote add origin https://github.com/username/repo.git
|
||||
Git push -u origin master
|
||||
```
|
||||
|
||||
Example 3: Forking an existing repo
|
||||
```
|
||||
# fork the original repo on top right corners
|
||||
git clone [git url]
|
||||
git remote -v # syncs forked repo
|
||||
git remote add upstream [git clone url]
|
||||
```
|
||||
|
||||
|
||||
Example 4: Push changes from your commit into your branch
|
||||
```
|
||||
git push [nameofyournewremote] [url]
|
||||
```
|
||||
|
||||
|
||||
#### Branch controls
|
||||
|
||||
- Create a new branch on git:
|
||||
```
|
||||
$ git branch <name_of_your_new_branch>
|
||||
```
|
||||
|
||||
- View all branches:
|
||||
```
|
||||
git branch -a
|
||||
```
|
||||
|
||||
- Add a new remote for your branch:
|
||||
```
|
||||
git remote add [name_of_your_remote] [name_of_your_new_branch]
|
||||
```
|
||||
|
||||
- Delete a branch on your local filesystem:
|
||||
```
|
||||
$ git branch -d [name_of_your_new_branch]
|
||||
|
||||
# or to force deletion
|
||||
|
||||
$ git branch -D [name_of_your_new_branch]
|
||||
```
|
||||
|
||||
- Delete a branch on github:
|
||||
```
|
||||
$ git push origin :[name_of_your_new_branch]
|
||||
```
|
||||
|
||||
- Go to desired branch
|
||||
```
|
||||
git checkout [branchname]
|
||||
# OR
|
||||
#git checkout --
|
||||
```
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
#### SSH things:
|
||||
- **CREATE new ssh key:**
|
||||
|
||||
For example, for ED25519:
|
||||
```
|
||||
ssh-keygen -t ed25519 -C "<comment>"
|
||||
```
|
||||
|
||||
For 2048-bit RSA:
|
||||
|
||||
```
|
||||
ssh-keygen -t rsa -b 2048 -C "<comment>"
|
||||
```
|
||||
|
||||
and then
|
||||
```
|
||||
Generating public/private ed25519 key pair. Enter file in which to save the key (/home/user/.ssh/id_ed25519):
|
||||
```
|
||||
press enter twice.
|
||||
|
||||
```
|
||||
Enter passphrase (empty for no passphrase): Enter same passphrase again:
|
||||
```
|
||||
then enter passphrase.
|
||||
|
||||
- **COPY public key to Gitlab account for example (MacOS):**
|
||||
|
||||
```
|
||||
tr -d '\n' < ~/.ssh/id_ed25519.pub | pbcopy
|
||||
```
|
||||
Replace `id_ed25519.pub` with your filename. For example, use `id_rsa.pub` for RSA.
|
||||
|
||||
Then sign in > top right > Preferences > SSH Keys > paste contents into Key box > type description into Title box > Add Key .
|
||||
|
||||
- **VERIFY that you can connect** :
|
||||
|
||||
```
|
||||
ssh -T git@gitlab.com
|
||||
|
||||
>>Welcome to GitLab, @shwetha729!
|
||||
```
|
||||
For more info on SSH, check out [here](https://docs.gitlab.com/ee/user/ssh.html#generate-an-ssh-key-pair).
|
||||
|
||||
|
||||
|
||||
- [Git for Obsidian](https://medium.com/analytics-vidhya/how-i-put-my-mind-under-version-control-24caea37b8a5) article
|
||||
-
|
||||
|
||||
|
||||
|
||||
----
|
||||
|
||||
Other sources:
|
||||
|
||||
- a [git command cheat sheet ](https://dev.to/anitaparmar26/git-command-cheat-sheet-31ec)
|
||||
-
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# Opam
|
||||
|
||||
Opam is an open-sourced package manager for OCaml (a functional programming language and system) and supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow. This is a necessary package install that is needed for many of the quantum programs that will be used.
|
||||
|
||||
The full install instructions can be found [here](https://github.com/ocaml/opam).
|
|
@ -0,0 +1,90 @@
|
|||
# Python Poetry
|
||||
|
||||
A useful python project & package manager that exists within venv & converts to a readable directory.
|
||||
|
||||
---
|
||||
|
||||
|
||||
### Some important commands:
|
||||
|
||||
- Install poetry using the installer:
|
||||
```
|
||||
curl -sSL https://install.python-poetry.org | python3 -
|
||||
```
|
||||
(this is more [recommended](https://python.land/virtual-environments/python-poetry) than simply pip-installing)
|
||||
this is currently installed in the ```/Users/shwethajayaraj/.local/bin``` for me.
|
||||
|
||||
Output:
|
||||
```
|
||||
Installing Poetry (**1.1.14**): Done
|
||||
|
||||
|
||||
|
||||
Poetry (**1.1.14**) is installed now. Great!
|
||||
|
||||
|
||||
|
||||
To get started you need Poetry's bin directory (/Users/shwethajayaraj/.local/bin) in your `PATH`
|
||||
|
||||
environment variable.
|
||||
|
||||
|
||||
|
||||
Add `export PATH="/Users/shwethajayaraj/.local/bin:$PATH"` to your shell configuration file.
|
||||
|
||||
|
||||
|
||||
Alternatively, you can call Poetry explicitly with `**/Users/shwethajayaraj/.local/bin/poetry**`.
|
||||
|
||||
|
||||
|
||||
You can test that everything is set up by executing:
|
||||
|
||||
|
||||
|
||||
`**poetry --version**`
|
||||
```
|
||||
|
||||
- Keeping poetry up to date:
|
||||
```
|
||||
poetry self update
|
||||
```
|
||||
|
||||
|
||||
- Starting a project with Poetry
|
||||
```
|
||||
poetry new demo
|
||||
```
|
||||
|
||||
- Install and remove packages
|
||||
```
|
||||
poetry add requests
|
||||
```
|
||||
```
|
||||
poetry remove <package name>
|
||||
```
|
||||
|
||||
|
||||
- install dependences of existing python project (as listed in the pyproject.toml file)
|
||||
```
|
||||
poetry install
|
||||
```
|
||||
|
||||
- convert existing project to poetry
|
||||
```
|
||||
cd my-project
|
||||
|
||||
poetry init
|
||||
```
|
||||
|
||||
- Starting a shell with the python virtual environment activated
|
||||
```
|
||||
poetry shell
|
||||
```
|
||||
|
||||
|
||||
### More Useful commands:
|
||||
- Exporting requirement to a txt file
|
||||
```
|
||||
poetry export -f requirements.txt > requirements.txt
|
||||
```
|
|
@ -0,0 +1,9 @@
|
|||
# Terminal To-do's
|
||||
|
||||
Because customizing your terminal for your computer is FUN! Here is a list of things that is on my tentative list of things I'd like to play around with:
|
||||
|
||||
---
|
||||
|
||||
~~- Getting [wikit](https://www.tecmint.com/wikipedia-commandline-tool/) set up on the terminal ~~
|
||||
- t~~his led to the installation of [fink](obsidian://open?vault=Coding%20Tips&file=Terminal%20Tips%2FFink) as it's only available via Linux commands~~
|
||||
-
|
|
@ -0,0 +1,20 @@
|
|||
# Anaconda python environment manager
|
||||
|
||||
Anaconda is a great tool used by large machine learning projects and teams to create virtual environments to run their program on. It is often more useful than venv nowadays and a way to run your app without needing to containerize it through Docker or Kubernetes.
|
||||
|
||||
#### Some important commands:
|
||||
|
||||
To see all conda environments available:
|
||||
```
|
||||
conda info --envs
|
||||
```
|
||||
|
||||
|
||||
For more detailed info, refer to the [docs](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html).
|
||||
|
||||
---
|
||||
|
||||
**To return a list of all the virtual environments you've made, search:**
|
||||
```
|
||||
find ~ -d -name "site-packages" 2>/dev/null
|
||||
```
|
|
@ -0,0 +1,47 @@
|
|||
# Xonsh Stuff
|
||||
|
||||
Xonsh is basically a terminal for python which is super cool but even better because you can literally also do bash commands inside it.
|
||||
|
||||
Begin by simply typing ``xonsh`` into the terminal.
|
||||
|
||||
## Setting up an environment
|
||||
There is entirely no need for conda here as it can be done with a simple vox command:
|
||||
1. Load the xontrig by typing:
|
||||
```
|
||||
xontrib load vox
|
||||
```
|
||||
|
||||
2. Create a new environment:
|
||||
```
|
||||
vox new world1
|
||||
```
|
||||
|
||||
3. List any existing or activate the environment:
|
||||
```
|
||||
$ vox list
|
||||
Available environments:
|
||||
eggs
|
||||
world1
|
||||
spam
|
||||
```
|
||||
|
||||
```
|
||||
$ vox activate world1
|
||||
Activated "world1".
|
||||
```
|
||||
|
||||
4. More info found here such as: [Exit or remove the environment ](https://xon.sh/python_virtual_environments.html)
|
||||
|
||||
|
||||
---
|
||||
|
||||
- there is a xonsh [vim file ](https://xon.sh/python_virtual_environments.html) but to be quite honest, you already have kite installed and that seems a lot better.
|
||||
- if every in doubt just type in cheatsheet
|
||||
- Make python extensions with [xontrib](https://asciinema.org/a/499605)
|
||||
|
||||
|
||||
## Things installed with xontrib
|
||||
- xontrib-avox
|
||||
- xontrib loaded the [prompt-bar](https://github.com/anki-code/xontrib-prompt-bar)
|
||||
- xontrib loaded the [cheatsheet](https://github.com/anki-code/xonsh-cheatsheet/blob/main/README.md
|
||||
-
|
|
@ -0,0 +1,26 @@
|
|||
# Xontrib-avox
|
||||
|
||||
This is a way to activate new environments and unactivate environments as you cd around projects. This is a lot more useful than conda as it treats projects as directories (similar to how obsidian works) .
|
||||
|
||||
Example:
|
||||
|
||||
1. setting a project as ```$PROJECT_DIRS = [p'~/code']```
|
||||
2. setting a project directory as ```~/code/spam ```
|
||||
3. ```avox``` then will use the venv name as ```spam```
|
||||
|
||||
|
||||
### Installation
|
||||
|
||||
```
|
||||
pip install xontrib-avox
|
||||
```
|
||||
|
||||
or just clone the original [repo](https://github.com/AstraLuma/xontrib-avox) with pip.
|
||||
|
||||
#### Configuration
|
||||
You must configure ```$PROJECT_DIRS``` by:
|
||||
|
||||
```
|
||||
$PROJECT_DIRS = ["~/code"]
|
||||
```
|
||||
|
Loading…
Reference in New Issue