Skip to content

Instantly share code, notes, and snippets.

View Maccauhuru's full-sized avatar
🎯
Learning Everyday

Simba Mupfukudzwa Maccauhuru

🎯
Learning Everyday
  • Software Developer at Clear Technologies
  • Dallas
View GitHub Profile
@Maccauhuru
Maccauhuru / django_crash_course.MD
Created November 5, 2019 02:21 — forked from bradtraversy/django_crash_course.MD
Commands for Django 2.x Crash Course

Django Crash Course Commands

# Install pipenv
pip install pipenv
# Create Venv
pipenv shell
@Maccauhuru
Maccauhuru / rethinkdb_cheat_sheet.MD
Created July 1, 2019 05:01 — forked from bradtraversy/rethinkdb_cheat_sheet.MD
RethinkDB Query Cheat Sheet

RethinkDB Cheat Sheet

Create database

r.dbCreate('mydb')

List databases

@Maccauhuru
Maccauhuru / script.js
Last active April 8, 2019 02:00
Object Example Laptop
const myLaptopObject = {
name : "Dell",
color : "black",
weight : 3.75,
working : true,
start : function (){
//function (i.e method) to power up device goes here
},
increaseVolume : function (){
//function(i.e method) to increase volume goes here
@Maccauhuru
Maccauhuru / script.js
Last active March 4, 2019 04:04
Function Generator Example 2
//Create a generator function to display some popular JS frameworks/libraries
function* displayFrameworks(){
const javascriptFrameworks = ['Angular','React','Vue'];
for(let i=0;i < javascriptFrameworks.length;i++){
yield javascriptFrameworks[i];
}
}
const listFW = displayFrameworks(); // Generator { }
@Maccauhuru
Maccauhuru / script.js
Last active March 4, 2019 02:18
Function Generator Example 1
//create a new generator function called takeOff
function* takeOff(){
yield "Three";
yield "Two";
yield "One";
yield "Space Craft taking off....."
}
//assign takeOff to a funtion expression named countDown
const countDown = takeOff();
@Maccauhuru
Maccauhuru / script.js
Last active February 27, 2019 03:32
Getters & Setters Example 3
class ProductCost {
constructor(item,quantity,price) {
this.item = item;
this.quantity = quantity;
this.price = price;
}
//getter
get cost() {
return this.calcCost();
}
@Maccauhuru
Maccauhuru / script.js
Last active February 27, 2019 02:15
Getters & Setters Example 2
const movie = {
name : "The Godfather",
year : 1972,
director: 'Francis Ford Coppola',
imdb_Rating: 9.2,
set actors(name) {
this.cast.push(name);
},
cast: [],
get movieDetails(){
@Maccauhuru
Maccauhuru / script.js
Created February 27, 2019 01:32
Getters & Setters Example 1
const movie = {
name : "The Godfather",
year : 1972,
director: 'Francis Ford Coppola',
imdb_Rating: 9.2,
get movieDetails(){
return `
The movie : '${this.name}' was directed by ${this.director} and released in the year ${this.year}.
It has a very high IMDB Rating of ${this.imdb_Rating} / 10.
`
@Maccauhuru
Maccauhuru / script.js
Last active February 26, 2019 14:27
ES6 Classes Example
//define Book as an object constructor function
class Book {
constructor(name,author,price){
this.name = name;
this.author = author;
this.price = price;
}
getBookCost(){
return `The book ${this.name} was written by ${this.author} and costs $${this.price}`;
}
@Maccauhuru
Maccauhuru / script.js
Created February 11, 2019 01:11
Object Method ES5
//define Book as an object constructor function
function Book(name,author) {
this.name = name;
this.author = author;
}
//add getBookDetails method to object prototype
Book.prototype.getBookDetails = function (){
return `The book ${this.name} was written by ${this.author}`;
}