Skip to content

Instantly share code, notes, and snippets.

@dolzenko
dolzenko / gist:bdea634728ea3372c6f2823f4a30ca96
Created December 22, 2023 09:26 — forked from cbartlett/gist:2093abd42296ddd51775
Print Ruby Exception Hierarchy
exceptions = []
tree = {}
ObjectSpace.each_object(Class) do |cls|
next unless cls.ancestors.include? Exception
next if exceptions.include? cls
next if cls.superclass == SystemCallError # avoid dumping Errno's
exceptions << cls
cls.ancestors.delete_if {|e| [Object, Kernel].include? e }.reverse.inject(tree) {|memo,cls| memo[cls] ||= {}}
end
@yahonda
yahonda / ruby31onrails.md
Last active March 22, 2024 03:57
Ruby 3.1 on Rails

Ruby 3.1 on Rails

Actions required to use Ruby 3.1.0 with Rails

Rails 7.0.Z

  • Rails 7.0.1 is compatible with Ruby 3.1.0.
  • Rails 7.0.1 addes net-smtp, net-imap and net-pop gems as Action Mailbox and Action Mailer dependency, you do not need to add them explicitly in your application Gemfile anymore.
  • thor 1.2.1 has been released. You will not see DidYouMean::SPELL_CHECKERS.merge deprecate warnings anymore.

Rails 6.1.Z

  • Use Rails 6.1.5 to support database.yml with aliases and secrets.yml with aliases.
@etozzato
etozzato / puma.rb
Last active January 28, 2024 20:12
A section of config/puma.rb that will automatically generate a self-signed X509 certificate and provide https in development
if Rails.env.development?
FileUtils.mkdir_p(Rails.root.join('config', 'certs'))
key_path = Rails.root.join('config', 'certs', 'development.key')
crt_path = Rails.root.join('config', 'certs', 'development.crt')
unless File.exist?(key_path) && File.exist?(crt_path)
def cert_domain
'localhost' # Setting[:cookie_domain] || 'localhost'
end
@vncsna
vncsna / bash_strict_mode.md
Created June 6, 2021 01:59 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@drmalex07
drmalex07 / README-tomcat-as-systemd-service.md
Last active March 21, 2024 21:34
An example configuration for Tomcat as systemd service. #tomcat #systemd #systemd.service

README

Let Tomcat is download and installed under /opt/tomcat. Also, let tomcat be a non-provileged user under which the server will be running.

We assume that we keep server's binaries under /opt/tomcat and we will create a server instance named foo under /var/tomcat/ (carrying its own conf, logs, webapps, work, lib directories). See also https://dzone.com/articles/running-multiple-tomcat.

Create a template service unit file at /etc/systemd/system/tomcat@.service:

@nordineb
nordineb / README.md
Created October 11, 2017 14:42
userPrincipalName(UPN) Vs samAccountName

userPrincipalName(UPN) Vs samAccountName

The samAccountName is the User Logon Name in Pre-Windows 2000 (this does not mean samAccountName is not being used as Logon Name in modern windows systems). The userPrincipalName is a new way of User Logon Name from Windows 2000 and later versions. user Name part can be different for the same user like DomainName\testUser and userTest@DomainName.Com.

SamAccountName

  • The samAccountName attribute is the user logon name used to support clients and servers from a previous version of Windows ( Pre-Windows 2000).
  • The user logon name format is : DomainName\testUser.
  • The samAccountName must be unique among all security principal objects within the domain.
  • The samAccountName should be less than 20 characters.
  • Query for the new name against the domain to verify that the samAccountName is unique in the domain.
@oseiskar
oseiskar / swagger-yaml-to-html.py
Last active February 21, 2024 16:43
Converts Swagger YAML to a static HTML document (needs: pip install PyYAML)
#!/usr/bin/python
#
# Copyright 2017 Otto Seiskari
# Licensed under the Apache License, Version 2.0.
# See http://www.apache.org/licenses/LICENSE-2.0 for the full text.
#
# This file is based on
# https://github.com/swagger-api/swagger-ui/blob/4f1772f6544699bc748299bd65f7ae2112777abc/dist/index.html
# (Copyright 2017 SmartBear Software, Licensed under Apache 2.0)
#
@isapir
isapir / jvmdump.bat
Last active June 2, 2023 06:53
Dump Threads and Heap for a JVM that runs as Service
:: if the service is run in Session 0 then open a console for that session and run it from there
:: e.g. %PsExec% -s -h -d -i 0 cmd.exe
:: set the paths for your environment
set PsExec=C:\Apps\SysInternals\PsExec.exe
set JAVA_HOME=C:\Apps\Java\jdk1.8.0_121
set DUMP_DIR=C:\temp
@echo off
@kaspth
kaspth / upgrade_encrypted_secrets.rb
Last active December 6, 2022 12:23
A script to update encrypted secrets to use improved encryption.
# Download this to your Rails app directory and run with:
# bin/rails runner upgrade_encrypted_secrets.rb
# Everything below here is private API and not something your app should use.
Rails::Secrets.singleton_class.prepend Module.new {
def decrypt(data)
cipher = OpenSSL::Cipher.new("aes-256-cbc").decrypt
cipher.key = key
cipher.update(data) << cipher.final
end