Picking the right architecture = Picking the right battles + Managing trade-offs
- Clarify and agree on the scope of the system
- User cases (description of sequences of events that, taken together, lead to a system doing something useful)
- Who is going to use it?
- How are they going to use it?
I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
Введение
Начать стоит отсюда. Не пугайтесь то, что это книга по незнакомой OS, эти термины практически везде одинаковые и здесь они изложены в понятной для начинающих форме.
http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_started/s1_procs.html
Прочесть нужно треть главы до подраздела "Starting a process", если С не пугает, читайте полностью. После прочтения вы будете понимать, что такое process, thread, mutex, priorites, semaphores, scheduler, contex-switch, kernel states.
Ruby
This file contains 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
module ActiveSupport | |
class TimeZone | |
module Google | |
API = 'https://maps.googleapis.com/maps/api/timezone/json'.freeze | |
def from_coordinates(lat, lng) | |
params = { | |
location: "#{lat},#{lng}", | |
timestamp: Time.now.to_i, | |
sensor: false | |
} |
This file contains 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
# I'm no benchmark guru. Just did a bunch of: | |
$ time ruby <filename> | |
# Note: This is just an 80mb XML file with 38,000 nodes. | |
ox_dom.rb 4.56s user 0.78s system 93% cpu 5.714 total (550mb) | |
ox_dom.rb 4.58s user 0.79s system 87% cpu 6.126 total (550mb) | |
ox_dom.rb 4.60s user 0.80s system 87% cpu 6.140 total (550mb) | |
nokigiri_dom.rb 11.75s user 1.02s system 94% cpu 13.518 total (895mb) | |
nokigiri_dom.rb 11.36s user 1.02s system 93% cpu 13.211 total (895mb) |
This file contains 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
☁ code ruby sax_parsers.rb | |
Rehearsal -------------------------------------------- | |
ox 0.800000 0.020000 0.820000 ( 0.820952) | |
nokogiri 2.110000 0.020000 2.130000 ( 2.144550) | |
----------------------------------- total: 2.950000sec | |
user system total real | |
ox 0.790000 0.010000 0.800000 ( 0.808858) | |
nokogiri 2.080000 0.030000 2.110000 ( 2.239248) |
This file contains 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
class TicketsController < ApplicationController | |
def show | |
tickets = params[:tickets].split(",") | |
ticket_data = tickets.map do |ticket| | |
parallel { Faraday.get("http://tickets.local/#{ticket}") } | |
end | |
render json: { tickets: ticket_data.map(&:result) } | |
end |
This file contains 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
# ElasticSearch Service | |
description "ElasticSearch" | |
start on (net-device-up | |
and local-filesystems | |
and runlevel [2345]) | |
stop on runlevel [016] |
This file contains 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_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..' | |
rails_env = ENV['RAILS_ENV'] || 'development' | |
resque_config = YAML.load_file(rails_root + '/config/resque.yml') | |
Resque.redis = resque_config[rails_env] | |
#secure the admin view of resque | |
Resque::Server.use(Rack::Auth::Basic) do |user, password| | |
password == "secret" | |
end |
NewerOlder