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
@alexshagov
alexshagov / examples.rb
Created April 3, 2020 07:10
RSpec basics examples
# homework.rb
class Homework
attr_reader :title, :content, :completed
def initialize(title:, content:)
@title = title
@content = content
@completed = false
end
@alexshagov
alexshagov / app.rb
Created March 24, 2020 21:30
Archive creator OOP draft
### lib/user_input.rb
class UserInput
class InvalidUserInput < StandardError; end
def initialize(input)
@input = input
end
def to_s
@alexshagov
alexshagov / script.rb
Created March 19, 2020 17:49
Archive creator
# frozen_string_literal: true
# CLI tool, accepts user input;
# Saves as txt file
# archives that txt file
require 'pry'
require 'zip'
USER_INPUT_FILENAME = 'user_input.txt'
@alexshagov
alexshagov / .envrc
Created July 30, 2019 13:40
Project-specific NVM using direnv
nvmrc=~/.nvm/nvm.sh
if [ -e $nvmrc ]; then
source $nvmrc
nvm use
fi
PATH_add node_modules/.bin
@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
version: '3'
services:
db:
image: postgres
volumes:
- db-data:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
- POSTGRES_USER=username
@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"

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 / 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
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