Skip to content

Instantly share code, notes, and snippets.

@pquimo
pquimo / gist:1049635
Created June 27, 2011 19:40
simple Oracle 11 stored function
CREATE OR REPLACE FUNCTION weekStartingFriday(dayval IN DATE)
RETURN DATE IS
adjustment NUMBER;
BEGIN
adjustment := TO_NUMBER(TO_CHAR(dayval, 'D'));
IF (adjustment >= 6) THEN
adjustment := adjustment - 6;
ELSE
adjustment := adjustment + 1;
END IF;
@pquimo
pquimo / find_chars.rb
Last active September 3, 2021 23:35
ruby code to detect non-ascii characters in files
index = 0
str.each_char do |char|
index += 1
unless char.ascii_only?
puts "char at #{index} == ***#{char.inspect}***"
puts str.slice(index - 10, 20)
end
end
@pquimo
pquimo / gist:1438933
Created December 6, 2011 16:55
create clean git repo from svn trunk
git svn clone --no-metadata -A users.txt svn+ssh://your.repohost.com/svnroot/repo_name/trunk new_git_repo
-- sample users.txt file
gbobinski = George Bobinski <george@bobinksi.com>
fthomas = Frank Thomas <frankthomas@supermail.com>
@pquimo
pquimo / gist:2589890
Last active February 27, 2018 23:26
kinesis keyboard config

net result: http://www.keyboard-layout-editor.com/#/layouts/a3e0e4ed3ba8062b1cfcf454436477f2

the red keys are ones I never press, the orange ones rarely press enable key remapping by pressing Progrm + F12, then sequences of keys: press they key you want it to be first, then the key you will press to get that

general setting

  • reset everything: Progrm + Shift + F2
  • turn off key clicks: Progrm + backslash (right side)

bare minimum needed even with Karabiner full remap

@pquimo
pquimo / gist:4158077
Created November 28, 2012 00:07
mac osx: uninstall all ruby gems
sudo gem list | cut -d" " -f1 | xargs sudo gem uninstall -aIx
@pquimo
pquimo / gist:4544613
Last active December 11, 2015 04:19
approximate ruby equivalent of C++ local object destructors to guarantee cleanup
def has_return
puts "start of has_return"
return
puts "unreachable code in has_return"
ensure
puts "cleanup from has_return method"
end
def has_exception
puts "start of has_exception"
@pquimo
pquimo / gist:5135035
Last active December 14, 2015 19:09
using RubyTapas episode 070 "break" as inspiration, try an on-the-fly version of the technique... which unfortunately doesn't work...
names = Proc.new do |&blk|
blk.call("Ylva")
blk.call("Brighid")
end
names.call do |name|
puts name
end
@pquimo
pquimo / gist:5135096
Created March 11, 2013 15:36
same as this gist, https://gist.github.com/pquimo/5135035, except using an array instead
names = []
names << "Ylva"
names << "Brighid"
names.each do |name|
puts name
end
@pquimo
pquimo / gist:3fd3c9709ce3419f3d3c
Last active August 29, 2015 14:04
mysql 5.6 passwordless login

create one:

  • mysql_config_editor set --login-path=nameofnewloginthing --host=somehost --user=someuser --password

use it:

  • mysql --login-path=nameofnewloginthing
@pquimo
pquimo / gist:6328a274ee4ddb0dc53a2f4b358d95e3
Last active January 4, 2018 02:52
kinesis advantage v2

net result: http://www.keyboard-layout-editor.com/#/layouts/a3e0e4ed3ba8062b1cfcf454436477f2

the red keys are ones I never press, the orange ones rarely press enable key remapping by pressing Progrm + F12, then sequences of keys: press they key you want it to be first, then the key you will press to get that

version 2 transition notes

the mac/windows mode seems to be more significant now. at least different. I'll figure out Windows later, but for now, it looks like it's a good rule to switch mac mode (Program + F5) immediately, and never switch out.

power user mode

To activate Power User Mode, press and hold the Program Key and the Shift Key, and then tap the Escape Key. Important Note: If you accidentally tap Esc before pressing Shift, you will generate a Status Report. All four LED indicator lights will flash four times to indicate Power User Mode has been activated, and two times to indicate when it has been deactivated. Note: When Power User Mode is active, a new line on the Status Report wil