Skip to content

Instantly share code, notes, and snippets.

View Nathan-Nesbitt's full-sized avatar

Nathan Nathan-Nesbitt

View GitHub Profile
@Nathan-Nesbitt
Nathan-Nesbitt / gist:ba242c6fccc09375609206d6691714c8
Created April 29, 2016 03:15
Verifying that +nathan_nesbitt is my blockchain ID. https://onename.com/nathan_nesbitt
Verifying that +nathan_nesbitt is my blockchain ID. https://onename.com/nathan_nesbitt
@Nathan-Nesbitt
Nathan-Nesbitt / Cassandra_HowTo_WSL.md
Created January 29, 2020 23:02
Cassandra Setup on WSL

Cassandra Setup

What is this?

Originally the idea was to implement a blogging website using Cassandra, but the requirements changed so we changed to MySQL. I didn't want to loose my notes, and I thought it would be useful to share.

Installing Apache Cassandra

To try something new, this was created using the NOSQL database: Apache Cassandra. The following steps will outline how to install the requirements and package for Apache Cassandra. There were a lot of traps, so I hope someone enjoys the walkthrough.

Working with Cassandra

Handling multiple tables

Since Cassandra is NoSQL we cannot assume consistancy accross tables (we may have the same value in n tables). Therefore, we need to use batch statements which are precreated queries that run accross multiple tables. An example of a batch statement is:

BEGIN BATCH
 INSERT INTO userpage_posts (username, datestamp) VALUES ('user1', '2020-01-01');
@Nathan-Nesbitt
Nathan-Nesbitt / External.html
Last active May 7, 2020 16:59
External Scripts Example
<!DOCTYPE html>
<html lang="en">
<body>
<script src="External.js"></script>
</body>
</html>
@Nathan-Nesbitt
Nathan-Nesbitt / Embedded.html
Created May 7, 2020 17:01
Embedded JavaScript Example
<!DOCTYPE html>
<html lang="en">
<body>
<script>
// Your JS code can go here! //
</script>
</body>
</html>
@Nathan-Nesbitt
Nathan-Nesbitt / SimpleVariable.js
Created May 7, 2020 17:31
Simple Example of a Variable
var greeting = "Hello World!";
console.log(greeting);
@Nathan-Nesbitt
Nathan-Nesbitt / ReassignVariable.js
Created May 7, 2020 17:59
Reassigning A Variable
var greeting = "Hello World!";
console.log(greeting);
// Reassigns the variable //
greeting = "Goodbye!"
console.log(greeting);
@Nathan-Nesbitt
Nathan-Nesbitt / Constants.js
Created May 7, 2020 18:19
Constant Variables Example
// Creates a constant variable //
const myConstant = 10;
// Tries to reassign the variable but will
// throw TypeError: invalid assignment to const `myVariable'
myConstant = 11;
// Prints 10 //
console.log(myConstant);
@Nathan-Nesbitt
Nathan-Nesbitt / NeedConstant.js
Created May 7, 2020 18:22
Example of Need of Constant
// Assume this creates a connection to a DB //
var myDatabaseConnection = new CreateConnectionToDatabase();
// Oops we accidentally overwrote the database connection //
myDatabaseConnection = 10;
// This would throw an error saying WTF?! how do I run this?
myDatabaseConnection.query("SELECT * FROM school");
@Nathan-Nesbitt
Nathan-Nesbitt / BlockScopeVariables.js
Created May 7, 2020 18:27
Example of Block Scoped Variables
// Create variable for only the outer block //
let i = 22;
// Create and loop over inner block variable //
for(let i = 0; i < 10; i++) {
console.log(i);
}
// Print outer block variable //
console.log(i);