Fast/efficient approach:
-- execute("UPDATE posts SET comments_count = (SELECT count(1) FROM comments WHERE comments.post_id = posts.id)")
-> 1.3197s
Slow/naïve approach:
class Pageviews < ActiveRecord::Base | |
#google analytics api shenanigans | |
require 'google/api_client' | |
require 'date' | |
include ReportingHelper | |
def self.getviews post | |
client, analytics, parameters = ReportingHelper.initclient | |
parameters = { |
require 'parallel' | |
require 'thread' | |
# The asset preloader is designed to precompute and cache all precompilable | |
# assets in parallel to avoid doing it in serial on the first request. As of | |
# Sprockets 3, all assets on the precompile list (i.e. config.assets.precompile) | |
# are compiled on the first request whether the current page has asked for them | |
# or not. Obviously such behavior can mean a very slow initial request (we were | |
# seeing load times on the order of 10-11 minutes). By preloading, or warming the | |
# sprockets cache, initial page load times can be reduced to ~15 seconds (with |
-- show running queries (pre 9.2) | |
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(query_start, clock_timestamp()), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
VCR.configure do |c| | |
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes' | |
c.hook_into :webmock | |
c.ignore_localhost = true | |
c.default_cassette_options = { record: :new_episodes } | |
c.allow_http_connections_when_no_cassette = false | |
c.configure_rspec_metadata! | |
c.ignore_hosts 'codeclimate.com' |
Fast/efficient approach:
-- execute("UPDATE posts SET comments_count = (SELECT count(1) FROM comments WHERE comments.post_id = posts.id)")
-> 1.3197s
Slow/naïve approach:
before_filter: allow_cors_requests | |
def allow_cors | |
headers["Access-Control-Allow-Origin"] = "*" | |
headers["Access-Control-Allow-Methods"] = %w{GET POST PUT DELETE}.join(",") | |
headers["Access-Control-Allow-Headers"] = %w{Origin Accept Content-Type X-Requested-With X-CSRF-Token}.join(",") | |
head(:ok) if request.request_method == "OPTIONS" | |
# or, render text: '' | |
# if that's more your style | |
end |
OK, Let's begin. Hello, Everybody. | |
My name is Narihiro Nakamura. | |
Today, I'm talking about "Parallel worlds of CRuby's GC". | |
I'm very happy now, because I'm meeting attendee in rubyconf. | |
And, one of my dreams is to talk in rubyconf. | |
So, I'm very happy and exciting. | |
Today is my first presentation in English. | |
My English is not good. |
# Ubuntu 18.04 and various Docker images such as openjdk:9-jdk throw exceptions when | |
# Java applications use SSL and HTTPS, because Java 9 changed a file format, if you | |
# create that file from scratch, like Debian / Ubuntu do. | |
# | |
# Before applying, run your application with the Java command line parameter | |
# java -Djavax.net.ssl.trustStorePassword=changeit ... | |
# to verify that this workaround is relevant to your particular issue. | |
# | |
# The parameter by itself can be used as a workaround, as well. |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |