style: auto format codebase

This commit is contained in:
Jean-Philippe Sirois
2021-10-26 13:55:12 -04:00
parent 30f988a5fe
commit cf4d3b2cc8
34 changed files with 457 additions and 378 deletions
@@ -118,9 +118,9 @@ if(password == "1234")
string password = Console.ReadLine();
if(password == "1234") { Console.WriteLine("Correct password!"); }
if(password == "4321")
{
Console.WriteLine("Correct password!");
if(password == "4321")
{
Console.WriteLine("Correct password!");
}
```
@@ -116,9 +116,9 @@ async function getCharacters() {
// or, mixed
async function getCharacters() {
const data = await fetch(
`https://rickandmortyapi.com/api/character`
).then((res) => res.json());
const data = await fetch(`https://rickandmortyapi.com/api/character`).then(
(res) => res.json()
);
return data.results;
}
+12 -45
View File
@@ -2,20 +2,20 @@
path: /bots
---
This page details the bots you will see in our server.
Below are the bots you can interact with. There are other bots within the server, but they are strictly for usage by staff or are automatic in their nature. [Click here to jump to the passive bots](#passive-bots).
This page details the bots you will see in our server.
Below are the bots you can interact with. There are other bots within the server, but they are strictly for usage by staff or are automatic in their nature. [Click here to jump to the passive bots](#passive-bots).
## JudgeBot
**Description** Judgebot is our main moderation bot. If you receive any warnings or infractions, JudgeBot will be the one to DM you.
Judgebot has a 50-point system. Each infraction gives you points, and points decay over time. Warnings give 5 points. Strikes typically give 10 but can give more in exceptional circumstances.
- 10 points: 1-hour mute
- 20 points: 12-hour mute
- 30 points: 24-hour mute
- 40 points: 30-day mute
- 50 points: permanent ban
- 10 points: 1-hour mute
- 20 points: 12-hour mute
- 30 points: 24-hour mute
- 40 points: 30-day mute
- 50 points: permanent ban
**Source:** https://github.com/the-programmers-hangout/JudgeBot
@@ -27,7 +27,6 @@ Judgebot has a 50-point system. Each infraction gives you points, and points dec
`:stop_sign:` - Reacting to a message with this emote will alert staff to it. Use it if you see any potentially rule breaking content.
## Aura
**Description:** Aura bot will hand out karma to users that earn it. Giving karma is as simple as mentioning (tagging) a user and thanking them in the same message.
@@ -50,7 +49,6 @@ Judgebot has a 50-point system. Each infraction gives you points, and points dec
`karma!reactions` - Details the reactions that Aura can add to messages.
## DocsBot
**Description:** DocsBot can retrieve documentation for discord.js
@@ -87,11 +85,9 @@ Judgebot has a 50-point system. Each infraction gives you points, and points dec
`tph!userinfo` - Displays info for a user.
## Keeper
**Description:** Keeper is a bot that allows you to bookmark messages by adding the `:bookmark:` emote reaction to a message.
**Description:** Keeper is a bot that allows you to bookmark messages by adding the `:bookmark:` emote reaction to a message.
**Source:** https://github.com/ddivad195/keeper
@@ -101,8 +97,6 @@ Judgebot has a 50-point system. Each infraction gives you points, and points dec
N/A
## ModMail
**Description:** This bot lets you privately contact the staff team. DM it to start a discussion!
@@ -111,8 +105,6 @@ N/A
**Usage:** All you need to do is send a message. We'll see any edits you make to your message too!
## Mimic
**Description:** Mimic is a bot that talks like you! If you opt-in it will save your messages and build markov chains in order to generate sentences that mimic how you and other users type!
@@ -145,11 +137,9 @@ N/A
`mimic!stats` - Display statistics of your messages
## Polly
**Description:** Polly is our macro bot.
**Description:** Polly is our macro bot.
**Source:** https://github.com/the-programmers-hangout/Polly
@@ -181,7 +171,7 @@ N/A
`++imageofcode` - Images of code can be really hard to read, let people know they should post the code as text instead.
`++noresearch` - Research is an important part of programming. Encourage people to research *then* ask! Ask them what they found if anything.
`++noresearch` - Research is an important part of programming. Encourage people to research _then_ ask! Ask them what they found if anything.
`++patience` - Remind users not to pester others in channels.
@@ -191,8 +181,6 @@ N/A
`++wrapmini` - Instruct a user to wrap their code.
## ReWizard
**Description:** ReWizard is a utility bot for regex. It can find, replace, split, and test regular expressions.
@@ -215,8 +203,6 @@ N/A
`re!valid` - Tests whether the given regex is valid.
## StandupBot
**Description:** StandupBot is a bot that controls the standup channel. It enforces a strict message format. Once you have successfully sent a message you will no longer be able to post in the standup channel for 20 hours.
@@ -229,7 +215,6 @@ N/A
N/A
## SuggestionBot
**Description:** SuggestionBot manages suggestions for the server. Send in your suggestion and we can put it to a vote!
@@ -242,8 +227,6 @@ N/A
`s!suggest your suggest message here` - Send in your suggestion message
## Passive bots
Below are the bots you will see in the server but you will not need to interact with them. They automatically do their job!
@@ -254,70 +237,54 @@ Below are the bots you will see in the server but you will not need to interact
**Source:** https://github.com/itsHobbes/clerky
## EmbedBot
**Description:** EmbedBot allows staff to manage and post embed messages into various channels.
**Source:** https://github.com/JakeJMattson/EmbedBot
## Emourge
**Description:** Emourge tracks emote usage. We use this to help us identify the least used emotes incase we want to add some new ones!
**Source:** https://github.com/dfireBird/emourge-mongo
## Hawk
**Description:** Hawk manages nickname prefixes & suffixes. It adds 🔨 to staff nicks and organises the occasional nick party!
**Source:** https://github.com/the-programmers-hangout/Hawk
## Nano
**Description:** Nano manages our AMAs. Whenever someone is accepted for an AMA, we'll give them a run down of how it works.
**Source:** https://github.com/the-programmers-hangout/Nano
## RaffleBot
**Description:** RaffleBot is a discord bot built originally for The Programmer's Hangout that focuses on managing giveaways.
**Description:** RaffleBot is a discord bot built originally for The Programmer's Hangout that focuses on managing giveaways.
**Source:** https://github.com/Abzylicious/RaffleBot
## Skadi
**Description:** Skadi manages activity roles on the server.
**Source:** This source isn't publicly available. We don't want people trying to game the system.
## Slothbot
**Description:** Slothbot manages slowmode across the server.
**Source:** https://github.com/the-programmers-hangout/slothbot
## Taboo
**Description:** Taboo makes sure only accepted file formats are uploaded.
**Source:** https://github.com/the-programmers-hangout/Taboo
## Watchdog
**Description:** Watchdog guards the gates of our server against raids and bots.
+1 -2
View File
@@ -46,7 +46,6 @@ If you get annoyed that you don't have your name and make a big deal out of it,
The Programmer's Hangout has an [organisation on GitHub](https://github.com/the-programmers-hangout) and the best part is that you can join it too! To get yourself added to the organisation, send your GitHub username to the moderators via @ModMail#8255 and you'll be invited to the organisation. You even get a cool little badge on your GitHub profile!
## How do I appeal my ban?
We accept ban appeals 30 days after the initial ban date. You can appeal your ban through [this google form.](https://forms.gle/TZEmvxnMbVNfCe4o7)
We accept ban appeals 30 days after the initial ban date. You can appeal your ban through [this google form.](https://forms.gle/TZEmvxnMbVNfCe4o7)
+1 -1
View File
@@ -104,7 +104,7 @@ Minimodding will not be tolerated in the server.
A user is considered minimodding if they try to moderate a conversation without being a staff member. This includes repeatedly pointing out to a user that something is against the rules.
If you suspect a member is breaking a rule, do not engage. Avoid piling on the user with macros or redirects. Alert one of our staff members either through Modmail or reacting to the message using the `:stop_sign:` emoji.
If you suspect a member is breaking a rule, do not engage. Avoid piling on the user with macros or redirects. Alert one of our staff members either through Modmail or reacting to the message using the `:stop_sign:` emoji.
### Do not discuss infractions in public
+47 -40
View File
@@ -9,16 +9,14 @@ title: What is Ansible?
Ansible is an open-source software provisioning, configuration management, and application deployment tool enabling Infrastructure as code. It handles configuration management, application deployment, cloud provisioning, ad-hoc task execution, network automation, and multi-node orchestration.
## What are the advantages of Ansible over other configuration management tools such as Chef or cfengine?
A big problem with other configuration management systems was that they relied on an agent to manage their systems, this creates a new problem of "managing the management" because the agents must be bootstrapped and kept updated which adds complexity. Ansible however is agentless. Ansible takes advantage of existing remote management systems like ssh and winrm to do its execution and not require managing another agent. While incoming ssh and winrm are never enabled by default in these operating systems, ansible is also a provisioning tool, which means it can provision systems with those two enabled. Rules can be set to ensure restarting these daemons if they crash, or restoring the state of the system in case ansible cant reach them, further reducing the need of human intervention.
Another important advantage of ansible over chef is the “source of truth”. Ansible uses "playbooks" which are the set of instructions to be performed, that act as the source of truth. These playbooks can be stored in git and allow ansible to fetch them directly from the git server as required providing all the advantages of Infrastructure as Code. With other configuration management tools such as Chef, you have to upload the “cookbooks” to one of the Chef Servers, and there is no straightforward way of making sure they stay consistent.
Another important advantage of ansible over chef is the “source of truth”. Ansible uses "playbooks" which are the set of instructions to be performed, that act as the source of truth. These playbooks can be stored in git and allow ansible to fetch them directly from the git server as required providing all the advantages of Infrastructure as Code. With other configuration management tools such as Chef, you have to upload the “cookbooks” to one of the Chef Servers, and there is no straightforward way of making sure they stay consistent.
Another big advantage Ansible has over other Configuration Management systems is the ability to use dynamic inventory. With Chef, for example, you have to manually configure what system is being managed by Chef. With Ansible, you can poll data from an external source. This external source can be a system managed by Ansible itself, with ansible itself providing the data for when a new system is provisioned in the private or public cloud, making ansible self-reliant.
## Why use Ansible when I can just use bash & perl?
Ansible provides five major advantages to using bash & perl.
@@ -33,22 +31,24 @@ Ansible provides five major advantages to using bash & perl.
**5.** Ansible comes with the ultimate oh shit button. Paid support.
## How do I get ansible?
You can get Ansible as a control node on most major platforms except Windows. Windows can be managed by Ansible, but it cannot be a control node.
On Fedora:
On Fedora:
```sh
$ sudo dnf install ansible
```
On RHEL/CentOS:
```sh
$ sudo yum install ansible
```
On Ubuntu:
```sh
$ sudo apt update
$ sudo apt install software-properties-common
@@ -57,11 +57,13 @@ $ sudo apt install ansible
```
On Gentoo:
```sh
$ merge -av app-admin/ansible
```
On FreeBSD:
```sh
$ sudo pkg install py36-ansible
```
@@ -71,12 +73,15 @@ Instructions to install on other targets can be found on https://docs.ansible.co
## How do I use ansible?
Running an ansible playbook is simple.
```sh
$ ansible -i inventory playbook.yml
```
`-i` is to give the inventory, or the hosts where this playbook would run. This file contains the hostname/ip of the machine.
An example inventory file:
```yml
[all:vars]
ansible_user=tph_admin
@@ -118,13 +123,14 @@ Inventory = /path/to/inventory
```
This simplifies your commands a little. Now you can do things such as:
```sh
$ ansible web --list-hosts
$ ansible web, ansible --lists-hosts
$ ansible node* --list-hosts
$ ansible all --list-hosts
```
If you dont set the inventory variable in .ansible.cfg file you can still do the same but you need to prepend the inventory.
```sh
@@ -145,13 +151,14 @@ Remember, you dont have to run a command over a group. You can also run it ov
$ ansible node1 -m ping
```
Ping is a module that comes built into ansible. We specify it will be a module using `-m`. It has built in error handling. All major unix commands are built into ansible as modules. You can find a list of all ansible modules using `$ ansible-doc -l`. Use grep to pinpoint modules.
Ping is a module that comes built into ansible. We specify it will be a module using `-m`. It has built in error handling. All major unix commands are built into ansible as modules. You can find a list of all ansible modules using `$ ansible-doc -l`. Use grep to pinpoint modules.
Sometimes modules might not exist for your command. Maybe you are using a custom thing. In that case you can run ad-hoc commands over ansible.
```sh
$ ansible node1 -m command -a “ping”
```
In this case command is a module and `-a` is followed by the command that will be run.
## Examples of Ansible Playbooks
@@ -167,17 +174,17 @@ A playbook to install cockpit on your CentOS web server.
become: yes # become a superuser
tasks:
- name: Cockpit is installed and is updated
yum :
yum :
name: cockpit # name of package
state: latest # make sure its updated if its not the latest release
- name: Cockpit enabled and running
service:
service:
name: cockpit
enabled: true
state: started
```
YAML is a pain to write and syntax errors can occur. However, ansible comes with a tool to ensure theres no syntax error. Check your playbook with:
YAML is a pain to write and syntax errors can occur. However, ansible comes with a tool to ensure theres no syntax error. Check your playbook with:
```sh
$ ansible-playbook --syntax-check playbook.yml
@@ -186,6 +193,7 @@ $ ansible-playbook --syntax-check playbook.yml
In fact, that playbook is incorrect. Run that command to see where its incorrect!
Then you can run it using:
```sh
$ ansible-playbook playbook.yml
```
@@ -201,18 +209,18 @@ A playbook to ensure certain users are present in a node.
hosts: web
become: true
tasks:
- name: Ensure three users are present
user:
name: “{{ whatver_name_you_want_this_to_be }}”
state: present
loop:
dev_user
qa_user
prod_user
tasks:
- name: Ensure three users are present
user:
name: “{{ whatver_name_you_want_this_to_be }}”
state: present
loop: dev_user
qa_user
prod_user
```
Create a VM on vsphere ESXi from a template.
```yml
---
- name: Create a VM from a template
@@ -220,27 +228,26 @@ Create a VM on vsphere ESXi from a template.
connection: local
gather_facts: no
tasks:
- name: Clone the template
vmware_guest:
hostname: 192.0.2.44
username: [email protected]
password: vmware
validate_certs: False
name: testvm_2
template: template_el7
datacenter: DC1
folder: /DC1/vm
state: poweredon
wait_for_ip_address: yes
- name: Clone the template
vmware_guest:
hostname: 192.0.2.44
username: [email protected]
password: vmware
validate_certs: False
name: testvm_2
template: template_el7
datacenter: DC1
folder: /DC1/vm
state: poweredon
wait_for_ip_address: yes
```
These are very simple playbooks. However you can go beyond and do wonders. At my workplace we have a playbook that checks the make of storage nodes we sell, then determines what version of esxi we support on it, and starts the work to set up initial storage volume pools. It then starts migrating data from customers old pools to our own pools. If for some reason it fails, and it is not the customers fault (invalid input for example), it writes an email with all the logs and sends it to the customers representative in our company, who upon getting the email, calls the customer and starts troubleshooting things with them.
We also have a playbook that we use for provisioning virtual storage clusters on KVM, ESXi, Xen and HyperV, runs stress tests against them to ensure the software is working properly, and then goes ahead to use PXE Boot on 15 racks of physical hardware located all over the country to install the new software, including two racks stored in high temperature and low temperature conditions and run the same set of stress tests to ensure it works on Physical hardware as well.
We also have a playbook that we use for provisioning virtual storage clusters on KVM, ESXi, Xen and HyperV, runs stress tests against them to ensure the software is working properly, and then goes ahead to use PXE Boot on 15 racks of physical hardware located all over the country to install the new software, including two racks stored in high temperature and low temperature conditions and run the same set of stress tests to ensure it works on Physical hardware as well.
Theres a lot more you can do with it, so go on and experiment with things you do daily and see what you can automate!
## When should I not use ansible?
## When should I not use ansible?
When its trivial to do something with a couple lines of bash or perl. Say opening a zip file, exporting all the test data from it to make a graph. This might seem like a stupid thing to point out, but people do it all the time.
@@ -250,11 +257,11 @@ https://docs.ansible.com/
## Ansible AWX & Tower
Ansible comes with a web dashboard, and it is highly recommended you install it. Its mindlessly easy to install, and makes using ansible a breeze. It exposes a REST API, that you can use to automate ansible even further. You shouldnt be using Ansible without it!
Ansible comes with a web dashboard, and it is highly recommended you install it. Its mindlessly easy to install, and makes using ansible a breeze. It exposes a REST API, that you can use to automate ansible even further. You shouldnt be using Ansible without it!
There are two dashboards. Ansible AWX and Ansible Tower. Ansible AWX is the upstream version of the dashboard. Tower is the paid version, comes with support, and guarantees back compatibility to a specific release.
There are two dashboards. Ansible AWX and Ansible Tower. Ansible AWX is the upstream version of the dashboard. Tower is the paid version, comes with support, and guarantees back compatibility to a specific release.
After you have installed Ansible, to install AWX you need to install some dependencies. Ensure you have git, docker, gnu make and docker-compose installed. You also need to install docker python module through pip.
After you have installed Ansible, to install AWX you need to install some dependencies. Ensure you have git, docker, gnu make and docker-compose installed. You also need to install docker python module through pip.
To set up awx:
@@ -268,8 +275,8 @@ You can edit the inventory file to change different variables such as username a
With the default configuration options, assuming you didnt edit the inventory file, you can access your dashboard at http://localhost/
The username is admin, and the password is password. Please change them if you haven't already pre-install.
The username is admin, and the password is password. Please change them if you haven't already pre-install.
For tower, contact the paid support you are paying for.
For tower, contact the paid support you are paying for.
We will not be covering awx in detail in this spotlight as it's complex enough to have it's own spotlight. However, don't let that stop you from asking questions about it!
We will not be covering awx in detail in this spotlight as it's complex enough to have it's own spotlight. However, don't let that stop you from asking questions about it!
+20 -16
View File
@@ -12,18 +12,20 @@ Clojure is a dynamically typed high level lisp designed with interactive develop
## Clojure features
* Immutability by default: on creation, you cannot change the value of a variable or data structure. this has a few benefits: you know the value of the variable at any point, references can be shared safely as they don't usually modify the value, and of course it is great for concurrency as shared mutable state is minimised.
* Immutable persistent data structures: data structures that cannot be changed after creation, that preserves previous versions. This type of data structure will use a set of core functions to modify and yield a new updated version, and as they are immutable previous versions can be re-used between data structures, so they are not incredibly memory inefficient.
* Host platform interoperability: a major downside to many great languages is the lack of libraries that will attract a userbase and promote development in the language. Luckily for us, this is not the case with Clojure as the language is made to be fully interoperable with the host machine languages, so you can use Java libraries in JVM targetted Clojure code, .NET libraries in CLR targetted code and JS libraries and frameworks in ClojureScript. The benefits of this are immeasurable and allow so much more freedom when using Clojure.
* Java: the main Clojure compiler targets the JVM, and allows programmers to use any Java libraries (or even other JVM language libraries) to harness the full potential of Clojure. There is the option to use the libraries directly, for example JavaFX, or using a Clojure wrapper for the library, such as CLJFX, which can make interop code more idiomatic.
* .NET: Clojure has a ported compiler called clojure-clr, which targets the .NET runtime. This allows programmers to use C# and other .NET libraries, including OpenGL. Although this port is not as used, it is still relatively similar to the main compiler.
* ClojureScript: this is a Clojure compiler targetting JavaScript, again with full interoperability with JS, allowing web apps and websites to be built in Clojure. This compiler uses the Google Closure Optimizing Compiler, meaning that the JavaScript code produced is very efficient and performant. There are many wrappers for JS frameworks and libraries, such as Reagent (a minimalistic React interface).
* Concurrency models:
* Software Transactional Memory and Atoms: Clojure has atoms built into the language, which are what store a state. STM will make a copy of the global variable being modified or referred to, and allow any operations to be performed on said data. After the changes are made the global variable is checked for any changes since the copy was made, and if the original copy and new copy are identical, the global is updated. Otherwise, the current changes are discarded, a new copy of the global is obtained and this process repeats. A key point is to not perform side effects with atomic changes.
* Asynchronous Agents: Clojure also has another concurrency model, using agents that are bound to a single location for their lifetime, and require an action to mutate its the location to a new state. An agent should have an immutable state, and will be able to be read without coordination. An action will be dispatched by a send function which will return, and then later on the action (which is a function) will be applied to the agent's state. The return value of this function will be sent to be validated, and if validation succeeds or there is no validator, the agent's state will be updated, and any watchers will be notified. Any other actions dispatched later will be added to the action queue to be applied once the agent's state has changed.
* Lazy sequences: lazy sequences are a feature that allows element evaluation to be deferred by computing the sequence at runtime, which allows infinitely long sequences to be created with little overhead, with the option to forcefully evaluate elements if required.
- Immutability by default: on creation, you cannot change the value of a variable or data structure. this has a few benefits: you know the value of the variable at any point, references can be shared safely as they don't usually modify the value, and of course it is great for concurrency as shared mutable state is minimised.
- Immutable persistent data structures: data structures that cannot be changed after creation, that preserves previous versions. This type of data structure will use a set of core functions to modify and yield a new updated version, and as they are immutable previous versions can be re-used between data structures, so they are not incredibly memory inefficient.
- Host platform interoperability: a major downside to many great languages is the lack of libraries that will attract a userbase and promote development in the language. Luckily for us, this is not the case with Clojure as the language is made to be fully interoperable with the host machine languages, so you can use Java libraries in JVM targetted Clojure code, .NET libraries in CLR targetted code and JS libraries and frameworks in ClojureScript. The benefits of this are immeasurable and allow so much more freedom when using Clojure.
- Java: the main Clojure compiler targets the JVM, and allows programmers to use any Java libraries (or even other JVM language libraries) to harness the full potential of Clojure. There is the option to use the libraries directly, for example JavaFX, or using a Clojure wrapper for the library, such as CLJFX, which can make interop code more idiomatic.
- .NET: Clojure has a ported compiler called clojure-clr, which targets the .NET runtime. This allows programmers to use C# and other .NET libraries, including OpenGL. Although this port is not as used, it is still relatively similar to the main compiler.
- ClojureScript: this is a Clojure compiler targetting JavaScript, again with full interoperability with JS, allowing web apps and websites to be built in Clojure. This compiler uses the Google Closure Optimizing Compiler, meaning that the JavaScript code produced is very efficient and performant. There are many wrappers for JS frameworks and libraries, such as Reagent (a minimalistic React interface).
- Concurrency models:
- Software Transactional Memory and Atoms: Clojure has atoms built into the language, which are what store a state. STM will make a copy of the global variable being modified or referred to, and allow any operations to be performed on said data. After the changes are made the global variable is checked for any changes since the copy was made, and if the original copy and new copy are identical, the global is updated. Otherwise, the current changes are discarded, a new copy of the global is obtained and this process repeats. A key point is to not perform side effects with atomic changes.
- Asynchronous Agents: Clojure also has another concurrency model, using agents that are bound to a single location for their lifetime, and require an action to mutate its the location to a new state. An agent should have an immutable state, and will be able to be read without coordination. An action will be dispatched by a send function which will return, and then later on the action (which is a function) will be applied to the agent's state. The return value of this function will be sent to be validated, and if validation succeeds or there is no validator, the agent's state will be updated, and any watchers will be notified. Any other actions dispatched later will be added to the action queue to be applied once the agent's state has changed.
- Lazy sequences: lazy sequences are a feature that allows element evaluation to be deferred by computing the sequence at runtime, which allows infinitely long sequences to be created with little overhead, with the option to forcefully evaluate elements if required.
## Tools
Clojure has many different tools that make it an amazing language to work with, the most prominent of these being the REPL. The Clojure compiler already comes with a REPL built in, but there are also others, such as nREPLs (network REPLs) and socket REPLS. More about those here: https://lambdaisland.com/guides/clojure-repls/clojure-repls#org44377fd
As for editors and extensions, there is CIDER, which is an Emacs IDE for Clojure supporting interactive REPL development via nREPLs, debugging, testing, docs lookup and more. There is also a similar environment called CALVA for visual studio code, which includes inline code evaluation, structural editing, intellisense and more. See these links: https://github.com/BetterThanTomorrow/calva https://github.com/clojure-emacs/cider
@@ -31,6 +33,7 @@ As for editors and extensions, there is CIDER, which is an Emacs IDE for Clojure
Now there are many more tools and libraries for Clojure which are included in this handy toolbox website: https://www.clojure-toolbox.com/
## Code Examples
```clj
Hello World 1
(println "Hello World")
@@ -40,7 +43,7 @@ Hello World 1
Hello World 2 (using Java entrypoint)
(ns foo.core
(:gen-class))
(defn -main
"docstrings go here"
[& args]
@@ -51,7 +54,8 @@ Further code examples:
https://pastecord.com/ukycegasab.clj
## Resources
* Getting started: https://clojure.org/guides/getting_started
* Special characters: https://clojure.org/guides/weird_characters
* Community docs: https://clojuredocs.org/
* Libraries: https://clojure.org/community/libraries
- Getting started: https://clojure.org/guides/getting_started
- Special characters: https://clojure.org/guides/weird_characters
- Community docs: https://clojuredocs.org/
- Libraries: https://clojure.org/community/libraries
+127 -91
View File
@@ -7,49 +7,54 @@ title: What is Deno?
---
## What is Deno?
Deno is a modern and secure runtime, and toolchain for JavaScript and TypeScript. It uses V8 and is built in Rust.
## History
Deno was created by Ryan Dahl, the creator of Node.js to fix some of his regrets with the now over a decade old javascript runtime which can be found in his talk: '10 Things I Regret About Node.js' <https://www.youtube.com/watch?v=M3BM9TB-8yA>
## What benefits does Deno have?
* TypeScript support out of the box.
* Support for Inbuilt tooling which is available without configuring or installing anything:
* Format
* Test
* Lint
* Bundle
* Compile
* Generate documentation
* Browser compatibility through support for ES modules and Web APIs; which makes it easy to pick up.
* Secure sandbox, access to the filesystem, environment or the network has to be explicitly given.
* No node_modules folder. Dependencies are declared as direct urls. All dependencies are fetched, compiled, and stored in a centralized DENO_DIR folder.
* Explicit import mechanism makes the module system more robust and easy to use.
* Modular and easily extendable.
* Focuses on embeddable architecture.
* Standard library which is available at <https://deno.land/std@0.97.0>
* Faster HTTP, TypeScript compile time and common tooling. Say goodbye to long CI times.
- TypeScript support out of the box.
- Support for Inbuilt tooling which is available without configuring or installing anything:
- Format
- Test
- Lint
- Bundle
- Compile
- Generate documentation
- Browser compatibility through support for ES modules and Web APIs; which makes it easy to pick up.
- Secure sandbox, access to the filesystem, environment or the network has to be explicitly given.
- No node_modules folder. Dependencies are declared as direct urls. All dependencies are fetched, compiled, and stored in a centralized DENO_DIR folder.
- Explicit import mechanism makes the module system more robust and easy to use.
- Modular and easily extendable.
- Focuses on embeddable architecture.
- Standard library which is available at <https://deno.land/std@0.97.0>
- Faster HTTP, TypeScript compile time and common tooling. Say goodbye to long CI times.
## Architecture
Unlike node, deno is built to be modular and is a collection of rust crates. These crates can be tested, used, and worked on independently.
* Rusty_v8 provides zero-cost rust bindings to v8.
* Deno_core contains:
* ES module loading infrastructure.
* JsRuntime which can be used with an event loop implementation. This is a single execution context for javascript.
* Resource table infrastructure. A resource is similar to a file descriptor. They are integers that are allocated by the privileged side of Deno which refer to various rust objects that need to be persisted between ops.
* Ops interface (Denos operating system bindings) to bind rust functions to the javascript side. This centralized binding interface allows you to monitor global metrics and state reliably.
* Extension interface.
* Deno_runtime is built on deno core and contains ops to implement the Deno namespace (APIs for FS, I/O, net tcp/udp and similar).
* Extensions folder contain implementation of web specs such as fetch, timers, websocket, webusb, and others.
* Cli is built on deno_runtime and contains.
* Infrastructure to compile and typecheck typescript.
* Infrastructure for code analysis and module graph.
* Inbuilt tooling such as lint, docs, or format. Those tools are built using rust crates such as deno_lint, deno_doc, and dprint.
* Extensions
* LSP (Language Server Protocol)
- Rusty_v8 provides zero-cost rust bindings to v8.
- Deno_core contains:
- ES module loading infrastructure.
- JsRuntime which can be used with an event loop implementation. This is a single execution context for javascript.
- Resource table infrastructure. A resource is similar to a file descriptor. They are integers that are allocated by the privileged side of Deno which refer to various rust objects that need to be persisted between ops.
- Ops interface (Denos operating system bindings) to bind rust functions to the javascript side. This centralized binding interface allows you to monitor global metrics and state reliably.
- Extension interface.
- Deno_runtime is built on deno core and contains ops to implement the Deno namespace (APIs for FS, I/O, net tcp/udp and similar).
- Extensions folder contain implementation of web specs such as fetch, timers, websocket, webusb, and others.
- Cli is built on deno_runtime and contains.
- Infrastructure to compile and typecheck typescript.
- Infrastructure for code analysis and module graph.
- Inbuilt tooling such as lint, docs, or format. Those tools are built using rust crates such as deno_lint, deno_doc, and dprint.
- Extensions
- LSP (Language Server Protocol)
## Deno Sandbox
Deno embraces browsers in providing a sandbox. By default, no permissions are given to the scripts.
```sh
@@ -68,7 +73,7 @@ deno run --allow-env=DISCORD_TOKEN,BAN script.ts
# Can only write to /tmp and specific relative directories
deno run --allow-write=/tmp,./some_relative_directory script.ts
# Can write to everything. No check option ignores type checking typescript and speeds up startup time.
# Can write to everything. No check option ignores type checking typescript and speeds up startup time.
deno run --allow-write --no-check script.ts
# Can access everything. Reload flag reload dependencies instead of using cache.
@@ -80,42 +85,52 @@ deno run --prompt script.ts
# Install a cli with all permissions named aleph (react-next-alternative for deno)
deno install --unstable -A -n aleph https://deno.land/x/[email protected]/cli.ts
```
Note: Higher level permissions will override lower level perms. If you give access to /tmp, it will automatically give access to /tmp/file, /tmp/test/file.
## Permissions API
Code can ask for permissions to be granted dynamically using the Deno.permissions API.
Code can ask for permissions to be granted dynamically using the Deno.permissions API.
```ts
// We will use utility functions from denos standard library to query and prompt for permissions.
import { grant, grantOrThrow } from "https://deno.land/[email protected]/permissions/mod.ts"
import {
grant,
grantOrThrow,
} from "https://deno.land/[email protected]/permissions/mod.ts";
// grantOrThrow will throw if permissions are not given.
// grantOrThrow will throw if permissions are not given.
const permissions = await grant([{
name: "env"
}, {
const permissions = await grant([
{
name: "env",
},
{
name: "write",
path: "/tmp"
}])
path: "/tmp",
},
]);
// Once prompted and denied, you cannot prompt for permissions again. Any subsequent call will return the previous state.
console.log(permissions)
console.log(permissions);
```
## Web Compatibility
Nodes incompatibility with the web is a huge burden on everyone. Here are few common pain points:
Polyfill browser APIs such as fetch or window.
Build and maintain native packages for web APIs such as USB, GPU, and others.
Build and maintain native packages for web APIs such as USB, GPU, and others.
Maintain two module systems. (See is-promise incident).
Deal with ambiguous and complex situations when transpiling and bundling.
Relearn node-specific way to achieve what can be done through web APIs.
Deal with ambiguous and complex situations when transpiling and bundling.
Relearn node-specific way to achieve what can be done through web APIs.
Deno avoids above and future problems by committing to strong compatibility with web standards.
### 1. Web Worker
Web workers are used to write multithreaded code on the web. They are available in Deno with one notable change. You can enable deno namespace for workers and enforce permissions.
Web workers are used to write multithreaded code on the web. They are available in Deno with one notable change. You can enable deno namespace for workers and enforce permissions.
```ts
// Worker will inherit permission of the parent unless you explicitly set permissions.
@@ -131,7 +146,8 @@ const worker = new Worker(new URL("./worker.ts", import.meta.url).href, {
```
### 2. Web GPU
WebGPU API provides a low level, high performance, and cross platform way to program GPU hardware. The spec isnt finalized. Deno and most browsers support it through an experimental flag.
WebGPU API provides a low level, high performance, and cross platform way to program GPU hardware. The spec isnt finalized. Deno and most browsers support it through an experimental flag.
<https://github.com/gpuweb/gpuweb/wiki/Implementation-Status>
@@ -147,45 +163,50 @@ deno run --unstable --allow-write=. https://crux.land/4KtnG8
# Open it
./output.png
```
You can open the URL in the browser to see what the code looks like. More examples can be found in this repo: <https://github.com/crowlKats/webgpu-examples>
Note: WSL2 users will need to be on insider and have graphics drivers for wsl installed.
### 3. Local Storage And Session Storage
Deno supports local storage and session storage. Persistence is achieved using sqlite behind the scenes.
Deno supports local storage and session storage. Persistence is achieved using sqlite behind the scenes.
```ts
localStorage.setItem('deno', 'good dinosaur')
console.log(localStorage.getItem('deno'))
localStorage.removeItem('deno')
localStorage.clear()
localStorage.setItem("deno", "good dinosaur");
console.log(localStorage.getItem("deno"));
localStorage.removeItem("deno");
localStorage.clear();
```
```sh
# Set location.
# Set location.
deno run --location=https://myapp script.ts
```
### 4. Import Map
Import map lets you rewire your code imports.
Import map lets you rewire your code imports.
```json
{
"imports": {
"std/": "https://deno.land/[email protected]/",
"npm/": "https://esm.sh/"
}
"imports": {
"std/": "https://deno.land/[email protected]/",
"npm/": "https://esm.sh/"
}
}
```
```ts
// Only for illustration purposes. Dont use this approach.
import { VERSION } from "std/version.ts"
import { VERSION } from "std/version.ts";
import Markdown from "npm/markdown-it"
const md = new Markdown()
import Markdown from "npm/markdown-it";
const md = new Markdown();
console.log(md.render(`# Hello, I am using std@${VERSION}`))
console.log(md.render(`# Hello, I am using std@${VERSION}`));
```
```sh
deno run --import-map=./import_map.json script.ts
```
@@ -195,6 +216,7 @@ More: <https://docs.google.com/document/d/1vFQzbmxg9ilpg8CT_P8roEYcpTfZ06Q5N4J9-
You can look inside extensions to see which web standards are supported: <https://github.com/denoland/deno/tree/main/extensions>
## Tooling
```sh
# lint the code.
deno lint
@@ -225,15 +247,17 @@ deno doc
```
## How do I use my existing node packages?
Use a cdn such as esm.sh or skypack.dev. They will convert npm packages to work with deno. Node modules are polyfilled through <https://deno.land/std/node/>. If your package uses an unavailable node module, it wont work with deno. You can make a PR to add it in the std.
```ts
import React from "https://esm.sh/react"
import React from "https://esm.sh/react";
// we need ?dts flag to get `X-Typescript-Types` header on skypack.
import ReactDom from "https://cdn.skypack.dev/[email protected]?dts"
import ReactDom from "https://cdn.skypack.dev/[email protected]?dts";
```
## How do I get auto completion for url imports?
Add this to your vscode config to get import intellisense for your favorite registry (any registry will work as long as they support registry protocol: <https://github.com/denoland/vscode_deno/blob/main/docs/ImportCompletions.md#module-registry-completions>
```json
@@ -242,9 +266,11 @@ Add this to your vscode config to get import intellisense for your favorite regi
"https://nest.land/": true
}
```
You should be able to configure this for your favorite editor since its implemented inside LSP.
## Isnt it insecure to import from urls? What if they change code?
No, deno caches any dependencies in DENO_DIR on running any command on the source code. It will use cache for subsequent runs. You can generate a lock file which can later be used to check subresource integrity.
```sh
@@ -254,20 +280,23 @@ deno cache --lock=deno.lockfile --lock-write deps.ts
# Use lockfile when running a script
deno run --lock=deno.lockfile script.ts
```
Unless you pass `--reload`, deno wont refetch any of the urls.
Unless you pass `--reload`, deno wont refetch any of the urls.
## How do type declarations for external modules work?
This is usually handled by registries by providing a specific header `X-Typescript-Types` in the requests. Deno will automatically fetch types from that.
This is usually handled by registries by providing a specific header `X-Typescript-Types` in the requests. Deno will automatically fetch types from that.
You can explicitly provide deno a type declaration file by commenting `@deno-types=path_to_file`.
```ts
// @deno-types=”./some_module.d.ts”
// Remote files are supported as well.
import someModule from "./some_module.js"
import someModule from "./some_module.js";
```
## How do you use private modules with deno?
Deno will request a file using an Authorization header set to Bearer [TOKEN]. You have to set these in the `DENO_AUTH_TOKENS` environment variable.
```
@@ -276,40 +305,46 @@ DENO_AUTH_TOKENS=[token]@deno.land;[token]@example.land:5000
```
## I want a script runner.
Use make, denon, velociraptor or others.
Use make, denon, velociraptor or others.
1. <https://www.gnu.org/software/make/>
2. <https://github.com/denosaurs/denon>
3. <https://velociraptor.run/>
## Which companies use deno?
Github, netlify, fly.io, appwrite, and many others.
Github, netlify, fly.io, appwrite, and many others.
## Code examples
### Http Server
```ts
const body = new TextEncoder().encode("Hello World");
async function handler(conn: Deno.Conn) {
for await (const { respondWith } of Deno.serveHttp(conn)) {
respondWith(new Response(body));
}
for await (const { respondWith } of Deno.serveHttp(conn)) {
respondWith(new Response(body));
}
}
for await (const conn of Deno.listen({ port: 4000 })) {
handler(conn)
handler(conn);
}
```
```sh
# We will run it with prompt and unstable since native http isnt stable yet
deno run --unstable --prompt http.ts
# Grant it the perm
# Grant it the perm
⚠️ Deno requests net access to "0.0.0.0:4000". Grant? [g/d (g = grant, d = deny)] g
# Now open browser window and go to http://0.0.0.0:4000
```
### Cat
```ts
const filenames = Deno.args;
for (const filename of filenames) {
@@ -320,6 +355,7 @@ for (const filename of filenames) {
```
### Testing
```ts
import {
assert,
@@ -364,19 +400,19 @@ Shell Tool: <https://deno.land/x/[email protected]>
## Resources
* Website: https://deno.land/
* Documentation viewer for modules: <https://doc.deno.land/>
* Code and dep visualizer: <https://deno-visualizer.danopia.net/>
* Manual: <https://deno.land/manual>
* Runtime APIs: <https://doc.deno.land/builtin/stable>
* Deno lint rules: <https://lint.deno.land/>
* Standard Library: <https://deno.land/std>
* Benchmark: <https://deno.land/benchmarks>
* Testing: <https://deno.land/manual@v1.10.2/testing>
* FAQs for typescript in deno: <https://deno.land/manual@v1.8.1/typescript/faqs>
* Editor: <https://deno.land/manual@v1.9.0/getting_started/setup_your_environment#editors-and-ides> (Note: jetbrains plugin is broken.)
* Debugging: <https://deno.land/manual@v1.9.0/getting_started/debugging_your_code>
* Deno walkthrough series on youtube: <https://www.youtube.com/channel/UCjg3RCjC2punepJwGYFW7RQ>
* Pastebin for deno: <https://crux.land/>
* Docker Image: <https://github.com/denoland/deno_docker>
* Web platform compat status: <https://wpt.deno.land/>
- Website: https://deno.land/
- Documentation viewer for modules: <https://doc.deno.land/>
- Code and dep visualizer: <https://deno-visualizer.danopia.net/>
- Manual: <https://deno.land/manual>
- Runtime APIs: <https://doc.deno.land/builtin/stable>
- Deno lint rules: <https://lint.deno.land/>
- Standard Library: <https://deno.land/std>
- Benchmark: <https://deno.land/benchmarks>
- Testing: <https://deno.land/manual@v1.10.2/testing>
- FAQs for typescript in deno: <https://deno.land/manual@v1.8.1/typescript/faqs>
- Editor: <https://deno.land/manual@v1.9.0/getting_started/setup_your_environment#editors-and-ides> (Note: jetbrains plugin is broken.)
- Debugging: <https://deno.land/manual@v1.9.0/getting_started/debugging_your_code>
- Deno walkthrough series on youtube: <https://www.youtube.com/channel/UCjg3RCjC2punepJwGYFW7RQ>
- Pastebin for deno: <https://crux.land/>
- Docker Image: <https://github.com/denoland/deno_docker>
- Web platform compat status: <https://wpt.deno.land/>
+4
View File
@@ -7,9 +7,11 @@ title: What is Docker?
---
## What is Docker?
Docker is a platform for developers and sysadmins to develop, deploy, and run applications with containers. Containers allow for total application and environment isolation which makes it much easier to ensure an application runs with any necessary dependencies.
## Why should I use Docker?
The simplest use case for Docker is packaging an application into an image and then running it on any machine running the Docker platform. Think running your API locally on Windows, on your OSX laptop, or on a Linux server in a cloud without making any changes to your codebase, all with the same command.
For more complex deployments consisting of multiple containers, Docker provides a tool called docker-compose. This will read a configuration of one or more Docker containers and run them for you and manage them as a single application.
@@ -17,11 +19,13 @@ For more complex deployments consisting of multiple containers, Docker provides
Another benefit is using it to perform builds or development on local machines to avoid needing to set up a development environment. As dependencies can be a nightmare in situations like this, requiring things like npm or virtualenv and other isolation techniques, containerization can greatly simplify things and shorten the time it takes for someone to get set up on a project. You can even pull down a container containing a language runtime and just start writing code immediately, for languages with REPLs you can use docker to launch a REPL shell for any language without needing to go install a runtime on your machine.
## What's the difference between Docker and a VM?
VMs have been widely used to solve these problems. The key difference between VMs and containers is that containers are not a virtual OS. All containers running on a host share the same parent kernel. Container technology is enabled by core Linux kernel features for isolating applications. When you run a Linux container on a Windows machine using Docker for Windows, a single Linux VM must run as the host for the Linux containers, but when running natively on a Linux machine, no VM is required, and container applications run inside an isolated process, just like any other application.
The advantage to this approach is that it's very lightweight since it doesn't require the overhead of a virtual guest operating system and virtual access to resources through a hypervisor.
## Examples
You can get a fully functional ubuntu machine by just running
```sh
+7
View File
@@ -6,6 +6,7 @@ title: What is Elixir?
---
## What is Elixir?
Elixir is a dynamically typed, functional programming language, with an emphasis on concurrency.
Elixir, despite being a young language, has grown quite rapidly, and has surprisingly fleshed out libraries and documentation.
On a surface level, the language was inspired by ruby in terms of syntax, but the way the language works is quite different.
@@ -13,14 +14,17 @@ Elixir leverages concurrency via the "actor model", where many lightweight proce
To do this, Elixir compiles to the BEAM / Erlang VM, which was built with this kind of distributed programming model in mind. Elixir is very similar in features to Erlang.
## What is Erlang?
Erlang is a much older programming language, for which the Erlang VM was designed. Erlang was initially conceived of at Ericsson, for use in telecommunications. They needed to be able to handle many different calls at once, and so needed a programming model that support many different workers, or "actors" running concurrently.
The Erlang VM leverages the actor model to do this.
## How is Elixir different from Erlang?
Elixir has an arguably friendlier syntax, but for the most part is very similar to erlang in terms of language constructs.
One major addition to the language however is metaprogramming. Elixir has a rich and easy to use macro system, and an almost homiconic syntax, somewhat reminiscent of Lisp, but without the parens. Elixir also comes with a somewhat richer standard library. Another big advantage of Elixir is very easy interop with Erlang: calling an Erlang function is as simple as calling an Elixir one, and Erlang users can also use Elixir functions with little pain.
## What is the actor model?
We've mentioned the actor model a few times, but what exactly is it?
The actor model is 2 things
@@ -30,6 +34,7 @@ The actor model is 2 things
In elixir / erlang, we can run millions of processes concurrently with no worry at all. Each process has its own memory and resources, and to share these, they must communicate. Communication via processes is done via "message passing" where a process A will send a message to another process B, ready to receive and respond to that message. The only way to share data is by communicating, no 2 processes can hold onto the same piece of memory. This model avoids many problems arising from shared concurrent state (though not all, mind you).
## How do I learn more about Elixir?
There's quite a few resources on Elixir, including a few books https://elixir-lang.org/learning.html#books.
A good place to start if you're interested is the website itself: https://elixir-lang.org/ which includes a lot of information about the language, including a guide to installing and getting started with it, as well as a large tutorial guiding you through most of the language's constructs.
@@ -45,6 +50,7 @@ IO.puts "Hello World from Elixir!"
```
### Various ways of summing a lists
The first works via recursion and pattern matching on the shape of a list, the second works by using a function defined in the Enum module.
```elixir
@@ -63,6 +69,7 @@ end
```
### Concurrent Processes
A simple example how simple processes can delegate work between eachother. The different processes here are running in parallel after being spawned.
```elixir
+9 -4
View File
@@ -6,6 +6,7 @@ title: What is Google?
---
## What is Google?
Google allows us smooth brained chumps to keep our jobs while looking like we know what we're doing.
"What!?!?" I hear you say. That's right. Google can almost always give you the answers you're looking for and in this spotlight we'll show you how!
@@ -14,7 +15,7 @@ Google allows us smooth brained chumps to keep our jobs while looking like we kn
## How do I use google?
It's easy! Unbelievably easy. Alright, let's imagine you have a question, say "How do I create an array in java?".
It's easy! Unbelievably easy. Alright, let's imagine you have a question, say "How do I create an array in java?".
Step 1. open <https://www.google.com/>
@@ -28,7 +29,7 @@ That's all folks.
🦗
**But... I want to *really* know how to use google!**
**But... I want to _really_ know how to use google!**
Alright alright. Pull your chair up close and I'll tell you the secrets big search don't want you to know! You didn't hear it from me though!
@@ -37,6 +38,7 @@ Alright alright. Pull your chair up close and I'll tell you the secrets big sear
One of the most important things to know is that google uses various keyword and punctuation combinations as filter operators. Let's take a look at what they are, and how they affect your search results.
### 1. The colon
`site:` - Imagine you're looking for that one specific stack overflow post. You remember seeing it way back when you were just a wee little programming child typing on your keyboard with your index fingers only. We can use `site:` to filter our results to a specific website.
Example: `site:stackoverflow.com html regex` - One of the top results here should be an infamous SO post on parsing HTML with regex. If you haven't read it take a look!
@@ -54,14 +56,16 @@ Example: `cache:https://stackoverflow.com/questions` - Now you need not panic wh
Example: `filetype:pdf On Computable Numbers` - PDF results for one of Alan Turing's papers.
### 2. The dash
`-` this little guy is a tricksy fellow. The echos of enraged Java programmers shattered through the lands as they searched `-xmx` and were given no results. As it turns out, using a dash will **exclude** the following word from the results
Example: `-xmx` - will give you no results.
### 3. Quotes
`"` - When you make a search on google, if you put a word or phrase in quotes, google will look for an exact match. Useful if you're looking for a very specific error.
Example: `"Fly, you fools"`
Example: `"Fly, you fools"`
### 4. Range ..
@@ -76,6 +80,7 @@ If you're looking for research papers for school/college/uni/fun then Google Sch
<https://scholar.google.com/>
## Advanced Search
Still stuck trying to find what you want? Try Google's Advanced Search page <https://www.google.com/advanced_search>
This page is a slightly more UX friendly version of all the above filters and more!
Image advanced search: <https://www.google.com/advanced_image_search>
@@ -85,4 +90,4 @@ Scholar advanced search: <https://scholar.google.com/#d=gs_asd>
## Here is a handy cheatsheet!
https://cdn.discordapp.com/attachments/825348974164049920/829494747910504498/google-online-research-cheat-sheet.png
https://cdn.discordapp.com/attachments/825348974164049920/829494747910504498/google-online-research-cheat-sheet.png
+6 -2
View File
@@ -5,11 +5,12 @@ created_at: "2018/07/18"
title: What is GraphQL?
---
## What is GraphQL?
GraphQL is a query language for APIs, meant to challenge and replace REST. At its core, GraphQL enables declarative data fetching where a client can specify exactly what data it needs from an API. Put bluntly, a lot of people claim GraphQL to be REST 2.0.
## Why does GraphQL exist?
GraphQL was created internally by Facebook in 2012, mainly to optimize the network load for mobile devices. Interestingly, other companies like Netflix or Coursera were working on comparable ideas to make API interactions more efficient. When Facebook announced GraphQL, Coursera abandoned their efforts and jumped on GraphQL.
## What makes GraphQL better than REST?
@@ -85,6 +86,7 @@ query user(id: "5") {
3. Strong-typing. Contrary to working with JSON responses limited to string and numeric, and the discrepancy between front-end (JS) and any back-end language being lost in translation.
## Core concepts
GraphQL has three types of operations:
- queries (fetching data),
@@ -147,6 +149,7 @@ http://myapi/graphql?query={me{name}}
```
## How can I start using GraphQL?
While it is possible to convert an existing REST endpoint to GraphQL, either through automated tools, or manually, the best case scenario would be on an entirely new project.
## Common misconceptions
@@ -157,7 +160,8 @@ While it is possible to convert an existing REST endpoint to GraphQL, either thr
- When it was first announced by Facebook, a lot of people thought it was React exclusive! This is not true. GraphQL can work on any tech stack (although some languages have more complete tooling than others)
## Closing notes
## Closing notes
Today, GraphQL is used in production by lots of different companies such as GitHub, Twitter, Yelp and Shopify - to name only a few. We are seeing month after month, small and large companies converting to it.
## Related projects and libraries
@@ -7,10 +7,12 @@ title: What is Haskell?
---
## What is Haskell?
"Haskell is a computer programming language. In particular, it is a polymorphically statically typed, lazy, purely functional language, quite different from most other programming languages. The language is named for Haskell Brooks Curry, whose work in mathematical logic serves as a foundation for functional languages. Haskell is based on the lambda calculus, hence the lambda we use as a logo." - Haskell Wiki
The above being said, if you perceive yourself to be "bad" at math, don't feed into it. If you are interested in using it and you apply yourself it will work out.
## Why should I use Haskell?
Haskell is a general purpose programming language. So you can use it for anything, from scripting to game development - that being said, it provides you with some rather unique and cool benefits not found in many other places.
- Haskell code tends to be very short and clear (See code examples below)
+6
View File
@@ -6,10 +6,12 @@ title: What is Julia?
---
## What is Julia?
Julia is a high-level dynamic programming language for numerical computing. It is free and open-source: under the MIT license.
Although Julia is still in its youth (the current release is v1.2), Julia provides a lot of support for mathematical analysis and data science.
## How hard is Julia to learn?
Julia is a fairly complex language but has some very simple behaviors which are easy to pick up. It is mainly used for data science and mathematical analysis, so those complexities come with it. You must understand some mathematical principles to use the language well. Julia uses certain expressions differently from other languages as well making it a bit harder to pick up; however, it makes sense. For example, string concatenation is done with \*, and not +. Julia is heavily documented and low-level, so learning the standard syntax is easy to do by following the tutorial along with other resources.
## What's so great about Julia?
@@ -30,12 +32,15 @@ Julia is a fairly complex language but has some very simple behaviors which are
- Efficient support for Unicode, including but not limited to UTF-8
## What platforms can Julia run on?
Julia can run on most popular platforms such as MacOSX, most Linux builds, Windows, and others. This is due to it compiling to a native binary. However, it does not have broad support for front-end development, but there is a library for Qt bindings.
## CLI
The Julia download comes with a CLI environment. With the CLI you can try out Julia functions and expressions in the command line. (Binary languages rarely have a CLI, so this is pretty cool)
## Code Examples:
Hello world:
```julia
@@ -140,6 +145,7 @@ end
```
## Resources:
Julia documentation: <https://docs.julialang.org>
Try it out online! <https://juliabox.com>, and <https://www.tutorialspoint.com/execute_julia_online.php>
+9
View File
@@ -6,12 +6,15 @@ title: What is Kotlin?
---
## What is kotlin?
Kotlin is a statically typed programming language that runs on the JVM (Java Virtual Machine).
## Why does kotlin exist?
Kotlin exists as a modern roll of Java - Java was built from the ground up to suit OOP, and that's a task that it does pretty well. Later, functional programming was added in, by contrast, kotlin was made with both paradigms in mind, picking the good, easy to adopt parts up and adding them all into one neat language. Kotlin also had a requirement: Allow interop with Java code - to which it does (works great on android!)
## How hard is kotlin to learn?
Well, that depends a lot on where you are coming from. If you already know Java, it'll be exceptionally easy to pick up. Everything has a very "right" feeling to it compared to the older style, it's almost like a natural progression.
If you don't know Java, that's a bit trickier to answer. You can certainly learn it, as a first language either, but there are some Java things you will need to know. If I were learning it as a first language, I'd try to heavily rely on the documentation and understand each feature that exists in kotlin, and why they exist. The most important is the concept of nullable types.
@@ -19,6 +22,7 @@ If you don't know Java, that's a bit trickier to answer. You can certainly learn
Java will allow anything to be null, but in kotlin there is a distinct separation. a `String` is very different to a `String?` - the second one can have a value of null, the first cannot. When interoping with Java code, it's always best to assume anything can be null.
## What are some key features of kotlin?
If you're a Java user, here is a comparison list made by Jetbrains: <https://kotlinlang.org/docs/reference/comparison-to-java.html>
Some key ones to point out of this list:
@@ -28,18 +32,23 @@ Some key ones to point out of this list:
- Extension functions - great for fixing up a library class that is missing a method. No pretty print function? That's cool, just define it yourself. `LibraryClass.newFunction() = ...` (Yes, like C#)
## What platforms can kotlin run on?
Anything and everything. Let's break that down:
## The JVM
This is primary compile target, the JVM as a piece of kit allows you to write some code and have it work without separate compilations on Windows, Mac and Linux - so you've got all of your bases covered there.
## Android
Yea, it's also a first class language on android, the only other language supported by google: <https://youtu.be/d8ALcQiuPWs>
## Native
If you don't like the JVM and you're not an android dev, well, you can just target native: <https://kotlinlang.org/docs/reference/native-overview.html>
## JavaScript
Yea, you can make kotlin compile to JavaScript, see here: <https://kotlinlang.org/docs/tutorials/javascript/kotlin-to-javascript/kotlin-to-javascript.html>
Here are some extra points that don't fit into any of the headings above
+40 -31
View File
@@ -6,14 +6,17 @@ title: What is Lisp?
---
## What is Lisp?
Originally specified in 1958, Lisp is the second oldest high level programming language in use today. (Only younger than FORTRAN by one year!). There have been many different dialects of Lisp that have come and gone over the ages. In the modern day, some of the most known and used Lisp dialects (lisps) are Common Lisp, Clojure/ClojureScript, Racket and Scheme. The name "Lisp" was derived from "LISt Processor", and the list data structure is at the core of the language. Many recognizable language features were first developed in Lisp; dynamic typing, garbage collection, the read-eval-print loop, and more.
## How hard are Lisps to learn?
The basics are not very difficult (especially because there aren't that many basics to learn). Experience with functional programming translates well. Most Lisps have a very small set of keywords and syntax rules, and rich libraries constructed atop those simple essentials. A lot of newcomers to Lisps are initially put off by a lot of parentheses, but most of those newcomers come to accept, and in some cases, admire the simplicity provided by, those parens. For example, Lisps usually have no concept of 'operator precedence' - the innermost parens are evaluated first.
If you know python, this document may be of particular interest to you: http://norvig.com/python-lisp.html. Even if you don't know python, the second paragraph under the heading "Introducing Python" explains some Lisp philosophy of use.
## What are some key features?
- Homoiconicity: Lisps treat data and code similarly - that is to say, the code you write is in the form of lisp data structures (arbitrarily nested lists) that the lisp interpreter reads and evaluates. While this can feel awkward at first, it allows for what might be the simplest metaprogramming constructs.
- Macros: Macros let you expand and redefine the syntax of the language itself. Think of it as having a hook into the interpreter... you get to write what feel like functions that return lisp expressions, and the interpreter will expand those macros, and then evaluate the code that the macro expands to. This is only possible because lisp code is written as s-expressions (lists enclosed in parens). As a result, you don't find any grunt-work in lisp. No need to type semi-similar chunks of code over and over again when you can just invent new syntax for it. How powerful are macros? As one example, Clojure's function and macro definition operators are both macros that use the 'special form' (roughly a keyword) "def".
@@ -75,47 +78,53 @@ If you know python, this document may be of particular interest to you: http://n
## Learning resources, blogs, sources of information:
### Common Lisp:
- Practical Common Lisp (book available online): http://www.gigamonkeys.com/book/
- Land of Lisp: http://landoflisp.com/
- Common Lisp Hyperspec: http://clhs.lisp.se/
- Lisp koans: https://github.com/google/lisp-koans
- Planet Lisp (blog aggregation): http://planet.lisp.org/
- Common Lisp Wiki: https://cliki.net/
- Simplified common lisp reference: http://jtra.cz/stuff/lisp/sclr/index.html
- Learning Lisp fast: https://cs.gmu.edu/~sean/lisp/LispTutorial.html
- Articulate common lisp (a website that tries to cover beginner topics with fewer hard opinions): http://articulate-lisp.com/
- State of the common lisp ecosystem, 2015: http://borretti.me/article/common-lisp-sotu-2015
- Lisp subreddit: https://www.reddit.com/r/lisp/
- Wikipedia article on CAR and CDR (a central concept in lisp lists): https://en.wikipedia.org/wiki/CAR_and_CDR
- http://random-state.net/files/nikodemus-cl-faq.html
- Practical Common Lisp (book available online): http://www.gigamonkeys.com/book/
- Land of Lisp: http://landoflisp.com/
- Common Lisp Hyperspec: http://clhs.lisp.se/
- Lisp koans: https://github.com/google/lisp-koans
- Planet Lisp (blog aggregation): http://planet.lisp.org/
- Common Lisp Wiki: https://cliki.net/
- Simplified common lisp reference: http://jtra.cz/stuff/lisp/sclr/index.html
- Learning Lisp fast: https://cs.gmu.edu/~sean/lisp/LispTutorial.html
- Articulate common lisp (a website that tries to cover beginner topics with fewer hard opinions): http://articulate-lisp.com/
- State of the common lisp ecosystem, 2015: http://borretti.me/article/common-lisp-sotu-2015
- Lisp subreddit: https://www.reddit.com/r/lisp/
- Wikipedia article on CAR and CDR (a central concept in lisp lists): https://en.wikipedia.org/wiki/CAR_and_CDR
- http://random-state.net/files/nikodemus-cl-faq.html
### Clojure(Script):
- "Clojure for the Brave and True", a book somewhat akin to 'Automate the boring stuff', but aimed at Clojure: https://www.braveclojure.com/
- Clojure Homepage: https://clojure.org/api/cheatsheet
- Clojure GitHub: https://clojure.github.io/clojure/
- Katas: https://github.com/marshallshen/clojure-katas
- Koans: https://github.com/functional-koans/clojure-koans
- 4Clojure - a set of 150+ problems for practicing clojure, with interpretting and tests on the page: https://www.4clojure.com/
- Clojure subreddit: https://www.reddit.com/r/Clojure/
- Stand up a simple web app in Clojure: http://clojure-doc.org/articles/tutorials/basic_web_development.html
- An article explaining the basics of laziness available in Clojure: http://clojure-doc.org/articles/language/laziness.html
- "Clojure for the Brave and True", a book somewhat akin to 'Automate the boring stuff', but aimed at Clojure: https://www.braveclojure.com/
- Clojure Homepage: https://clojure.org/api/cheatsheet
- Clojure GitHub: https://clojure.github.io/clojure/
- Katas: https://github.com/marshallshen/clojure-katas
- Koans: https://github.com/functional-koans/clojure-koans
- 4Clojure - a set of 150+ problems for practicing clojure, with interpretting and tests on the page: https://www.4clojure.com/
- Clojure subreddit: https://www.reddit.com/r/Clojure/
- Stand up a simple web app in Clojure: http://clojure-doc.org/articles/tutorials/basic_web_development.html
- An article explaining the basics of laziness available in Clojure: http://clojure-doc.org/articles/language/laziness.html
### Scheme:
- Probably the de facto guide to Scheme is known as SICP - "Structure and Interpretation of Computer Programs". This is a book written by a couple of MIT professors, which was used as a textbook for introductory programming courses. It uses Scheme to teach principals of programming. It should probably be noted that this book and these courses are not focused on teaching Scheme (they cover the majority of the Scheme language in the first lecture/chapter) - they're focused on teaching computer programming concepts, and Scheme is just the language used to express those concepts.
- The SICP book online (freely available): https://mitpress.mit.edu/sites/default/files/sicp/index.html
- 2004 MIT SICP course playlist (higher quality, standalone video): https://www.youtube.com/playlist?list=PL7BcsI5ueSNFPCEisbaoQ0kXIDX9rR5FF
- The 2010 UC Berkeley SICP course (recorded in classroom, somewhat lower fidelity): https://www.youtube.com/playlist?list=PLhMnuBfGeCDNgVzLPxF9o5UNKG1b-LFY9
- Probably the de facto guide to Scheme is known as SICP - "Structure and Interpretation of Computer Programs". This is a book written by a couple of MIT professors, which was used as a textbook for introductory programming courses. It uses Scheme to teach principals of programming. It should probably be noted that this book and these courses are not focused on teaching Scheme (they cover the majority of the Scheme language in the first lecture/chapter) - they're focused on teaching computer programming concepts, and Scheme is just the language used to express those concepts.
- The SICP book online (freely available): https://mitpress.mit.edu/sites/default/files/sicp/index.html
- 2004 MIT SICP course playlist (higher quality, standalone video): https://www.youtube.com/playlist?list=PL7BcsI5ueSNFPCEisbaoQ0kXIDX9rR5FF
- The 2010 UC Berkeley SICP course (recorded in classroom, somewhat lower fidelity): https://www.youtube.com/playlist?list=PLhMnuBfGeCDNgVzLPxF9o5UNKG1b-LFY9
### Racket:
- The jumping-off point for Racket info (documentation, tools, getting started, etc) is https://racket-lang.org/.
- The jumping-off point for Racket info (documentation, tools, getting started, etc) is https://racket-lang.org/.
### IDEs/editors:
- Lisps in general: Emacs - Emacs has been called "a great operating system, lacking only a decent editor". The Emacs community has a lot of lispers, partially because Emacs plugin are written mostly in ELisp - a dialect of Lisp that is at the core of Emacs' extendability. As such, many Lisps have Emacs packages for editing, running, debugging, project maintenance, etc, and Emacs has packages for version control, file/directory management, and even things like personal organization (basically all done in text buffers).
- Lisps in general: Emacs - Emacs has been called "a great operating system, lacking only a decent editor". The Emacs community has a lot of lispers, partially because Emacs plugin are written mostly in ELisp - a dialect of Lisp that is at the core of Emacs' extendability. As such, many Lisps have Emacs packages for editing, running, debugging, project maintenance, etc, and Emacs has packages for version control, file/directory management, and even things like personal organization (basically all done in text buffers).
- Common Lisp: Emacs with SLIME, Vim with SLIMV, Portacle (kinda), LispWorks, Allegro CL.
- Common Lisp: Emacs with SLIME, Vim with SLIMV, Portacle (kinda), LispWorks, Allegro CL.
- Clojure: Nightcode, Light Table, IntelliJ Cursive, Eclipse with counterclockwise, Emacs with CIDER, VIM with Fireplace.
- Clojure: Nightcode, Light Table, IntelliJ Cursive, Eclipse with counterclockwise, Emacs with CIDER, VIM with Fireplace.
- Racket: By default, Racket comes with DrRacket, an IDE with extensive documentation of the language
- Racket: By default, Racket comes with DrRacket, an IDE with extensive documentation of the language
## Other resources:
+17 -13
View File
@@ -10,26 +10,28 @@ title: What is Sqlite?
Sqlite is a small self-contained SQL database engine written in ANSI C. It allows for creating an SQL database both on disk as a single file, and in memory.
It is commonly embedded either into an operating system or an application to store data for querying against without running a full DBMS.
Sqlite has some rather attractive features that make it a good choice for many situations, those situations include;
Sqlite has some rather attractive features that make it a good choice for many situations, those situations include;
- Storing a cache of data between application runs.
- Storing relational data for querying either on disk or in ram.
- Being used as a stable format for long term storage.
This being said, Sqlite does have a few usecases it is unsuited for;
- Being accessed directly by multiple users over the network.
- Petabyte scale data.
- Highly concurrent reads and writes.
## Standout Features
Sqlite is small, simple and consistent. They make promises to maintain backwards compatibility and have a well worked and simple codebase.
Sqlite is small, simple and consistent. They make promises to maintain backwards compatibility and have a well worked and simple codebase.
There are about 138 thousand lines of code (not counting blank lines or comments), but over 91946 thousand lines of testing code,
There are about 138 thousand lines of code (not counting blank lines or comments), but over 91946 thousand lines of testing code,
this means that it is probably one of the most tested pieces of software currently used today.
Its so well tested and trusted that its used in the Airbus A350, which means its trusted to an Aviation-grade.
Its built in limits are huge, Sqlite can support databases upto 140 terabytes in size with around a gigabyte per row.
Sqlite is entirely public domain and requires no changes to licensing for embedding, reselling, repackaging, or modifying in anyway.
It comes standard in a few programming languages like Python and PHP, and has out the box bindings for C/C++/TCL.
It comes standard in a few programming languages like Python and PHP, and has out the box bindings for C/C++/TCL.
Even the US Library of Congress uses it as a suitable long term data storage format.
Sqlite can even be extended to support JSON and other functionality.
@@ -49,13 +51,13 @@ Enter ".help" for usage hints.
sqlite>
```
Before we start lets turn on some helpers (they make output prettier)
Before we start lets turn on some helpers (they make output prettier)
```
.headers on
.mode column
```
In here we can now execute our SQL commands.
First we will create some tables
@@ -90,7 +92,8 @@ create unique index song_id_uindex
This will create a simple database with two tables. Song and Artist, there is also a relationship between a song and its artist
Lets insert some data into the database now,
```sql
```sql
INSERT INTO artist (id, name)
VALUES (1, 'Billie Eilish');
INSERT INTO artist (id, name)
@@ -110,12 +113,13 @@ INSERT INTO song (id, title, artist_id)
VALUES (5, 'Let It Be', 3);
```
Now we can start querying the database. First lets get all the songs.
Now we can start querying the database. First lets get all the songs.
```sql
select * from song;
```
We will get back
We will get back
```
sqlite> select * from song;
@@ -137,7 +141,8 @@ FROM song
WHERE (select artist_id from artist where artist_name = 'The Beatles');
```
This should return something like
This should return something like
```
sqlite> song_id artist_name title
...> ---------- ----------- ----------
@@ -151,6 +156,5 @@ Other than that this is a fully fledged SQL engine, so you can go to town trying
## Resources
* When to use SQLite: https://www.sqlite.org/whentouse.html
* Documentation: https://www.sqlite.org/docs.html
- When to use SQLite: https://www.sqlite.org/whentouse.html
- Documentation: https://www.sqlite.org/docs.html
+4 -4
View File
@@ -5,7 +5,8 @@ created_at: "2019/12/04"
title: What is Svelte?
---
## What is Svelte?
## What is Svelte?
Svelte is a front-end technology similar in use to React, Vue, Angular, and the like. However, instead of loading a framework on the client-side, Svelte wires everything up during the build step, meaning it doesn't have to interpret any additional information at runtime. However, it's still in its relative infancy.
## When should you use Svelte?
@@ -20,6 +21,7 @@ Svelte is a front-end technology similar in use to React, Vue, Angular, and the
- If you don't need interactivity/data binding.
## Examples
### Styling a component
```html
@@ -119,9 +121,7 @@ https://svelte.dev/examples#classes
</label>
{#if visible}
<p in:fly="{{ y: 200, duration: 2000 }}" out:fade>
Flies in, fades out
</p>
<p in:fly="{{ y: 200, duration: 2000 }}" out:fade>Flies in, fades out</p>
{/if}
```
+13 -4
View File
@@ -12,6 +12,7 @@ Symfony is an Open Source full stack PHP framework for web applications and a se
Symfony aims to speed up the creation and maintenance of web applications and to replace repetitive coding tasks. It's also aimed at building robust applications in an enterprise context and aims to give developers full control over the configuration.
## Why should I use Symfony
- Modularity, the core of Symfony is really small but as your needs grow you can easily install more components without having to refactor anything.
- Flexible architecture, you can customize pretty much anything ranging from folder structure to foreign libraries.
- Scalability, thanks to Symfonys architecture no matter how big your application grows you can always keep extending it without having to worry about having to refactor your whole codebase.
@@ -20,33 +21,41 @@ Symfony aims to speed up the creation and maintenance of web applications and to
- There are a great set of 3rd party libraries that can be found at https://flex.symfony.com/
- You can build anything in it that meet the needs of any business, as long as its web based
- Good documentation, everything you need to know is explained in steps in the documentation. It is filled to the brim with code snippets and explanations.
- Developing in Symfony is actually fun. Instead of writing low level code all day long you write relatively high level code without losing customizability and you will see your app progress really quickly without having to spend too much time thinking about things like folder structure, design patterns, naming conventions, etc since most of those things are taken care off already or can be found in the documentation.
- Developing in Symfony is actually fun. Instead of writing low level code all day long you write relatively high level code without losing customizability and you will see your app progress really quickly without having to spend too much time thinking about things like folder structure, design patterns, naming conventions, etc since most of those things are taken care off already or can be found in the documentation.
## How does Symfony compare to other solutions from a business perspective
Symfony is not the solution with the most raw performance, this however does not mean it is slow by any means. However for most businesses cost effectiveness is more important. For robust enterprise applications Symfony is ahead in being more cost effective to host, maintain and develop which is one of the main reasons why it is chosen over other major full stack frameworks.
## What previous experience do you need before making optimal use of Symfony
It is expected that you already know the basics of PHP, HTML, CSS and JS before starting a Symfony project. If you dont know the basics of one of the 4 mentioned above you should first learn those before checking out Symfony. Advancing without any knowledge of these basics will hinder your experience with Symfony.
## What kind of functionality can you expect from Symfony
Symfony is a framework that works via a MVC pattern (https://en.wikipedia.org/wiki/Modelviewcontroller). Which means that you can define a route and after visiting that route a function in a controller class is called that returns a response.
You write the controller functions yourself and you are free to write whatever functionality needed, as long as it returns a response which can be anything like html, json or even a file.
Some of the core components of Symfony are the: templating engine, ORM, mailer, logger, form generator, dummy data generator, PHPUnit for test, security component, yaml parser, the validator and Webpack Encore which is webpack with Symfony integration for all of your frontend dependencies. With Webpack Encore it is even possible to integrate Vue or React into your project by mounting it on a Twig template. If you decide to do this you will have to choose between using frontend routing or using Symfonys own controller routing.
## Symfony as a backend framework
It is not required to use Symfonys fullstack capabilities if you want to use Symfony. In fact, thanks to Symfonys modularity you dont even have to have the frontend components installed. If you want to make a REST API using Symfony then API Platform (https://api-platform.com/) will help you set one up really fast thanks to its good integration with Symfony. It integrates with the ORM and the validator. Everything is fully customizable if you decide to go for API Platform but you can still write your own endpoints manually if you need custom actions.
## Required tools you need to have set up before starting a Symfony project
First off, it is required that you have Composer installed. Composer is a package manager for PHP, if you have never heard about it Id strongly recommend you first study it up a bit before reading any further. You can download composer at https://getcomposer.org/download/, but you will first have to have a PHP executable before being able to install Composer. By using XAMPP you will get all the other tools you need to run a PHP web server, it comes bundled with Apache, MariaDB which is an open source fork of MySQL and PhpMyAdmin which is a database viewer and a couple of other handy tools for later. You can view what is included at their site: https://www.apachefriends.org/download.html, make sure you download the version for PHP 7.4. At the time of writing this spotlight PHP 8 is still rather new and a lot of important dependencies are not yet compatible with this version.
Now that we have the basic requirements installed for setting up any PHP project that uses dependencies we can proceed by installing the necessary tools to comfortably work with a Symfony project.
- The first thing we need to install would be the Symfony CLI (command line interface) which gives you commands that you will need when starting and running your project locally, it can be downloaded at: https://symfony.com/download.
Now that we have the basic requirements installed for setting up any PHP project that uses dependencies we can proceed by installing the necessary tools to comfortably work with a Symfony project.
- The first thing we need to install would be the Symfony CLI (command line interface) which gives you commands that you will need when starting and running your project locally, it can be downloaded at: https://symfony.com/download.
- The second most important thing that makes life really easy when working with Symfony is PhpStorm. If you are familiar with Jetbrains you might already know of this IDE. There are designated plugins for Symfony in PhpStorm that make working with Symfony really comfortable. If you are a student you should be able to get a student license for free, if not you will get a 30 days free trial and after that you can always buy it if you like it. You can download it at https://www.jetbrains.com/phpstorm/download/. It is fine to use a different IDE like VS Code, but keep in mind that PhpStorm will be used in the tutorials linked below.
## Learning resources
Official documentation: https://symfony.com/doc/current
Official learning videos: https://symfonycasts.com/screencast/symfony
If you are new to Symfony Id strongly recommend you first check out the official learning videos linked above. They will walk you through the basics of Symfony and help you set up your project. It doesnt walk you through the tools you need to have set up first on the video tutorial, but we already went through them.
If you are new to Symfony Id strongly recommend you first check out the official learning videos linked above. They will walk you through the basics of Symfony and help you set up your project. It doesnt walk you through the tools you need to have set up first on the video tutorial, but we already went through them.
+19 -6
View File
@@ -8,53 +8,64 @@ title: What is Vim?
---
## What is Vim?
Slated as the 'ubiquitous text editor', "Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient." according to its website at <https://www.vim.org>. It is a command-based text editor, so instead of menus and icons, it relies solely on keybinds and commands a user can type into it.
## Where can I get Vim?
See the official Vim website, at <https://www.vim.org/download.php>
Note: If you are using a UNIX-like operating system, you are very likely to have Vi (the precursor to Vim) installed, some GNU/Linux distributions alias vim-lite or vim.tiny to be vi. You can use Vi if youre in a pinch and cant install Vim, but it will not be as customizable as Vim
## Why should I use Vim?
Vim is a very powerful tool that can increase your productivity and efficiency when writing anything on your computer. There *is* a common misconception about Vim being difficult to use, and confusing to learn. However, Vim is surprisingly easy to pick up once you start to develop muscle memory, and even then, it is very simple to remap commands and such to other keybinds.
Vim is a very powerful tool that can increase your productivity and efficiency when writing anything on your computer. There _is_ a common misconception about Vim being difficult to use, and confusing to learn. However, Vim is surprisingly easy to pick up once you start to develop muscle memory, and even then, it is very simple to remap commands and such to other keybinds.
## Some of the benefits of using Vim include:
- As the website suggests, Vim is *very* configurable and extensible. With a wealth of extensions and very easily picked-up configuration/scripting language, it can become any type of text editor you need.
- As the website suggests, Vim is _very_ configurable and extensible. With a wealth of extensions and very easily picked-up configuration/scripting language, it can become any type of text editor you need.
- Once you start to develop muscle memory for it, you can become incredibly quick at editing, especially when compared to something like Emacs, as the default keybinds are simple, like "dd" to delete a line.
- Vim has plugins for everything from fuzzy search to code completion to prose editing, but even then, provides a lot of features you would want out of the box.
- Vim is very light and will run on basically any computer from the last 25 years
## What are Modes?
Vim is a “modal” editor, as opposed to a “non-modal” editor like Emacs, or Notepad. Vims “modes” are meant to act as finely tuned tools for interacting with documents. Some examples of modes include but are not limited to:
- Normal mode: Where you will type in your commands and do most of your keybinds
- Insert mode: The mode in which you can input text into the currently opened file
- Visual mode: Allows you to make selections in your files and perform actions on them, like running commands in normal mode, but for groups of text.
## But how do I exit this thing?!
Exiting is actually incredibly simple. First, get into normal mode, youll know youre in normal mode when the h,j,k, and l keys move the cursor around the document, you should try to use those keys instead of your arrow keys to navigate. If you are not in normal mode, simply press the escape (Esc) key on your keyboard. In normal mode, simply type `:q`.
Exiting is actually incredibly simple. First, get into normal mode, youll know youre in normal mode when the h,j,k, and l keys move the cursor around the document, you should try to use those keys instead of your arrow keys to navigate. If you are not in normal mode, simply press the escape (Esc) key on your keyboard. In normal mode, simply type `:q`.
If you want to save and exit, type`:wq`.
If you want to forcibly save and exit, type `:wq!`.
So yes, people who post *that meme* are wrong. Exiting vim is easy.
If any of this confuses you, press Control-C twice and follow what the prompt tells you.
So yes, people who post _that meme_ are wrong. Exiting vim is easy.
If any of this confuses you, press Control-C twice and follow what the prompt tells you.
## Configuring your Vim
While Vim comes with some reasonable defaults out of the box, a lot of people will no doubt find issues with them, and seek to modify/disable certain features. Luckily for those people, Vim is shockingly easy to configure.
For example, to enable line numbering, you can simply add `set number` to your vimrc
(`~/.vimrc` or `~/.config/nvim/init.vim` on UNIX-like operating systems depending on if youre using Vim or Neovim)
## Some examples of configuration options:
```viml
set numberenables the line number column
set relativenumbermakes the numbers in the number column be relative to the cursor
set shiftwidth=2 tabstop=2 expandtabuse 2-space indents with <tab>
```
If you want plugins, there's a large amount of ways to install those, too. Vim 8 comes with its own package manager as standard, but you can also any of the many community-built plugin managers out there like [vim-plug](https://github.com/junegunn/vim-plug) and [Vundle](https://github.com/VundleVim/Vundle.vim).
If you want code completion, you can try packages like the humorously-named Coc.nvim (which stands for "Conquer of Completion", and can be found at https://github.com/neoclide/coc.nvim), or the more robust and well-known (though slightly less able) [YouCompleteMe](https://github.com/ycm-core/YouCompleteMe).
## Try out vim without trying out vim
Vim has been around for such a long time that the ideas exist in a plethora of tools outside this editor. Many modern IDEs/Text Editors like VSCode and Jetbrains have vim plugins available (called VSCodeVim, IdeaVim emulate key vim features), and whilst theyre not a complete set of what vim does, it has most of the core bindings and it goes to show the sheer community support available once you learn this tool. Emacs has a vast array of EVIL (Extensible Vi Layer) plugins, including popular vim plugins like vim surround.
Forks of vim also exist that tackle certain issues like async, such as Neovim (which you can look at here: https://github.com/neovim/neovim). Even popular web browsers have vim extensions. Google Chrome has vimium, that has navigational style single-key commands, and you can exclude certain websites from using it. Firefox has vimperator, and Safari has Vimari. Certain apps have vim style bindings like the feedly RSS app and Todoist on google chrome with the todoist-shortcuts extension (https://github.com/mgsloan/todoist-shortcuts).
@@ -62,6 +73,7 @@ Forks of vim also exist that tackle certain issues like async, such as Neovim (w
In fact, if you use Neovim, some editors even allow you to embed it into them, running your own configuration & using your customizations. For example, the VSCode extension “Neo Vim”.
## Resources
- Vim's built-in vimtutor is great for learning the basics, which you can access by calling `:vimtutor` from within the editor.
- https://github.com/kevinSuttle/learn-vim
- https://www.youtube.com/channel/UC8ENHE5xdFSwx71u3fDH5Xw (high energy vim enthusiast who does a ton of tutorial videos for it)
@@ -71,5 +83,6 @@ In fact, if you use Neovim, some editors even allow you to embed it into them, r
- https://vim-adventures.com/quiz/ (this is a test to see if you know vim well to cleanup this board in the least keystrokes possible)
## Paid Resources
- Modern Vim: https://pragprog.com/titles/modvim/
- Vim Adventures: https://vim-adventures.com/
- Vim Adventures: https://vim-adventures.com/
+14 -11
View File
@@ -7,30 +7,32 @@ title: What is WSL?
## What is WSL?
A lot of people shy away from developing on Windows under the misconception that its a terrible environment to develop on, instead, dual booting Windows and Linux, or even switching over to Linux entirely!
Well, WSL is here to change that.
A lot of people shy away from developing on Windows under the misconception that its a terrible environment to develop on, instead, dual booting Windows and Linux, or even switching over to Linux entirely!
Well, WSL is here to change that.
Windows Subsystem For Linux, or simply, WSL is a compatibility layer for running Linux executables directly on Windows 10. WSL is aimed at enabling you to run Bash and core Linux command line tools on Windows. WSL does not yet support GUI applications but it's currently WIP at the time of writing this! https://devblogs.microsoft.com/commandline/whats-new-in-the-windows-subsystem-for-linux-september-2020/#gui-apps
## How is WSL different from a Virtual Machine?
By this point you might be thinking that WSL is basically a virtual machine, and Ive seen a lot of people think the same thing when I see it being discussed but WSL and a VM are very different.
By this point you might be thinking that WSL is basically a virtual machine, and Ive seen a lot of people think the same thing when I see it being discussed but WSL and a VM are very different.
A VM is isolated, slow to boot and consumes more of your precious resources. Unlike a VM, WSL also integrates well with Windows, meaning you can use your Windows tools alongside Linux
- https://docs.microsoft.com/en-us/windows/wsl/faq#why-would-i-use-wsl-rather-than-linux-in-a-vm-
## What is the difference between WSL1 and WSL2?
WSL1 is the older version of WSL. It essentially just allows you to run Linux applications on Windows 10 *as a new Windows process*. WSL2 on the other hand allows for a far greater integration as it has a Microsoft Linux kernel which allows you to use a larger set of commands which wouldn't have been possible on WSL1.
WSL1 is the older version of WSL. It essentially just allows you to run Linux applications on Windows 10 _as a new Windows process_. WSL2 on the other hand allows for a far greater integration as it has a Microsoft Linux kernel which allows you to use a larger set of commands which wouldn't have been possible on WSL1.
WSL2 uses a Linux kernel built by Microsoft based on the latest stable branch of the Linux kernel with special modifications to facilitate running on Windows while keeping in mind size and performance. The kernel is open source if you want to take a look: https://github.com/microsoft/WSL2-Linux-Kernel
Generally, it is recommended that you use WSL2 rather than WSL1 but in some cases you'll be better off using WSL1 over WSL2. You can read more about which one you should use here: https://docs.microsoft.com/en-us/windows/wsl/compare-versions#exceptions-for-using-wsl-1-rather-than-wsl-2
If you're interested in the underlying technology, Microsoft's DevBlogs is a good place to start: https://devblogs.microsoft.com/commandline/a-deep-dive-into-how-wsl-allows-windows-to-access-linux-files/
## Cool! How do I install this?
WSL is really very easy to install! Follow the steps in Microsofts official documentation and you'll be done installing this in a couple of minutes (note the minimum requirements for running WSL2, i.e. version number and build number).
WSL is really very easy to install! Follow the steps in Microsofts official documentation and you'll be done installing this in a couple of minutes (note the minimum requirements for running WSL2, i.e. version number and build number).
- https://docs.microsoft.com/en-us/windows/wsl/install-win10
There are multiple distributions available on the Microsoft Store including but not limited to some versions of Ubuntu, Debian and Kali Linux.
If you want to work with a Linux distribution not already on the Microsoft Store, follow this link: https://docs.microsoft.com/en-us/windows/wsl/use-custom-distro. You can also build your own Linux distro: https://docs.microsoft.com/en-us/windows/wsl/build-custom-distro
Now that you are done with installing WSL, its time to start working with it! The best part of WSL is that you can use it just like you would use and work with a regular Linux command-line. It uses the same commands as Linux and it works pretty damn well.
There are multiple distributions available on the Microsoft Store including but not limited to some versions of Ubuntu, Debian and Kali Linux.
If you want to work with a Linux distribution not already on the Microsoft Store, follow this link: https://docs.microsoft.com/en-us/windows/wsl/use-custom-distro. You can also build your own Linux distro: https://docs.microsoft.com/en-us/windows/wsl/build-custom-distro
Now that you are done with installing WSL, its time to start working with it! The best part of WSL is that you can use it just like you would use and work with a regular Linux command-line. It uses the same commands as Linux and it works pretty damn well.
## Working with WSL
@@ -54,8 +56,9 @@ If you use network applications and want to access a Linux network app from Wind
Since WSL installs a brand new filesystem separate from Windows' NTFS, you will need to install your CLI apps like git on both Windows and your WSL distro(s) if you want to use it in both places.
**Note:** if you want a cleaner and more customizable UI than PowerShell's or WSLs (or CMD, if you use that) default terminal emulator, I recommend getting Windows Terminal from Microsoft Store: <https://aka.ms/terminal>
### Bonus Bonus Bonus - Linux GUI apps on WSL**
Remember how I said WSL does not support Linux GUI apps before? Well, I *might* have forgotten to add the word "officially" because there is a way to run Linux GUI apps on WSL. (Note that the steps below are for WSL2, not WSL1).
### Bonus Bonus Bonus - Linux GUI apps on WSL\*\*
Remember how I said WSL does not support Linux GUI apps before? Well, I _might_ have forgotten to add the word "officially" because there is a way to run Linux GUI apps on WSL. (Note that the steps below are for WSL2, not WSL1).
Text guide: <https://medium.com/@dhanar.santika/installing-wsl-with-gui-using-vcxsrv-6f307e96fac0>
Video guide: <https://www.youtube.com/watch?v=4SZXbl9KVsw>
@@ -72,4 +75,4 @@ Thanks for reading and happy programming ahead :slight_smile:.
- Microsoft DevBlogs: <https://devblogs.microsoft.com/commandline/>
- WSL FAQ: <https://docs.microsoft.com/en-us/windows/wsl/faq>
- WSL2 FAQ: <https://docs.microsoft.com/en-us/windows/wsl/wsl2-faq>
- Discussions/issues related to WSL: <https://github.com/microsoft/WSL>
- Discussions/issues related to WSL: <https://github.com/microsoft/WSL>
+5 -1
View File
@@ -6,13 +6,17 @@ title: What is Zsh?
---
## What is Zsh?
Zsh, or Z Shell, is a popular alternative shell that extends the most common one, bash. It supports history enhancements, path expansion, environment variable expansion, improved tab completion, improved globbing (searching files), and hundreds more. Zsh has too many features to list here. For a developer, zsh can save tons of time while using a terminal window.
## When should I use Zsh?
If you use a terminal often, zsh can be extremely helpful. The multitude of utilities built into zsh by default alongside being able to add plugins allows anyone to customise zsh to their personal needs.
## When shouldn't I use Zsh?
For developers who you switch between/across multiple computers, setting up Zsh on each machine multiple times can be time-consuming, and thus leading to inconsistent behaviour over multiple machines with some using Zsh, and others using a different shell. If you don't work often with the terminal, installing Zsh may not be necessary.
## Special Features
Zsh has many features and community-made extensions that make it an extremely attractive shell for users. Among extensions, Oh My ZSH is by far the most popular, with hundreds of plugins and themes to extend the functionality and improve the look of Zsh. Oh My ZSH has even inspired similar frameworks for bash, such as Oh My Bash, and Bash It, but with much less robust community support. Other integrations also offer automatic suggestions, mouse support, plugin management, and more.
Zsh has many features and community-made extensions that make it an extremely attractive shell for users. Among extensions, Oh My ZSH is by far the most popular, with hundreds of plugins and themes to extend the functionality and improve the look of Zsh. Oh My ZSH has even inspired similar frameworks for bash, such as Oh My Bash, and Bash It, but with much less robust community support. Other integrations also offer automatic suggestions, mouse support, plugin management, and more.