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
| # This is kind of counter-intuitive because at first thought one wouldn't really want to have multiple | |
| # instances of a Singleton class. There is an instance however where I needed exactly this. When creating | |
| # a SOAP service the Singleton pattern works nice because you can just call the Singleton#instance method to | |
| # fetch the instance without having to manually pass the object around. The trouble comes when you want | |
| # connections to multiple SOAP endpoints. This is a test solution that I came up with to mock create multiple | |
| # instances of a Singleton class. | |
| require 'singleton' | |
| class TestA |
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 enum_flds(node = nil, path = '') | |
| root = ( node.nil? ? :publicfoldersroot : node.folder_id ) | |
| name = ( node.nil? ? '' : node.display_name ) | |
| GenericFolder.find_folders(root).each do |f| | |
| enum_flds(f, "#{path}#{(path=='/' ? '' : '/')}#{name}") | |
| end | |
| puts "Folder: #{path}#{(path=='/' ? '' : '/')}#{name}" | |
| end | |
| enum_flds |
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
| # Set some ExtendedProperties | |
| tag = {:preformatted => []} | |
| tag[:preformatted] << {:set_item_field => [ | |
| {:extended_field_uRI=>{:distinguished_property_set_id=>"PublicStrings", :property_name=>"viewpoint_tags", :property_type=>"StringArray"}}, | |
| {:message => [ | |
| {:extended_property => [ | |
| {:extended_field_uRI=>{:distinguished_property_set_id=>"PublicStrings", :property_name=>"viewpoint_tags", :property_type=>"StringArray"}}, | |
| {:values => [ {:value => {:text => 'test_a'} }, {:value => {:text => 'test_b'}}]} | |
| ]} |
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
| # I know this doesn't make much sense, but I used it as an example of working with Handsoap which is a singleton, | |
| # but I had the need for multiple, simultaneous connections. | |
| class Master | |
| @@instances = {} | |
| def self.new(host) | |
| return @@instances[host] if @@instances.has_key?(host) | |
| super |
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
| #!/usr/bin/env bash | |
| # Dan Wanek | |
| # Mon Jul 25 11:43:54 CDT 2011 | |
| # | |
| # There is a good document from Apple on how to set up Active Directory for Mac that can be found | |
| # at http://www.seminars.apple.com/contactme/pdf/L334436B_ActiveDirect_WP.pdf | |
| # Default settings | |
| COMPUTER_NAME=`hostname -s | tr "[:lower:]" "[:upper:]"` | |
| RENAME_COMPUTER=false |
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
| require 'ostruct' | |
| require 'yaml' | |
| class Configurator < OpenStruct | |
| $rc_file = "#{ENV['HOME']}/.rubyconfs/myconf.yaml" | |
| def self.read_config | |
| if(File.exists?($rc_file)) | |
| YAML.load(File.read($rc_file)) |
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
| require 'json' | |
| require 'viewpoint' | |
| include Viewpoint::EWS | |
| puts "Usage: cal_items.rb <email>" if ARGV.length == 0 | |
| email = ARGV[0] | |
| cfile="creds_test.json" | |
| creds = JSON.load(File.open(cfile,'r')) | |
| Viewpoint::EWS::EWS.endpoint = creds['endpoint'] | |
| Viewpoint::EWS::EWS.set_auth(creds['user'],creds['pass']) | |
| cal = GenericFolder.get_folder(:calendar, email) |
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
| # A script to fetch AD Users and put them into a spreadsheet | |
| # Dan Wanek <[email protected]> | |
| # 08/24/2011 22:36:00 | |
| param( | |
| [int]$limit = 20, | |
| [string]$ou = "", | |
| [string]$outFile = $(Get-Location).Path + "\LDAP_USER_RPT.xls", | |
| [switch]$verbose, | |
| [switch]$usage |
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
| require 'nokogiri' | |
| def mkxml(b, nm, bhash) | |
| b.send(nm.to_s) { | |
| bhash.each_pair do |k, v| | |
| if(v.is_a?(Hash)) | |
| mkxml(b, k, v) | |
| elsif(v.is_a?(Array)) | |
| b.send(k, v.shift, v[0].keys.first => v[0].values.first) | |
| else |
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
| class File | |
| def last_line | |
| ind = 1 | |
| loop do | |
| offset = (ind * -80) | |
| if(offset >= size) | |
| seek(0, IO::SEEK_SET) | |
| line = read | |
| line.chomp! | |
| return line.split(/\n/, -1).last |