old notes

ruby

#datastructures #tree #graph #leetcode #devstudy #ruby

Things to Remember

  • 80% planning, 20% implementation
  • Read slowly.
  • Examine assumptions and let them go. Keep an open mind.
  • Resist the urge to jump to conclusions. Resist the urge to plug in a known structure or syntax even as you're reading the question.
  • The question is only ONE way of describing the problem. What are other ways of looking at this description?

  • Abstraction first, Implementation later

  • Understand the cases of the problem as a PROBLEM not from with the limits of the syntax you keep reaching for.

  • What is the problem? What am I trying to achieve?

  • What are my cases at each step in abstracted terms?

Questions to When Debugging

  • Look at every single line and ask yourself: what am I asking the computer to do?

#ruby #rails #models #sessions #users

Dopa-Mine App

Find Ways To Integrate:

  • j.query & AJAX calls to front end
  • pull json/cvs data & represent in dashboard
  • create API endpoints for grabbing daily summary?
  • chat function –> code sockets –> maybe have it make calls to a pybot api?
  • search function –> by tags/suggestions?

Steps.0

  1. Determine Models
  2. Build Schema/DB (remember joint tables)
  3. Validate associations
  4. Create Sessions
  5. Write tests

To-Do Organized by Pages:

1. Home/Login

  • redirect users to last visited page if they have to login here
  • sessions controller: add timed logouts?

2. User Dashboard @ users#home

  • remove dashboard controller?
  • represent data in graphs: %/24 hours of each type of dopamine
  • add today's activities + hours
  • represent progress of the week

3.

TO DO: map all the routes > models > views

Models

User has_and_belongs_to_many :activities has_many :comments

rails generate model User username:string email:string password_digest:string

Followed by rails db:migrate

Activity has_and_belongs_to_many :users has_many :dopamine_points has_many :comments

DopaminePoints belongs_to :activity belongs_to :user

Comment belongs_to :commented_on, polymorphic: true belongs_to :user

Rolling back migrations:

  • using rails db:rollback STEP=3 will roll back the database migration but it will not remove the generated models nor the migration schema instructions so you will have manually alter those to reflect the true database schema required.

Object syntax notes

@user object is initialized by User.new class + method

In console: Activity.find(1)

#linux #networking #router #automation #bash #python #ruby

The suggest from my tutor was to “write an automation script that goes into my router and pulls the logs from the router logs to system logs and then scans them for any occurrences of nmap and sends the results to me in an email. Possibly filtering by priority?

To Research

Router Access

  • does my router have logs accessible
  • can my router easily transfer those logs to my system logs or do I have to manually do that?

System logs

  • where is the appropriate place to put them?

Cron job

  • set it up where?

Email server

  • can I send it directly to my thundermail client or does it have to go through gmail?

Additional Practice

  • redo this assignment using my linux machine?
  • redo in py?