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
| EventMachine.run { | |
| EventMachine::PeriodicTimer.new(60){ | |
| result = ActiveRecord::Base.connection.select_rows("show global status like 'threads_running'") # => [['threads_running', 1]] | |
| threads_running = result.try(:first).try(:at, 1) | |
| message = "#{threads_running} threads running at #{Time.now}" | |
| puts message | |
| file = File.open("#{Rails.root}/log/mysql_thread_count.log", 'a') | |
| file.puts message |
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
| Promotion.find_each(:batch_size => 10) do |p| | |
| if p.refreshing_stats? | |
| date_refresh_started_at = p.retrieve_stats_cache_info(:refreshing => false) | |
| if date_refresh_started_at | |
| threshold_time = 6.hours.ago | |
| if date_refresh_started_at < threshold_time | |
| p.done_refreshing_stats | |
| puts "Forced the completion of stats refresh for promotion #{p.id}" | |
| 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
| # Summary | |
| # ------- | |
| # If you care about performance, use `&&` or an `if` statement instead of the object.foo.try(:name) pattern. | |
| # | |
| # Like so... | |
| # object.foo.name if object.foo | |
| # OR | |
| # object.foo && object.foo.name | |
| class Object |
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
| Plan for an explosion in personal wealth | |
| By Magnus Heystek22 April 2021 12:35 | |
| The past ten years have not been a very good decade for most South African investors. Your pension and equity portfolio have not risen much over this period. | |
| In fact, it was one of the lowest average ten-year returns in many decades. If inflation and transaction costs are taken into account, then most people today have much less in real terms than they think. | |
| When the returns of the JSE over ten years are measured against the major world regions, the average returns were among the weakest in the world. | |
| And as last week's article pointed out, yields in US dollar terms were round zero. |
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
| Drayton and Mackenzie. By Alexander Starritt. Swift Press; 512 pages; £16.99 | |
| Two very different men, James and Roland, meet as young adults. Both seek success, first as management consultants, then as entrepreneurs in the field of green energy. As they navigate private pain and the turmoil of the global financial crash of 2007-09, they increasingly value their friendship. Both characters are expertly drawn in this funny, touching story. | |
| Dusk. By Robbie Arnott. Astra House; 272 pages; $26. Chatto & Windus; £16.99 | |
| A puma roams the Tasmanian highlands, killing sheep and their shepherds. Iris and Floyd, twins and social outcasts, join the hunt in hope of securing a considerable bounty. This brings them into contact with another tracker, Patrick, who is cunning and dangerous. This is a propulsive novel of survival and betrayal, enriched by arresting depictions of nature. | |
| Flashlight. By Susan Choi. Farrar, Straus and Giroux; 464 pages; $30. Jonathan Cape; £20 | |
| One night, while on holiday in Japan, ten-year-old Lou |
OlderNewer