Skip to content

Instantly share code, notes, and snippets.

View maricavor's full-sized avatar

Sergey Tsyganov maricavor

View GitHub Profile
@mrmartineau
mrmartineau / stimulus.md
Last active February 6, 2026 16:59
Stimulus cheatsheet
@sshkarupa
sshkarupa / Readme.md
Created September 13, 2017 11:00
Creating a new Rails application project with Docker

You certainly won't need anything installed other than Docker to create Ruby apps...

1: Generating the project

The idea is to mount the current folder into a temporary Ruby container using the official Ruby image from Docker Hub, then install Rails inside this temporary container, and then create the project skeleton using the rails new command.

# Start bash inside a Ruby container:
@mnishiguchi
mnishiguchi / ruby_poro.md
Last active September 24, 2024 13:05
ruby, rails - Ruby Poros, tableless models, service objects
@mbyczkowski
mbyczkowski / with_active_support.rb
Last active November 22, 2024 13:40 — forked from tonytonyjan/rails_42_with_active_support.rb
session cookie decrypter for Rails 4.2+
require 'cgi'
require 'json'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base)
cookie = CGI::unescape(cookie)
salt = 'encrypted cookie'
signed_salt = 'signed encrypted cookie'
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
secret = key_generator.generate_key(salt)[0, ActiveSupport::MessageEncryptor.key_len]
@sheharyarn
sheharyarn / api_controller.rb
Last active April 27, 2022 08:53
Render API Errors in Rails
class APIController < ApplicationController
include JSONErrors
# ...
end
@jstrassburg
jstrassburg / jetty.xml
Last active March 27, 2020 18:10
Solr Jetty Authorization
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- only the relevant addition is listed here -->
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">MySolrRealm</Set>
<Set name="config">
@wteuber
wteuber / encrypt_decrypt.rb
Last active February 2, 2026 15:13
Basic encrypt and decrypt Strings in Ruby with deterministic salt or IV, generate and store random salt and IV in production
require 'openssl'
class String
CIPHER_NAME = 'aes-256-cbc'.freeze
PBKDF_ITER = 200_000
KEY_LEN = 32 # 256 bits
SALT_CONST = "fixed-global-salt-v1".freeze
IV_SALT_CONST = "fixed-iv-salt-v1".freeze
def encrypt(password)