Skip to content

Instantly share code, notes, and snippets.

View vojtad's full-sized avatar

Vojta Drbohlav vojtad

  • SlidesLive
  • Czech Republic
View GitHub Profile
@vojtad
vojtad / action_view_partial_renderer_collection_caching.rb
Last active March 22, 2019 16:33
Monkey patch ActionView::CollectionCaching#cache_collection_render included in ActionView::PartialRenderer. This helps prevent N+1 for uncached entries when rendering cached collection.
module MonkeyPatches
#
# Monkey patch ActionView::CollectionCaching#cache_collection_render included in ActionView::PartialRenderer.
# This helps prevent N+1 for uncached entries when rendering cached collection.
# This patch allows us to specify modify_uncached_collection Proc. The Proc is called with collection of uncached entries as argument. Its result should be Array. It is used as new collection for rendering.
#
# Setup:
#
# Add this line to monkey_patches.rb initializer.
# ActionView::PartialRenderer.prepend(MonkeyPatches::ActionViewPartialRendererCollectionCaching)
@alexlee-gk
alexlee-gk / configure_cuda_p70.md
Last active June 21, 2024 03:40
Use integrated graphics for display and NVIDIA GPU for CUDA on Ubuntu 14.04

This was tested on a ThinkPad P70 laptop with an Intel integrated graphics and an NVIDIA GPU:

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation Device 191b (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204GLM [Quadro M3000M] (rev a1)

A reason to use the integrated graphics for display is if installing the NVIDIA drivers causes the display to stop working properly. In my case, Ubuntu would get stuck in a login loop after installing the NVIDIA drivers. This happened regardless if I installed the drivers from the "Additional Drivers" tab in "System Settings" or the ppa:graphics-drivers/ppa in the command-line.