Skip to content

Instantly share code, notes, and snippets.

# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@davidhooey
davidhooey / oracle_stmt_utils.rb
Created March 26, 2014 13:56
Oracle utilities for stmt_to_sqlid, stmt_to_hash and sqlid_to_hash.
require 'digest'
module OracleStmtUtils
def stmt_to_sqlid(stmt)
d1, d2, msb, lsb = Digest::MD5.digest(stmt + "\x00").unpack('IIII')
sqln = msb * (2 ** 32) + lsb
stop = Math.log(sqln, Math::E) / Math.log(32, Math::E) + 1
sqlid = String.new
alphabet = '0123456789abcdfghjkmnpqrstuvwxyz'
@davidhooey
davidhooey / oracle_lock_mon.sql
Created April 8, 2014 16:00
SQL*Plus command file to log transaction locks.
Rem oracle_lock_mon.sql
Rem
Rem NAME
Rem oracle_lock_mon.sql
Rem
Rem DESCRIPTION
Rem SQL*Plus command file to log transaction locks.
Rem This script is based on the
Rem /rdbms/admin/utllockt.sql script.
Rem
@davidhooey
davidhooey / bdd.rb
Created April 16, 2014 13:49 — forked from adkron/bdd.rb
class Fifo
EmptyError = Class.new(Exception)
Node = Struct.new(:value, :next)
attr_accessor :size, :top
private :size=, :top=
def initialize
self.size = 0
@davidhooey
davidhooey / sql_server_delete_duplicate_rows.sql
Last active August 29, 2015 14:02
Remove duplicate rows in SQL Server.
delete from tableName
where %%physloc%% not in
(
select
max(%%physloc%%)
from
tableName
group by
column1,
column2,
@davidhooey
davidhooey / tiny_png.rb
Created August 11, 2014 14:50
Compress PNGs using the TinyPNG service.
require "net/https"
require "uri"
# Ensure we have two parameters.
if ARGV.length != 2
puts "Usage: #{$0} input_directory output_directory"
exit 1
end
key = "PLACE_TINY_PNG_KEY_HERE"
@davidhooey
davidhooey / oracle_wait_events_for_sql_id_within_time_period.sql
Created September 24, 2014 15:31
Oracle Wait Events for SQL_ID within Specific Time Frame
-- V$ACTIVE_SESSION_HISTORY
select
event,
sum(time_waited) time_waited
from
v$active_session_history
where
sql_id = 'SQL_ID'
and
sample_time between
@davidhooey
davidhooey / oracle_awrrpt_sql.sql
Last active August 29, 2015 14:06
Oracle Generate AWR Report Through SQL
-- Find the dbid, instance_number and begin and end snap_id to be used.
select
snap_id,
dbid,
instance_number,
begin_interval_time,
end_interval_time
from
@davidhooey
davidhooey / oracle_awrsqrpt_sql.sql
Created September 24, 2014 15:40
Oracle Generate AWR SQL Report Through SQL
-- Find the dbid, instance_number and begin and end snap_id to be used.
select
snap_id,
dbid,
instance_number,
begin_interval_time,
end_interval_time
from
dba_hist_snapshot
@davidhooey
davidhooey / oracle_which_sql_caused_wait_event.sql
Created September 24, 2014 15:42
Oracle Which SQL_ID Caused A Particular Wait Event
select
event,
sql_id,
snap_id,
dbid,
instance_number,
sample_time,
session_id,
session_serial#,
user_id,