Skip to content

Instantly share code, notes, and snippets.

View braindeaf's full-sized avatar
🏠
Working from home

RobL braindeaf

🏠
Working from home
View GitHub Profile
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
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active May 15, 2024 20:55
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

@lucaspiller
lucaspiller / .gitlab-ci.yml
Last active April 14, 2022 09:07
Rails 5.2 + Docker + Gitlab Continuous Deployment
image: ruby:2.6
services:
- postgres:11-alpine
variables:
POSTGRES_DB: myorg_test
CONTAINER_IMAGE: registry.gitlab.com/myorg/myapp
stages:
@art-solopov
art-solopov / cal-grid.js
Last active February 26, 2022 13:39
A very simple calendar widget for Stimulus.JS
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>
@ozydingo
ozydingo / active_record_extension.rb
Last active June 16, 2021 22:47
ActiveRecord left join
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
@eikes
eikes / .__mini_rails__
Last active March 15, 2023 13:27
Single file rails app
__mini_rails__
@brock
brock / nodereinstall.sh
Last active May 13, 2024 03:24
Complete Node Reinstall. I've moved this to a repo at http://git.io/node-reinstall
#!/bin/bash
# node-reinstall
# credit: http://stackoverflow.com/a/11178106/2083544
## program version
VERSION="0.0.13"
## path prefix
PREFIX="${PREFIX:-/usr/local}"