Skip to content

Instantly share code, notes, and snippets.

View alexshagov's full-sized avatar
💭
I may be slow to respond.

Alexander Shagov alexshagov

💭
I may be slow to respond.
View GitHub Profile
ActiveRecord::Schema.define(version: 20160509115901) do
create_table "posts", force: :cascade do |t|
t.string "title"
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "posts_tags", force: :cascade do |t|
@alexshagov
alexshagov / post.rb
Last active May 10, 2016 17:11
blog 2-3
class Post < ActiveRecord::Base
has_and_belongs_to_many :tags
end
class PostForm
include Virtus
include ActiveModel::Model
#Post attributes
attribute :title, String
attribute :body, String
#Tag attributes
attribute :tags, Array[Integer], default: []
@alexshagov
alexshagov / post_form.rb
Last active May 9, 2016 16:16
blog 2-4
class PostForm
include Virtus
include ActiveModel::Model
#Post attributes
attribute :post, Object
attribute :title, String
attribute :body, String
#Tag attributes
attribute :tags, String # first tag,second tag,third tag
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
# GET /posts
# GET /posts.json
def index
@posts = Post.all
end
# GET /posts/1
@alexshagov
alexshagov / psql-with-gzip-cheatsheet.sh
Created March 6, 2017 08:47 — forked from brock/psql-with-gzip-cheatsheet.sh
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

@alexshagov
alexshagov / install-universal-ctags-with-gtags-osx.md
Last active May 21, 2022 13:41
How to install GNU Global with universall ctags support on mac OS

Unfortunately, homebrew does not support --with-universal-ctags option for global (on the state of April 2018) The reason is that universal-ctags is not officially released yet.

Install universal ctags

Run brew install --HEAD universal-ctags/universal-ctags/universal-ctags (See https://github.com/universal-ctags/homebrew-universal-ctags repo)

If you're on macOS, you might have an old ctags installed with command line tools for XCode. To fix this, simply run alias ctags="brew --prefix/bin/ctags"

version: '3'
services:
db:
image: postgres
volumes:
- db-data:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
- POSTGRES_USER=username
@alexshagov
alexshagov / gtags-ruby-emacs.md
Last active June 27, 2020 08:49
How to generate gtags for Ruby project

How to generate gtags for Ruby project

generate gtags.files list consisting only from .rb files

find . -name "*.rb" > gtags.files

generate *TAGS files

gtags --gtagslabel=new-ctags