Skip to content

Instantly share code, notes, and snippets.

Video Summary

This video is a technical presentation on concurrency and multithreading, focusing on advanced students preparing for capstone projects or job interviews. Here's a concise summary:

  1. Introduction and Purpose:

    • The talk is aimed at advanced students or those preparing for job interviews due to the relevance of concurrency and multithreading in these contexts.
    • All students are welcome to join and ask questions.
  2. Key Takeaways:

  • Understanding the differences between processes and threads.
# app/models/current.rb
class Current < ActiveSupport::CurrentAttributes
attribute :account, :user
attribute :request_id, :user_agent, :ip_address
resets { Time.zone = nil }
def user=(user)
super
self.account = user.account
# app/models/current.rb
class Current < ActiveSupport::CurrentAttributes
attribute :request_id
end
#####################################################
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
before_action :set_request_id
# First, define a Current class that inherits from ActiveSupport::CurrentAttributes
class Current < ActiveSupport::CurrentAttributes
attribute :foo
end
# Set the value
Current.foo = "bar"
# Retrieve the value
puts Current.foo # Output: bar
<div id="traffic-chart" class="c3" style="max-height: 100px; position: relative;">
<svg style="overflow: hidden;" width="600" height="100">
<defs>
<clipPath id="c3-1684282110701-clip">
<rect width="575" height="88"></rect>
</clipPath>
<clipPath id="c3-1684282110701-clip-xaxis">
<rect x="-31" y="-20" width="637" height="28"></rect>
</clipPath>
<clipPath id="c3-1684282110701-clip-yaxis">
<div id="traffic-chart" class="c3" style="max-height: 100px; position: relative;">
<svg style="overflow: hidden;" width="600" height="100">
<defs>
<clipPath id="c3-1684281192096-clip">
<rect width="575" height="88"></rect>
</clipPath>
<clipPath id="c3-1684281192096-clip-xaxis">
<rect x="-31" y="-20" width="637" height="28"></rect>
</clipPath>
<clipPath id="c3-1684281192096-clip-yaxis">
sports = %w{ football soccer basketball baseball volleyball }
case sports.sample
when 'football' then puts "touchdown"
when 'soccer' then puts "goal"
when 'basketball' then puts "basket"
when 'baseball' then puts "run"
when "volleyball" then puts "point"
end
sports = %w{ football soccer basketball baseball volleyball }
case sports.sample
when 'football'
puts "touchdown"
when 'soccer'
puts "goal"
when 'basketball'
puts "basket"
when 'baseball'
sports = %w{ football soccer basketball baseball volleyball }
game = sports.sample
if game == 'football'
puts "touchdown"
elsif game == 'soccer'
puts "goal"
elsif game == 'basketball'
puts "basket"
if @cancelling_party.role == 'tutor'
desc = "Refund for Cancelled Appointment | Cancelled by TUTOR at #{DateTime.now.strftime('%l:%M %p on %-m-%-d-%Y')} | Tutor: #{@tutor.full_name} | Student: #{@student.full_name} | Appointment ID: #{@appt.id}"
Processor::Stripe.new.issue_refund(@stripe_charge_id, @refund_amount, desc)
refund_status = "Appointment was succesfully cancelled and a refund to the student was initiated. Please be sure to account for a withdrawal of $#{display_full_price(@refund_amount)} from your bank account if you have already received the funds."
else
# cancelled by Student, so appt must be more than 24 hrs away to recieve refund
hours_before_appt = ((@appt.start_time.to_time - Time.now) / 1.hour)
if hours_before_appt >= 24
desc = "Refund for Cancelled Appointment | Cancelled by STUDENT at #{DateTime.now.strftime('%l:%M %p on %-m-%-d-%Y')} | Tutor: #{@tutor.full_name} | Student: #{@student.full_name} | Appointment ID: #{@appt.id}"
Processor::Stripe.new.issue_refund(@stripe_