Skip to content

Instantly share code, notes, and snippets.

View olegnikitashin's full-sized avatar

Oleg Nikitashin olegnikitashin

  • Adjust
  • Berlin, Germany
View GitHub Profile
@olegnikitashin
olegnikitashin / rails_new_options_help.md
Created January 25, 2024 19:33 — forked from kirillshevch/rails_new_options_help.md
List of "rails new" options to generate a new Rails 7 application

Run rails new --help to see all of the options you can use to create a new Rails application:

Output for Rails 7+

Usage:
  rails new APP_PATH [options]

Options:
      [--skip-namespace], [--no-skip-namespace]              # Skip namespace (affects only isolated engines)
@olegnikitashin
olegnikitashin / update-golang.md
Created January 26, 2020 17:04 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@olegnikitashin
olegnikitashin / format-xml-vi.md
Created January 17, 2020 16:39 — forked from jlacar/format-xml-vi.md
Format XML in vi using xmllint

Formatting XML in vi

Using xmllint

You can format XML in vi using xmllint

:%!xmllint "%" --format

Default indentation is 2 spaces. You can change that by assigning a value to the XMLLINT_INDENT environment variable. To do that without

@olegnikitashin
olegnikitashin / HOWTO.md
Created May 5, 2019 17:48 — forked from krisleech/HOWTO.md
ActiveModel comforming Form object based on dry-type / dry-validation
require 'dry-validation'
require 'dry-struct'
require 'active_model/errors'

require_relative '../create_study'

module MyApp
  module Types
    include Dry::Types.module
@olegnikitashin
olegnikitashin / values_pointers.go
Created December 26, 2018 21:07 — forked from josephspurrier/values_pointers.go
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@olegnikitashin
olegnikitashin / spec--capybara_helpers.rb
Created November 19, 2018 14:33 — forked from seanknox/spec--capybara_helpers.rb
RSpec + Capybara + Sauce Labs + Selenium (local or remote)
module CapybaraHelpers
class << self
def local_ip
ipv4_addr_info.ip_address
end
def setup_selenium_remote
app_host ||= ENV.fetch('SELENIUM_APP_HOST', local_ip)
Capybara.server_host = app_host
Capybara.app_host = "http://#{app_host}:#{Capybara.current_session.server.port}"
@olegnikitashin
olegnikitashin / user.rb
Created November 12, 2018 14:19 — forked from harlow/user.rb
Extract a validator in Rails. Zip code validation.
# app/models/user.rb
class User < ActiveRecord::Base
validates :zip_code, presence: true, zip_code: true
end
@olegnikitashin
olegnikitashin / rails-jsonb-queries
Created October 8, 2018 15:28 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@olegnikitashin
olegnikitashin / signer.rb
Created September 18, 2018 11:31 — forked from oestrich/signer.rb
Signing Google Cloud Storage URLs
private_key = "..."
client_email = "..."
bucket = "..."
path = "..."
full_path = "/#{bucket}/#{path}"
expiration = 5.minutes.from_now.to_i
signature_string = [
"GET",
@olegnikitashin
olegnikitashin / readme.md
Created August 24, 2018 11:19 — forked from maxivak/readme.md
Integrating Gem/Engine and Main Rails App