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
| Some helpful links: | |
| http://samsaffron.com/archive/2015/03/31/debugging-memory-leaks-in-ruby | |
| sudo bundle exec rbtrace -p 27031 -e 'load "/home/mkim/heap-dump.rb"' --timeout 300 | |
| ["902df967-5e27-49d4-8f6e-254a94777337", "2d4227d5-fffd-4420-b2c6-97e54a6bc8e6", "07c07581-0272-4279-87b2-6c25359cdc1c", "3204575e-b5fd-44dc-9a89-93c1668751ac", "7ce4cbde-a381-491e-9f71-9d04cc1cb438", "8fd03e14-32b3-4160-a08b-b4ca2a44e4c4", "bf5f0ce2-c5ba-4dde-be34-69175383eb16", "90085729-3e24-4b70-8903-db3c31390473", "5f318be7-214a-4573-9684-e5f6e09e5c53", "b6707c1c-2825-4975-8fc8-cff8c654cf9b", "c57594da-3b6e-4e0b-acfd-f5c13c82def5", "64c77f61-24bb-4a89-8b0c-37da0bbf750b", "c397f5b8-41e2-44e5-9d7a-a92b414324a9", "bd78ca99-4a5d-462d-9fb8-abe1fcf76437", "fe831923-8582-4816-9402-1de7de8b48c9", "ab98b096-46b8-4edb-a0a1-1df9fc325529", "32bb06c2-fbb8-49ab-8dd2-748d9d2455b0", "2123c63e-ceb2-48b8-b167-f7e2cb652350", "2b8b6cc9-429f-4325-add5-cdf8cd321c42", "2fb6d295-ef6e-4a6e-a708-16c96b150cd3"] |
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
| # With this algorithm, we merge/contract the head into the tail | |
| # vertex, i.e., copy edges of head vertex into the tail vertex | |
| # and then delete the head vertex. | |
| adj_list = {} | |
| file = File.read('./kargerMinCut.txt');nil | |
| file.each_line do |line| | |
| line_array = line.strip.split | |
| vertex = line_array.shift | |
| adj_list[vertex.to_s] = line_array |
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
| class Lecture04 | |
| attr_accessor :graph_reverse, :explored, :number_nodes_processed, :current_source_vertex, :finishing_times, :leaders, :new_graph, :directory | |
| def initialize(dir) | |
| @directory = dir | |
| @graph_reverse = {} | |
| File.foreach(@directory) do |line| | |
| current_edge = line.strip.split.reverse.map(&:to_i) | |
| @graph_reverse[current_edge[0].to_s] = [] if @graph_reverse[current_edge[0].to_s].nil? | |
| @graph_reverse[current_edge[0].to_s] << current_edge[1] |
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
| require 'benchmark' | |
| @threads = [] | |
| Benchmark.bm(14) do |x| | |
| x.report('no-threads') do | |
| 8.times do | |
| tmp_array = [] | |
| 10_000_000.times { |n| tmp_array << n } | |
| 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
| req_body_for_patient_a = { | |
| routing: 'PatientA', | |
| filter: { | |
| term: { patient_name: 'PatientA' } | |
| } | |
| } | |
| req_body_for_patient_b = { | |
| routing: 'PatientB', | |
| filter: { |
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
| require 'benchmark' | |
| @threads = [] | |
| Benchmark.bm(14) do |x| | |
| x.report('no-threads') do | |
| 8.times do | |
| tmp_array = [] | |
| 10_000_000.times { |n| tmp_array << n } | |
| 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
| require 'faraday' | |
| require 'benchmark' | |
| @conn = Faraday.new(url: 'https://www.google.com') | |
| @threads = [] | |
| Benchmark.bm(14) do |x| | |
| x.report('no-threads') do | |
| 8.times { @conn.get } | |
| 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
| require 'json' | |
| require 'elasticsearch' | |
| client = Elasticsearch::Client.new hosts: 'http://localhost:9200' | |
| # Test that Elasticsearch is up | |
| client.info |
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
| def raw_put(path, body) | |
| conn = Faraday.new url: 'http://localhost:9200' | |
| conn.put(path) do |req| | |
| req.body = body.to_json | |
| req.headers['Content-Type'] = 'application/json' | |
| end | |
| end | |
| # Create primary index | |
| req_body = { |
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
| req_body_for_patient_a = { | |
| routing: 'PatientA', | |
| filter: { | |
| term: { patient_name: 'PatientA' } | |
| } | |
| } | |
| req_body_for_patient_b = { | |
| routing: 'PatientB', | |
| filter: { |
OlderNewer