- Install qemu
brew install qemu
- Download QEMU_EFI.fd
class AsyncMethodJob < ApplicationJob | |
queue_as :default | |
def perform(target:, method_name:, args:, queue_name: :default) | |
self.class.queue_as(queue_name) | |
# `target` could be either an instance or a class | |
target = target.constantize if target.is_a?(String) # Convert class name to class object if needed | |
target.send(method_name, *args) | |
end | |
end |
defmodule Lector.Template do | |
@moduledoc """ | |
Defines helper functions for rendering Templates. | |
What this allows is a naive re-implementation of how Phoenix handles views/templates. | |
When 'using' `Lector.Template`, files sharing the same module name as the view being used get pre-compiled | |
into named render functions. In other words, `Lector.Templates.Home` will pre-compile a `home.html.eex` file | |
in the same folder into a function of the same name (`Lector.Templates.Home.home(assigns)`), which renders | |
the template. |
defmodule Acme.Repo do | |
use Ecto.Repo, | |
otp_app: :acme, | |
adapter: Ecto.Adapters.Postgres | |
def with_prefix(prefix) do | |
module_atom = Module.concat([Acme, Repo, WithPrefix, Macro.camelize(prefix)]) | |
# We could not find a better way to see if this module already existed | |
if !Kernel.function_exported?(module_atom, :prefix, 0) do |
First install all required packages:
pkg install git-lite libtool automake autoconf curl
Set up the building blocks:
<?php | |
namespace App\Providers; | |
use Illuminate\Routing\ResponseFactory; | |
use Illuminate\Support\ServiceProvider; | |
use Illuminate\Contracts\Support\Responsable; | |
use Illuminate\Contracts\View\Factory as ViewFactoryContract; | |
use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactoryContract; |
Install rust
jail-app is name of jail.
$ jexec jail-app
$ pkg install curl
Download and install rustup
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
A memory-saving ActiveRecord setting has been used by just one application ever, according to GitHub | |
There's a common performance problem in many Rails background jobs. | |
Background jobs often do operations across large sets of data. Basically, they do silly things like User.all.each(&:send_daily_newsletter). | |
So, there's a problem with that query. In development and test environments, User.all will probably return a few rows, maybe a dozen at most. Most developers have extremely limited seed data on their local machines. | |
In production, however, User.all will probably return quite a few rows. Depending on the app you work on, maybe a few hundred thousand. | |
There's a tiiiiiny issue with a result set that returns 100,000 rows, and it's not just that the SQL query will take a long time to return. It will have irreversible effects on your Ruby app too! |
# spec/support/capybara.rb | |
require 'capybara/rails' | |
require 'capybara/rspec' | |
# port and url to webpack server | |
WEB_TEST_PORT = '5005'.freeze | |
WEB_TEST_URL = "http://localhost:#{WEB_TEST_PORT}".freeze | |
def capybara_wait_for_webpack_server | |
10.times.each do |_| |