Skip to content

Instantly share code, notes, and snippets.

View maricavor's full-sized avatar

Sergei Tsõganov maricavor

View GitHub Profile
@wteuber
wteuber / encrypt_decrypt.rb
Last active October 28, 2024 11:58
Simply encrypt and decrypt Strings in Ruby.
require 'openssl'
class String
def encrypt(key)
cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
cipher.key = Digest::SHA1.hexdigest key
s = cipher.update(self) + cipher.final
s.unpack('H*')[0].upcase
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">
@sheharyarn
sheharyarn / api_controller.rb
Last active April 27, 2022 08:53
Render API Errors in Rails
class APIController < ApplicationController
include JSONErrors
# ...
end
@mbyczkowski
mbyczkowski / with_active_support.rb
Last active September 28, 2023 03:56 — 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]
@mnishiguchi
mnishiguchi / ruby_poro.md
Last active September 24, 2024 13:05
ruby, rails - Ruby Poros, tableless models, service objects
@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:
@mrmartineau
mrmartineau / stimulus.md
Last active September 24, 2024 21:07
Stimulus cheatsheet