This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Encapsulation (can make blueprints with functionality avaiable to them) | |
"""Abstraction (hiding away what's under the hood and only using what we need without worring about how everything is implemented) | |
(using Public and Private: we use _variable to show it's a private var) since there is no Private protection, it's more a convention saying 'please dont touch this). Same with the dunder __method__ which means DO NOT overwrite this! | |
""" | |
# Inheritance (allows new objects to take on the properties of existing objects) | |
class User(): | |
def sign_in(self): | |
print('logged in') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker-compose up | |
#docker-compose down #shuts it down | |
#inside of app directory | |
#then | |
docker ps | |
#then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See base_api examples | |
# Configure devise-jwt to get signin/signup tokens | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce #must import it first | |
my_list = [1,2,3] | |
def accumulator(acc, item): | |
print(acc, item) | |
return acc + item | |
print(reduce(accumulator, my_list, 0)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#app/controllers/relationships_controller.rb | |
class RelationshipsController < ApplicationController | |
before_action :logged_in_user | |
def create | |
user = User.find(params[:followed_id]) | |
current_user.follow(user) | |
redirect_to user | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
is_old = False | |
is_licensed = True | |
if is_old: | |
print('you are old enough to drive') | |
elif is_licensed: | |
print('you are not old enough but you have a license!') | |
else: | |
print('Nope') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
namespace :api, :defaults => { :format => :json } do | |
namespace :v1 do | |
resources :movies | |
# get 'cocktails/categories', to: 'cocktails#categories' | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// takes in and adds arrays or amounts and activities | |
function lastFridayNight(transactions) { | |
let mySum = 0; | |
for (let i=0; i < transactions.length; i++) { | |
let transaction = transactions[i]; | |
mySum += transaction.amount; | |
} | |
return mySum; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A destructor is never called directly; it is automatically called | |
* If the object is on the stack, when the function returns | |
* If on the heap, when 'delete' is used | |
Cube::~Cube(); // Custom destructor | |
- member function | |
- name of the class preceded by a tilde | |
- zero arguments and zero return type | |
*/ |