Skip to content

Instantly share code, notes, and snippets.

View RobBikmansurov's full-sized avatar
🏀
I enjoy playing basketball and running

RobBikmansurov RobBikmansurov

🏀
I enjoy playing basketball and running
View GitHub Profile
@RobBikmansurov
RobBikmansurov / curl.md
Created October 21, 2021 13:03 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@RobBikmansurov
RobBikmansurov / BootstrapToRails6.md
Created October 24, 2020 05:37 — forked from nachozt/BootstrapToRails6.md
Bootstrap to Rails 6 with webpacker

Step 1:

Add bootstrap and its dependencies:

yarn add bootstrap jquery popper.js

Step 2:

in config/webpack/environment.js add the following:

@RobBikmansurov
RobBikmansurov / index.md
Created August 4, 2020 15:07 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@RobBikmansurov
RobBikmansurov / media-queries
Last active August 4, 2020 16:55
css media query
// in 2020 actual $sizes: ("xs":320px, "sm":576px, "md":768px, "lg":992px, "xl":1200px);
/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {...}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {...}
/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {...}
@RobBikmansurov
RobBikmansurov / Dockerfile
Created November 1, 2019 05:26
Dockerfie for Rails app
# Dockerfile
# /path/to/your/app/Dockerfile
# docker-compose up
FROM ruby:2.6.3-slim-stretch
RUN apt-get update && apt-get install -y \
curl \
build-essential \
freetds-dev freetds-bin \
@RobBikmansurov
RobBikmansurov / docker-compose.yml
Last active November 1, 2019 05:27
docker-compose.yml for Rails and PostgreSQL
# docker-compose.yml
# docker-compose build
# docker-compose run web bundle install
# docker-compose run web rake db:create
# docker-compose run web rake db:setup
# docker-compose up
# docker-compose down
version: '3'
services:
@RobBikmansurov
RobBikmansurov / gist:c456524d00099ba14a25b6ac24c4a9d9
Created December 1, 2017 13:16 — forked from alex-zige/gist:5795358
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
@RobBikmansurov
RobBikmansurov / association.md
Created April 7, 2017 17:25 — forked from AlxGolubev/association.md
Способ загрузки ассоциаций при использовании find_by_sql

При выполнении сложных запросов, часто бывает необходимо выполнить предзагрузку данных об ассоциациях какой либо модели. Обычно сложные запросы выполняються через find_by_sql, например

Post.find_by_sql "SELECT p.name, c.author FROM posts p, comments c WHERE p.id = c.post_id"
> [#<Post:0x36bff9c @attributes={"title"=>"Ruby Meetup", "first_name"=>"Quentin"}>, ...]

Чтобы при вывзове ассоциаций объектов избежать проблемы с select(n+1) запросами в Rails существует eager-loading, например:

@RobBikmansurov
RobBikmansurov / rspec_model_testing_template.rb
Created November 10, 2016 11:15 — forked from PWSdelta/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems: