NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
- name: ensure github.com is a known host | |
lineinfile: | |
dest: /root/.ssh/known_hosts | |
create: yes | |
state: present | |
line: "{{ lookup('pipe', 'ssh-keyscan -t rsa github.com') }}" | |
regexp: "^github\\.com" |
NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
For my Vietnamese wife a good karaoke setup is serious business. Problem is, I noticed that some people spend thousands of dollars on unnecessary stuff like gigantic receivers and speakers, only to end up with hiss, clipping, and clunky operation. Smart/consistent home setup should definitely fit under $1000, and that's with speakers and expensive Nvidia Shield box. You could definitely cut it to under $500 and still have a great setup. I did some research and put together a convenient setup for amazing quality at-home karaoke that isn't worth thousands, isn't a chore to operate, and passes Asian quality standards with flying colors.
How to use this setup once it's ready:
This guide assumes that you already have a TV with HDMI ARC or Optical/Coaxial audio output, and that you have WiFi at home.
def has_role?(role, object) | |
if object.has_association?(role) | |
if has_many? | |
object.roles.find(self.id) | |
else | |
object.role.id == self.id | |
end | |
else | |
self.roles.include?(role) | |
end |
defmodule EctoBatchStream do | |
import Ecto.Query, only: [from: 1, from: 2] | |
@batch_size 1000 | |
# Example: | |
# | |
# query = from u in MyApp.User, select: u.email | |
# stream = EctoBatchStream.stream(MyApp.Repo, query) | |
# stream |> Stream.take(3) |> Enum.to_list # => […] |
# config/initializers/react.rb | |
Rails.configuration.react.server_renderer = | |
Class.new(React::ServerRendering::BundleRenderer) do | |
private | |
def render_from_parts(before, main, after) | |
js_code = compose_js(before, main, after) | |
@context.eval(js_code) | |
end |
- name: ensure postgresql hstore extension is created | |
sudo: yes | |
sudo_user: postgres | |
shell: "psql {{ postgresql_database }} -c 'CREATE EXTENSION hstore;'" | |
register: psql_result | |
failed_when: > | |
psql_result.rc != 0 and ("already exists" not in psql_result.stderr) | |
changed_when: "psql_result.rc == 0" |
def plain_text_receipt # => Runtime: 5 sec, Network Timeout | |
<<-TEXT | |
Thank you for your order! | |
Product: #{name} - #{price} # => 2 DB queries | |
Tax: #{tax_amount} # => 1 DB query, 1 API call | |
Total: #{total_amount} # => 2 DB queries, 1 API call | |
TEXT | |
end | |
private |
# Rake tasks for managing git plugins with submodules. | |
# | |
# These tasks aim to make life simpler by automating all the boring work. | |
# What you get: | |
# - complete git integration (all you need to know is install, uninstall and update) | |
# - complete github integration (only use author name + plugin name) | |
# - rails plugin hooks (install.rb/uninstall.rb) are taken care of | |
# | |
# Available commands: | |
# |