A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.
posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord| trap("SIGINT") { exit! } | |
| total_width = `stty size`.scan(/\d+/)[1].to_i # terminal width | |
| snowflakes = {} | |
| puts "\033[2J"; # clearing output | |
| loop do | |
| snowflakes[rand(total_width)] = 0 |
| image: ruby:2.6 | |
| services: | |
| - postgres:11-alpine | |
| variables: | |
| POSTGRES_DB: myorg_test | |
| CONTAINER_IMAGE: registry.gitlab.com/myorg/myapp | |
| stages: |
| import moment from 'moment' | |
| import { Controller } from 'stimulus' | |
| const TOGGLE_BUTTON_TEMPLATE = ` | |
| <button data-target="cal-grid.toggleButton" data-action="cal-grid#toggleWidget"></button> | |
| ` | |
| const DROPDOWN_TEMPLATE = ` | |
| <div class="cal-grid--dropdown" data-target="cal-grid.dropdown"> | |
| <div> |
| module ActiveRecordExtension | |
| extend ActiveSupport::Concern | |
| module ClassMethods | |
| # Simple left join taking advantage of existing Rails & Arel code | |
| def left_joins(*args) | |
| inner_joins = self.joins(*args).arel.join_sources | |
| left_joins = inner_joins.map do |join| | |
| Arel::Nodes::OuterJoin.new(join.left, join.right) | |
| end |
| __mini_rails__ |
| #!/bin/bash | |
| # node-reinstall | |
| # credit: http://stackoverflow.com/a/11178106/2083544 | |
| ## program version | |
| VERSION="0.0.13" | |
| ## path prefix | |
| PREFIX="${PREFIX:-/usr/local}" |