Last active
August 29, 2015 14:06
-
-
Save sathlan/640ae675b186947e1579 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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