Skip to content

Instantly share code, notes, and snippets.

View morivitalii's full-sized avatar
👌

Mori Vitalii morivitalii

👌
View GitHub Profile
@stevepolitodesign
stevepolitodesign / example.md
Last active September 23, 2023 15:30
Testing a Generator in a Rails Engine

Testing a Generator in a Rails Engine

Testing a generator in a Rails engine can result in unwanted modifications of files in the test/dummy directory.

# lib/generators/my_engine/install_generator.rb
module MyEngine
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.expand_path("templates", __dir__)
@valyala
valyala / README.md
Last active November 4, 2025 00:19
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
@BideoWego
BideoWego / a_rails_rspec_checklist\README.md
Last active January 13, 2022 12:20
Rails Spec setup checklist, helper and support files

Rails RSpec Checklist

  • Ensure turbolinks is disabled for good measure

    • comment out gem
    • remove from javascript asset pipeline
    • remove from application layout
  • Add the following gems to Gemfile in a development, test group

    • hirb
@maxivak
maxivak / readme.md
Last active October 18, 2025 00:23
Integrating Gem/Engine and Main Rails App
@chensoren
chensoren / gist:3081968
Created July 10, 2012 08:10
ruby openssl AES encrypt and decrypt
require 'base64'
require 'digest'
require 'openssl'
module AESCrypt
def AESCrypt.encrypt(password, iv, cleardata)
cipher = OpenSSL::Cipher.new('AES-256-CBC')
cipher.encrypt # set cipher to be encryption mode
cipher.key = password