Skip to content

Instantly share code, notes, and snippets.

@sudoremo
sudoremo / navigate
Created September 16, 2019 16:20
Allows navigating between macOS windows (using hammerspoon) and tmux
if [ "$#" -ne 1 ]; then
echo "Usage: $0 left|right|top|bottom|previous"
echo ""
echo "e.g.: $0 left"
exit 99
fi
DIRECTION=$1
if [ "$DIRECTION" == "left" ]; then
# This is a workaround for the rails issue described in
# https://github.com/rails/rails/issues/17368. If you use this,
# make sure you understand its code and what it does and what it
# doesn't.
#
# See below for an example.
# lib/lazy_ids.rb (i.e.)
module LazyIds
extend ActiveSupport::Concern
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies....
Using concurrent-ruby 1.0.5
Using minitest 5.11.3
Using thread_safe 0.3.6
Using arel 9.0.0
Using ruby-plsql 0.6.0
Using coderay 1.1.2
Using ffi 1.9.23
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies....
Using concurrent-ruby 1.0.5
Using minitest 5.11.3
Using thread_safe 0.3.6
Using arel 8.0.0
Using ruby-plsql 0.6.0
Using coderay 1.1.2
Using ffi 1.9.23
# frozen_string_literal: true
# This file attempts to reproduce issue #1720 of the enhanced adapter
# (https://github.com/rsim/oracle-enhanced). See issue comments for instructions
# on how to use this file.
# CONFIGURATION
DB_CONFIG = {
adapter: :mysql2,
# frozen_string_literal: true
# This file attempts to reproduce issue #1720 of the enhanced adapter
# (https://github.com/rsim/oracle-enhanced). See issue comments for instructions
# on how to use this file.
# CONFIGURATION
DB_CONFIG = {
adapter: :oracle_enhanced,
@sudoremo
sudoremo / oracle_enhanced_1678.rb
Created March 22, 2018 13:19
This file attempts to reproduce the issues #920, #1070 and #1678 of the oracle enhanced adapter (https://github.com/rsim/oracle-enhanced)
# frozen_string_literal: true
# This file attempts to reproduce the issues #920, #1070 and #1678 of the oracle
# enhanced adapter (https://github.com/rsim/oracle-enhanced). To use it:
#
# 1) Make sure that ojdbc(6|7|9).jar is in your $PATH
# 2) Set the constant DB_CONFIG to your database credentials
# (use a fresh database as it may delete some tables)
# 3) Run this script via "jruby oracle_enhanced_1678.rb"
INFO: Stopping service Catalina
May 23, 2017 2:41:47 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: A web application registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
May 23, 2017 2:41:47 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [oracle.jdbc.driver.BlockSource.ThreadedCachingBlockSource.BlockReleaser] but has failed to stop it. This is very likely to create a memory leak.
May 23, 2017 2:41:47 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [Ruby-0-JIT-3] but has failed to stop it. This is very likely to create a memory leak.
May 23, 2017 2:41:47 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: A web application created a ThreadLocal
INFO: Stopping service Catalina
May 23, 2017 2:41:47 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: A web application registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
May 23, 2017 2:41:47 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [oracle.jdbc.driver.BlockSource.ThreadedCachingBlockSource.BlockReleaser] but has failed to stop it. This is very likely to create a memory leak.
May 23, 2017 2:41:47 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [Ruby-0-JIT-3] but has failed to stop it. This is very likely to create a memory leak.
May 23, 2017 2:41:47 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: A web application created a ThreadLocal
@sudoremo
sudoremo / return_safe_yield.rb
Last active December 12, 2016 13:48
Calling procs or lambdas can be dangerous when they contain a `return` statement. This mini-library deals with this issue in two different ways.
module ReturnSafeYield
class UnexpectedReturnException < StandardError; end
# Yields the given block and raises a `UnexpectedReturnException` exception if
# the block contained a `return` statement. Thus it is safe to assume that
# yielding a block in this way never jumps out of your surrounding routine.
#
# Note that you cannot pass a block using `safe_yield do`, as it does not make
# sense to check for `return` statements in code controlled by the caller
# itself.