Skip to content

Instantly share code, notes, and snippets.

@sathlan
Last active August 29, 2015 14:06
Show Gist options
  • Save sathlan/640ae675b186947e1579 to your computer and use it in GitHub Desktop.
Save sathlan/640ae675b186947e1579 to your computer and use it in GitHub Desktop.
def lookup(self, key_name, **kwargs):
if self._bucket_dict and key_name in self._bucket_dict:
value = Bucket._bucket[self.name][key_name]
k = Key(self)
prefix = '/'
if not value.startswith('/'):
prefix = ''
suffix = '/'
if not value.endwith('/'):
suffix = ''
k.name = (prefix +
"/".join(key_name.strip("/").split("/")[0:3]) +
suffix)
k.size = len(value)
return k
#!/opt/chef/embedded/bin/ruby
require 'mysql'
require 'optparse'
options = {:localhost => '127.0.0.1'}
OptionParser.new do |opts|
opts.on("-l", "Use localhost instead of 127.0.0.1") do |l|
options[:localhost] = 'localhost'
end
end.parse!
connection = ::Mysql.init
connection.options(::Mysql::OPT_PROTOCOL, 1)
connection = ::Mysql.connect(
options[:localhost],
'test_user',
'user_passwd',
nil,
3306,
nil
)
connection.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment