Skip to content

Instantly share code, notes, and snippets.

View jittdev's full-sized avatar

Subrosa Games LLC jittdev

View GitHub Profile
@jittdev
jittdev / FlushCaches1.sh
Created March 14, 2023 13:55
flush caches :: #shell
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
@jittdev
jittdev / 4PillarsOfOop1.py
Created March 14, 2023 13:55
4 Pillars of OOP :: #Python Basics
# 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')
@jittdev
jittdev / ToSpinUpAContainerWithoutNiceDockerGui1.txt
Created March 14, 2023 13:55
to spin up a container without nice Docker GUI :: #DOCKER
docker-compose up
#docker-compose down #shuts it down
#inside of app directory
#then
docker ps
#then
@jittdev
jittdev / 4ContinuingSetup1.txt
Created March 14, 2023 13:55
4 Continuing Setup :: #api - ruby backend
# See base_api examples
# Configure devise-jwt to get signin/signup tokens
@jittdev
jittdev / Reduce()1.py
Created March 14, 2023 13:55
reduce() :: #Python Advanced
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))
@jittdev
jittdev / RelationshipsControllerForFollowers1.rb
Created March 14, 2023 13:55
Relationships Controller for followers :: #Ruby / Rails
#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
@jittdev
jittdev / IfElseElif1.py
Created March 14, 2023 13:55
if else elif :: #Python Basics
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')
@jittdev
jittdev / NamespaceV11.rb
Created March 14, 2023 13:55
namespace V1 :: #api - ruby backend
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
@jittdev
jittdev / ObjectsIi:Examples1.js
Created March 14, 2023 13:55
Objects II: Examples :: #Javascript
// 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;
}
@jittdev
jittdev / Destructors1.cpp
Created March 14, 2023 13:55
Destructors :: #C++
/* 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
*/