A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.
posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord
#!/bin/bash | |
sudo apt-get -y install python-software-properties | |
sudo add-apt-repository ppa:keithw/mosh | |
sudo apt-get update | |
sudo apt-get -y install mosh | |
mkdir -p .config/nvim | |
curl -L https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage > /tmp/nvim.appimage | |
sudo mv /tmp/nvim.appimage /usr/bin/nvim | |
chmod +x /usr/bin/nvim | |
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \ |
set nocompatible | |
set exrc | |
set showbreak=>\ \ \ | |
" set rtp+=~/.vim/bundle/Vundle.vim/ | |
set rtp+=/usr/local/opt/fzf | |
call plug#begin('~/.vim/plugged') |
I hereby claim:
To claim this, I am signing this object:
lines = File.readlines('Gemfile.lock').grep(/rubocop/i) | |
pattern = /rubocop \((.*?)\)/ | |
act_rubocop = lines.find{ |e| e =~ pattern } | |
rubocop_version = act_rubocop[pattern, 1] | |
installed_ones = {} | |
abort("Failed to install rubocop: #{rubocop_version}") unless system("gem install rubocop -v #{rubocop_version}") | |
lines.reject{|e| e == act_rubocop}.reject{|e| e =~ /rubocop \(/}.select{|e| e.index('(')}.each do |other| | |
gem_name, version = other.split(/\s+/).reject(&:empty?) |
This gist will collect all issues we solved with Rails 5.2 and Webpacker
# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
This list is based on aliases_spec.rb.
You can see also Module: RSpec::Matchers API.
matcher | aliased to | description |
---|---|---|
a_truthy_value | be_truthy | a truthy value |
a_falsey_value | be_falsey | a falsey value |
be_falsy | be_falsey | be falsy |
a_falsy_value | be_falsey | a falsy value |
wget https://storage.googleapis.com/golang/go1.10.1.linux-armv6l.tar.gz | |
sudo tar -C /usr/local -xvf go1.10.1.linux-armv6l.tar.gz | |
cat >> ~/.bashrc << 'EOF' | |
export GOPATH=$HOME/go | |
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin | |
EOF | |
source ~/.bashrc |
require 'aws/s3' # gem name is 'aws-sdk' | |
class BucketSyncService | |
attr_reader :from_bucket, :to_bucket, :logger | |
attr_accessor :debug | |
DEFAULT_ACL = :public_read | |
# from_credentials and to_credentials are both hashes with these keys: | |
# * :aws_access_key_id |
defmodule MyApp.Auth do | |
import Comeonin.Bcrypt, only: [checkpw: 2, dummy_checkpw: 0] | |
alias MyApp.Accounts.User | |
alias MyApp.Repo | |
def login(conn, user) do | |
conn | |
|> Guardian.Plug.sign_in(user) | |
end |