mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-09 07:56:12 +02:00
content(resources): clean up markdown files, headings & codeblocks
This commit is contained in:
@@ -132,7 +132,7 @@ To ensure that the Heroku application has been created, run the `git remote -v`
|
|||||||
repository. Should your application have been created successfully, you will see a new remote added linking to a Heroku
|
repository. Should your application have been created successfully, you will see a new remote added linking to a Heroku
|
||||||
Git remote.
|
Git remote.
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ git remote -v
|
$ git remote -v
|
||||||
heroku https://git.heroku.com/chill-ping-bot.git (fetch)
|
heroku https://git.heroku.com/chill-ping-bot.git (fetch)
|
||||||
heroku https://git.heroku.com/chill-ping-bot.git (push)
|
heroku https://git.heroku.com/chill-ping-bot.git (push)
|
||||||
@@ -147,7 +147,7 @@ As explained earlier, the `Procfile` acts as a build instruction manual for our
|
|||||||
|
|
||||||
For my sample bot, the `Procfile` looks like this:
|
For my sample bot, the `Procfile` looks like this:
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
worker: java -jar target/Bot.jar
|
worker: java -jar target/Bot.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -235,6 +235,6 @@ Here are some tips for developing with Heroku.
|
|||||||
Heroku offers a free alternative to many hosting platforms and is a perfect platform for aspiring bot developers to begin.
|
Heroku offers a free alternative to many hosting platforms and is a perfect platform for aspiring bot developers to begin.
|
||||||
|
|
||||||
More resources on hosting JVM-based applications on Heroku:
|
More resources on hosting JVM-based applications on Heroku:
|
||||||
|
|
||||||
- [Getting Started on Heroku with Java](https://devcenter.heroku.com/articles/getting-started-with-java#introduction)
|
- [Getting Started on Heroku with Java](https://devcenter.heroku.com/articles/getting-started-with-java#introduction)
|
||||||
- [Java Sample (on GitHub)](https://github.com/heroku/java-sample)
|
- [Java Sample (on GitHub)](https://github.com/heroku/java-sample)
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ And we can keep going on and on, creating more arrays inside the arrays.
|
|||||||
|
|
||||||
To create multidimensional array, you do it like a regular array but with a extra `[]` at the end.
|
To create multidimensional array, you do it like a regular array but with a extra `[]` at the end.
|
||||||
|
|
||||||
##### Method 1:
|
#### Method 1:
|
||||||
|
|
||||||
Use
|
Use
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ This will make a empty 2x3 matrix that looks like:
|
|||||||
|
|
||||||
So there are 2 arrays with 3 elements each within the array `arr`.
|
So there are 2 arrays with 3 elements each within the array `arr`.
|
||||||
|
|
||||||
##### Method 2:
|
#### Method 2:
|
||||||
|
|
||||||
Use:
|
Use:
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ This will make a 2x3 matrix with preset values instead of all 0's so it'll look
|
|||||||
{{1,2,3},{4,5,6}}
|
{{1,2,3},{4,5,6}}
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Method 3:
|
#### Method 3:
|
||||||
|
|
||||||
Combine both:
|
Combine both:
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ This will make a 2x3 matrix that looks like:
|
|||||||
{{1,2,3},{4,5,6}}
|
{{1,2,3},{4,5,6}}
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Note:
|
#### Note:
|
||||||
|
|
||||||
It is possible to go ever further, and so a declaration like `data_type array_name[A][B][C]` is possible and would add more layers to your array. So after going through one layer, you have to input the location of the next layer, and so on and so forth until you reach the deepest layer of the `{}` where you'll find the object.
|
It is possible to go ever further, and so a declaration like `data_type array_name[A][B][C]` is possible and would add more layers to your array. So after going through one layer, you have to input the location of the next layer, and so on and so forth until you reach the deepest layer of the `{}` where you'll find the object.
|
||||||
|
|
||||||
@@ -108,9 +108,9 @@ This will make an 2x3x4 matrix that looks like:
|
|||||||
{{{0,0,0,0},{0,0,0,0},{0,0,0,0}},{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}
|
{{{0,0,0,0},{0,0,0,0},{0,0,0,0}},{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}
|
||||||
```
|
```
|
||||||
|
|
||||||
### What can you do with it?
|
## What can you do with it?
|
||||||
|
|
||||||
##### Calling objects
|
#### Calling objects
|
||||||
|
|
||||||
To get the object inside, you can call for the object inside a multidimensional array by putting a integer inside the `[]`.
|
To get the object inside, you can call for the object inside a multidimensional array by putting a integer inside the `[]`.
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ This would output `2` because using array indicies, `2` is the object in positio
|
|||||||
You must put an integer in both `[]`, or else you will get an error.
|
You must put an integer in both `[]`, or else you will get an error.
|
||||||
There is no syntax to instantly view the whole array, but an easy way is to loop through the whole array and outputting it.
|
There is no syntax to instantly view the whole array, but an easy way is to loop through the whole array and outputting it.
|
||||||
|
|
||||||
##### Reassigning objects
|
#### Reassigning objects
|
||||||
|
|
||||||
Like with a regular array, you can also reassign what object is being held inside a exact position using `=`
|
Like with a regular array, you can also reassign what object is being held inside a exact position using `=`
|
||||||
So let's take for example the array made in example 2 above, which looks like:
|
So let's take for example the array made in example 2 above, which looks like:
|
||||||
@@ -142,7 +142,7 @@ This would cause the array to change to looking like:
|
|||||||
{{1,2,3},{4,1337,6}}
|
{{1,2,3},{4,1337,6}}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Restrictions
|
## Restrictions
|
||||||
|
|
||||||
1. The size is locked upon initialization. Once you make the array, its size is locked. For example, if you make a 2x3 array, and realize you need another column or row, you have to either make a new one, or change the size where you initialize it. If you want a dynamic size array, a array which you can change the size of, consider using `std::vector` instead.
|
1. The size is locked upon initialization. Once you make the array, its size is locked. For example, if you make a 2x3 array, and realize you need another column or row, you have to either make a new one, or change the size where you initialize it. If you want a dynamic size array, a array which you can change the size of, consider using `std::vector` instead.
|
||||||
2. There is no way to search except by iterating through each object in the entire array. For example, if you need to find the number `2` in:
|
2. There is no way to search except by iterating through each object in the entire array. For example, if you need to find the number `2` in:
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ This document will constantly evolve to document this everlasting war. We don't
|
|||||||
## The Past
|
## The Past
|
||||||
|
|
||||||
### The War of Xerxes & Greeks
|
### The War of Xerxes & Greeks
|
||||||
|
|
||||||
Some of the earliest accounts of hiding secrets date back to Herodotus, a legendary figure known as "the father of history". Herodotus in one of his accounts, chronicles the conflict of Persia and Xerxes, the despotic king of Persians. It was art of hiding secrets that saved Persia from falling into slavery.
|
Some of the earliest accounts of hiding secrets date back to Herodotus, a legendary figure known as "the father of history". Herodotus in one of his accounts, chronicles the conflict of Persia and Xerxes, the despotic king of Persians. It was art of hiding secrets that saved Persia from falling into slavery.
|
||||||
|
|
||||||
Greek and Persia are both known for their well running feud. This feud reached a never before seen crisis after Xerxes started construction of the new capital of his great kingdom. Gifts and tributes arrived from kings, merchants, and the likes with the sole exception of Athens and Sparta. Xerxes was extremely proud and this insolence has reached his bottom line. Xerxes started mobilizing a force and declared that he will conquer the world and Persia's boundary would be the heavens itself. He actually assembled the greatest fighting force in the history of mankind, and that too in secrecy, and was ready to launch an attack.
|
Greek and Persia are both known for their well running feud. This feud reached a never before seen crisis after Xerxes started construction of the new capital of his great kingdom. Gifts and tributes arrived from kings, merchants, and the likes with the sole exception of Athens and Sparta. Xerxes was extremely proud and this insolence has reached his bottom line. Xerxes started mobilizing a force and declared that he will conquer the world and Persia's boundary would be the heavens itself. He actually assembled the greatest fighting force in the history of mankind, and that too in secrecy, and was ready to launch an attack.
|
||||||
@@ -80,5 +81,4 @@ Unfortunately for her, Walsingham had another designation. He was England's spym
|
|||||||
|
|
||||||
Mary was soon caught, and was sent to trial. Although, they used a cipher, there belonged to an era where ciphers were constantly being weakened by advances in cryptanalysis. It stood no chance against Phellippes. There was sufficient proof, and death penalty was recommended. Elizabeth signed her death warrant. With her family motto in mind, "In my end is my beginning", she approached the block. The executioners requested her forgiveness, and she was finally released from her misery.
|
Mary was soon caught, and was sent to trial. Although, they used a cipher, there belonged to an era where ciphers were constantly being weakened by advances in cryptanalysis. It stood no chance against Phellippes. There was sufficient proof, and death penalty was recommended. Elizabeth signed her death warrant. With her family motto in mind, "In my end is my beginning", she approached the block. The executioners requested her forgiveness, and she was finally released from her misery.
|
||||||
|
|
||||||
|
|
||||||
This document is a work in progress, and will be constantly updated.
|
This document is a work in progress, and will be constantly updated.
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ title: Introduction to Cryptography
|
|||||||
- [The Codebreakers](https://www.amazon.com/Codebreakers-Comprehensive-History-Communication-Internet/dp/0684831309)
|
- [The Codebreakers](https://www.amazon.com/Codebreakers-Comprehensive-History-Communication-Internet/dp/0684831309)
|
||||||
- [Seizing the Enigma: The Race to Break the German U-Boats Codes](https://www.amazon.com/Seizing-Enigma-German-U-Boats-1939-1943/dp/0395427398)
|
- [Seizing the Enigma: The Race to Break the German U-Boats Codes](https://www.amazon.com/Seizing-Enigma-German-U-Boats-1939-1943/dp/0395427398)
|
||||||
|
|
||||||
|
|
||||||
## Books
|
## Books
|
||||||
|
|
||||||
- [Handbook of Applied Cryptography - Free](http://cacr.uwaterloo.ca/hac/)
|
- [Handbook of Applied Cryptography - Free](http://cacr.uwaterloo.ca/hac/)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
---
|
---
|
||||||
authors:
|
authors:
|
||||||
- "AstronautEVA#0331"
|
- "AstronautEVA#0331"
|
||||||
title: "What is a class?"
|
title: "Classes"
|
||||||
created_at: 2019/10/20
|
created_at: 2019/10/20
|
||||||
---
|
---
|
||||||
|
|
||||||
# What is a class?
|
## What is a class?
|
||||||
|
|
||||||
Oftentimes in programs, it is necessary to represent objects from the real world as computer data.
|
Oftentimes in programs, it is necessary to represent objects from the real world as computer data.
|
||||||
For example, if someone is writing a program that simulates a zoo, they will need to create some animals.
|
For example, if someone is writing a program that simulates a zoo, they will need to create some animals.
|
||||||
@@ -56,7 +56,7 @@ public class Animal {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Class vs Object
|
## Class vs Object
|
||||||
|
|
||||||
Remember this is only the description of what an animal is, not a specific animal. A specific animal such as Max is one instance of a class and is called an object. It has values assigned to its attributes like the name is Max and the age is 5. You can call methods on the object such as move or sleep. And there can be an infinite number of objects constructed from a class. To create objects from your class, you need something called a constructor.
|
Remember this is only the description of what an animal is, not a specific animal. A specific animal such as Max is one instance of a class and is called an object. It has values assigned to its attributes like the name is Max and the age is 5. You can call methods on the object such as move or sleep. And there can be an infinite number of objects constructed from a class. To create objects from your class, you need something called a constructor.
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
authors:
|
authors:
|
||||||
- "AstronautEVA#0331"
|
- "AstronautEVA#0331"
|
||||||
title: "What is Inheritance?"
|
title: "Inheritance"
|
||||||
created_at: 2019/10/24
|
created_at: 2019/10/24
|
||||||
recommended_reading:
|
recommended_reading:
|
||||||
- java/class
|
- java/class
|
||||||
---
|
---
|
||||||
|
|
||||||
# What is Inheritance?
|
## What is Inheritance?
|
||||||
|
|
||||||
Inheritance is the idea that when two classes have similar implementations, rather than duplicating code for each class one can obtain it from the other. Much like a human child will inherit traits from their parents, a child class will inherit data from
|
Inheritance is the idea that when two classes have similar implementations, rather than duplicating code for each class one can obtain it from the other. Much like a human child will inherit traits from their parents, a child class will inherit data from
|
||||||
its parent class.
|
its parent class.
|
||||||
@@ -123,7 +123,7 @@ public class Animal {
|
|||||||
|
|
||||||
It can be used in our subclass.
|
It can be used in our subclass.
|
||||||
|
|
||||||
```
|
```java
|
||||||
Animal myAnimal = new Animal();
|
Animal myAnimal = new Animal();
|
||||||
myAnimal.sleep(); // returns "The animal sleeps."
|
myAnimal.sleep(); // returns "The animal sleeps."
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ public class Bird extends Animal {
|
|||||||
|
|
||||||
It cannot be used in our superclass.
|
It cannot be used in our superclass.
|
||||||
|
|
||||||
```
|
```java
|
||||||
Animal myAnimal = new Animal();
|
Animal myAnimal = new Animal();
|
||||||
myAnimal.chirp(); // error, the method does not exist
|
myAnimal.chirp(); // error, the method does not exist
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ external_resources:
|
|||||||
href: https://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/
|
href: https://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/
|
||||||
---
|
---
|
||||||
|
|
||||||
## An introduction to Streams
|
|
||||||
|
|
||||||
Basically everyone, who spent a few hours coding some Java came across a situation like this:
|
Basically everyone, who spent a few hours coding some Java came across a situation like this:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@@ -30,7 +28,7 @@ Arrays.stream(intArray).forEach(n -> System.out.println(n));
|
|||||||
|
|
||||||
You just made one line out of three. But how does this work? `int[] intArray = {1,2,3,4,5};` does just declare and initialize a new array of integers. This stays the same as before, because you can use the `Arrays.stream()` method for every Array, [as it works with generic Arrays](https://www.mkyong.com/java8/java-how-to-convert-array-to-stream/). This method creates a [Stream Object](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html), that has several methods to perform operations on an array.
|
You just made one line out of three. But how does this work? `int[] intArray = {1,2,3,4,5};` does just declare and initialize a new array of integers. This stays the same as before, because you can use the `Arrays.stream()` method for every Array, [as it works with generic Arrays](https://www.mkyong.com/java8/java-how-to-convert-array-to-stream/). This method creates a [Stream Object](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html), that has several methods to perform operations on an array.
|
||||||
|
|
||||||
### Sorting
|
## Sorting
|
||||||
|
|
||||||
Now maybe you have a list instead of an array and you also want the list to get sorted before you print it. Without Streams you would first have to sort the list and then iterate through it. Way too many lines! Using Streams you can simply do:
|
Now maybe you have a list instead of an array and you also want the list to get sorted before you print it. Without Streams you would first have to sort the list and then iterate through it. Way too many lines! Using Streams you can simply do:
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ intList.stream().sorted().forEach(n -> System.out.print(n + ", "));
|
|||||||
|
|
||||||
At the end, you have again only one line, for sorting and printing every element in a list. Due to the fact that Streams mostly use Method Chaining, you could perform a bunch of operations.
|
At the end, you have again only one line, for sorting and printing every element in a list. Due to the fact that Streams mostly use Method Chaining, you could perform a bunch of operations.
|
||||||
|
|
||||||
### Filtering
|
## Filtering
|
||||||
|
|
||||||
Now you are able to print out every element of an array, a list, a stack, etc. sorted as well as unsorted. The last essential operation is, how to filter your array/list. One often has to only get specific elements of an array. Using Streams you could do it like this:
|
Now you are able to print out every element of an array, a list, a stack, etc. sorted as well as unsorted. The last essential operation is, how to filter your array/list. One often has to only get specific elements of an array. Using Streams you could do it like this:
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ completed at a later time. Much like in real life, when you create a promise, yo
|
|||||||
to fulfill that promise. However, sometimes things go wrong where you can no longer fulfill
|
to fulfill that promise. However, sometimes things go wrong where you can no longer fulfill
|
||||||
a promise you made. This is essentially the main idea behind how promises work in javascript.
|
a promise you made. This is essentially the main idea behind how promises work in javascript.
|
||||||
|
|
||||||
### Basics
|
## Basics
|
||||||
|
|
||||||
When you create a Promise or call a function that returns a Promise in Javascript, you're left
|
When you create a Promise or call a function that returns a Promise in Javascript, you're left
|
||||||
with an object that can either resolve into the actual value that you were promised, or it
|
with an object that can either resolve into the actual value that you were promised, or it
|
||||||
@@ -24,7 +24,7 @@ can reject and leave you with an error for why that promise failed.
|
|||||||
|
|
||||||
We can access these values using the `.then` and `.catch` methods on the `Promise` object respectively.
|
We can access these values using the `.then` and `.catch` methods on the `Promise` object respectively.
|
||||||
|
|
||||||
### A Simple Example
|
## A Simple Example
|
||||||
|
|
||||||
First, let's explore a bit of a made-up example. Imagine we have a promise-returning function
|
First, let's explore a bit of a made-up example. Imagine we have a promise-returning function
|
||||||
called `getMembers` that retrieves all the members in a discord server. When we execute this
|
called `getMembers` that retrieves all the members in a discord server. When we execute this
|
||||||
@@ -50,7 +50,7 @@ getMembers("The Programmers Hangout").then(members => {
|
|||||||
|
|
||||||
This way we are able to make sure that we only try to `console.log` when the `getMembers` function has resolved and ready to be used.
|
This way we are able to make sure that we only try to `console.log` when the `getMembers` function has resolved and ready to be used.
|
||||||
|
|
||||||
### Beginner Mistakes
|
## Beginner Mistakes
|
||||||
|
|
||||||
Promises are possibly the #1 most common source of confusion for beginners. In order
|
Promises are possibly the #1 most common source of confusion for beginners. In order
|
||||||
to avoid falling in pitfalls yourself, you have to remember 2 things about Javascript when
|
to avoid falling in pitfalls yourself, you have to remember 2 things about Javascript when
|
||||||
@@ -85,7 +85,7 @@ getWeather("Los Angeles").then(weather => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Real World Example
|
## Real World Example
|
||||||
|
|
||||||
Here is a real function that gets character information from the Rick and Morty API.
|
Here is a real function that gets character information from the Rick and Morty API.
|
||||||
You can try it in your browser if you want to test it out.
|
You can try it in your browser if you want to test it out.
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ external_resources:
|
|||||||
href: "https://www.freecodecamp.org/news/spread-operator-and-rest-parameter-in-javascript-es6-4416a9f47e5e/"
|
href: "https://www.freecodecamp.org/news/spread-operator-and-rest-parameter-in-javascript-es6-4416a9f47e5e/"
|
||||||
---
|
---
|
||||||
|
|
||||||
# An overview of the spread operator
|
|
||||||
|
|
||||||
Spread operator (or spread syntax) is a powerful feature in Javascript which allows you to do such things as merging or copying objects, expanding an array into function arguments and a lot more. In this post, we are going to cover most of its use-cases.
|
Spread operator (or spread syntax) is a powerful feature in Javascript which allows you to do such things as merging or copying objects, expanding an array into function arguments and a lot more. In this post, we are going to cover most of its use-cases.
|
||||||
|
|
||||||
## Copying an object
|
## Copying an object
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ created_at: "2019/10/06"
|
|||||||
title: Variables
|
title: Variables
|
||||||
---
|
---
|
||||||
|
|
||||||
## Variables
|
|
||||||
|
|
||||||
A `variable` in Javascript is a "named container" that can hold data. Variables are declared by giving them a name and a value - the `name` allows you to reference the variable throughout your program, and the `value` is the current value the variable represents.
|
A `variable` in Javascript is a "named container" that can hold data. Variables are declared by giving them a name and a value - the `name` allows you to reference the variable throughout your program, and the `value` is the current value the variable represents.
|
||||||
|
|
||||||
Variables can be defined in the following ways:
|
Variables can be defined in the following ways:
|
||||||
@@ -123,9 +121,9 @@ for(let i = 0; i < 5; i++) {
|
|||||||
console.log(i); // Error: i is undefined
|
console.log(i); // Error: i is undefined
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
let myVar = 'test';
|
let myVar = "test";
|
||||||
}
|
}
|
||||||
console.log(myVar) // Error: myVar is undefined
|
console.log(myVar); // Error: myVar is undefined
|
||||||
```
|
```
|
||||||
|
|
||||||
However, if the above code was in a function, this would not be the case. In the case of a function, the variable will be scoped to the given function, and not accessible outside it. Eg:
|
However, if the above code was in a function, this would not be the case. In the case of a function, the variable will be scoped to the given function, and not accessible outside it. Eg:
|
||||||
|
|||||||
Reference in New Issue
Block a user