Skip to content

Instantly share code, notes, and snippets.

View r3cha's full-sized avatar

Roman Klevtsov r3cha

  • Lisbon
View GitHub Profile
def perform(url)
return unless url
response = HTTParty.get(url)
return unless response.success?
data = JSON.parse(response.body)
return unless data['results']
data['results'].each do |test|
@r3cha
r3cha / Dockerfile
Last active September 3, 2020 10:27
One app docker image for build frontend & backend
FROM node:14-alpine as node
FROM ruby:2.7.0-alpine3.11 as build-base
COPY --from=node /usr/local/bin/node /usr/local/bin/
COPY --from=node /opt/yarn-v1.22.4 /opt/yarn-v1.22.4
RUN ln -s /usr/local/bin/node /usr/local/bin/nodejs
# Here is you can copy npm from node to build-base if you preffer use it
RUN ln -s /opt/yarn-v1.22.4/bin/yarn /usr/local/bin/yarn
@r3cha
r3cha / docker-compose.yml
Last active September 4, 2020 10:58
Fastest way to up you frontend service
version: "3.8"
volumes:
node_modules:
services:
ui:
image: node:14.8.0-alpine3.12
ports:
- 3000:8080
@r3cha
r3cha / user_jwt.rb
Last active May 27, 2020 09:23
Mongoid Rails model concern
# app/models/concerns/user_jwt.rb
module UserJwt
extend ActiveSupport::Concern
included do
include ActiveModel::SecurePassword
has_secure_password
field :email, type: String
field :phone, type: String
FROM node:current-alpine3.11 as node
FROM ruby:2.6.5-alpine3.11 as build-base
COPY --from=node /usr/local/bin/node /usr/local/bin/
COPY --from=node /opt/yarn-v1.22.0 /opt/yarn-v1.22.0
RUN ln -s /usr/local/bin/node /usr/local/bin/nodejs
RUN ln -s /opt/yarn-v1.22.0/bin/yarn /usr/local/bin/yarn
RUN ln -s /opt/yarn-v1.22.0/bin/yarnpkg /usr/local/bin/yarnpkg
@r3cha
r3cha / Gemfile
Last active April 6, 2019 16:03
Create Ruby on Rails application from bootstrap theme
# add this gems to Gemfile
gem 'bootstrap', '~> 4.3.1'
gem 'jquery-rails'
gem 'popper_js', '~> 1.14.5'
@r3cha
r3cha / create_items.rb
Last active April 6, 2019 20:54
How to generate friendly urls without overhead of friendly id and etc.
# db/migrate/create_items.rb
# if you use activerecord
class CreateItems < ActiveRecord::Migration
def change
create_table :items do |t|
t.string :title
t.string :slug
t.timestamps
end
end
@r3cha
r3cha / r-img_example
Last active April 2, 2019 09:49
place r-img tag in your html
<div class="image_area">
<r-img image-hash="hashWithImageUrls" bg-position="center">
</div>