Skip to content

Instantly share code, notes, and snippets.

View shmdt's full-sized avatar
💭
🇺🇦

Kovalenko Anton shmdt

💭
🇺🇦
View GitHub Profile
@shmdt
shmdt / Encryptable
Last active November 7, 2019 10:11
module Encryptable
def encrypt(key)
crypt.encrypt_and_sign(key)
end
def decrypt(key)
crypt.decrypt_and_verify(key)
end
private
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@shmdt
shmdt / cloudSettings
Last active January 19, 2020 19:00 — forked from SabretWoW/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…
{"lastUpload":"2020-01-19T18:59:50.579Z","extensionVersion":"v3.4.3"}
@shmdt
shmdt / gist:8df223441838a5d60521e2caa79d4bb1
Created February 3, 2019 18:33 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@shmdt
shmdt / cucumber-rails.md
Created January 31, 2019 09:39 — forked from stepheneyer/cucumber-rails.md
BDD testing using Cucumber, Capybara, and Rails

#Cucumber and Capybara - Behavior Driven Development

##Overview

Cucumber allows software developers to describe how software should behave in plain text. The text is written in a business-readable, domain-specific language. This allows non-programmers to write specific feature requests that can be turned into automated tests that drive development of the project.

Capybara is the largest rodent known to man.

@shmdt
shmdt / server.py
Created January 2, 2019 08:13
simple server
python -m SimpleHTTPServer 5000
# Thank you, Benjamin Oakes
# http://www.benjaminoakes.com/2013/09/13/ruby-simple-http-server-minimalist-rake/
@shmdt
shmdt / terminal-git-branch-name.md
Created November 28, 2018 13:52 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Mac)

Add Git Branch Name to Terminal Prompt (Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@shmdt
shmdt / place_with_recaptcha.html.erb
Created November 21, 2018 08:17
setup recaptcha-v3 with rails
<%= from_for(@your_instance) do |f| %>
<%= button_to 'submit', '', { class: 'btn', onclick: "reCaptcha('your_action')" } %>
<%= f.submit 'hide this btn', class: 'hidden', id: 'submit_this_form' %>
<% end %>
<script src="https://www.google.com/recaptcha/api.js?render=<%= ENV['RECAPTCHA_SITE_KEY'] %>"></script>
<script>
function reCaptcha(action) {
event.preventDefault();
grecaptcha.ready(function () {
@shmdt
shmdt / certbot_webroot_flow.txt
Last active September 14, 2018 14:02
certbot webroot flow
mkdir path/to/frontend
mkdir path/to/backend
add to /etc/nginx/sites-enabled/frontend
server {
location ~ /.well-known {
allow all;
default_type "text/plain";
root path/to/frontend;
@shmdt
shmdt / rails-jsonb-queries
Created April 11, 2018 06:57 — 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")