This file contains 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 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 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 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 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 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 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 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 'openssl' | |
require 'yaml' | |
class Encryptor | |
def initialize(key_pass, key_size = 2048, key_name = 'rsakey.sec', cipher = OpenSSL::Cipher.new('aes-256-cbc')) | |
@key_size = key_size | |
@cipher = cipher | |
@key_name = key_name |
This file contains 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 'openssl' | |
class Encryptor | |
def initialize(key_pass, key_size = 1024, key_name = 'rsakey.sec', cipher = OpenSSL::Cipher.new('aes-256-cbc')) | |
@key_size = key_size | |
@cipher = cipher | |
@key_name = key_name | |
if( File.exists?(@key_name) ) |
This file contains 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 a convenience method that exists to determine if the window should be closed or not. | |
// There could be a lot more logic here, but for now we are just closing any window whose | |
// location property is equal to "chrome://global/content/commonDialog.xul", which is what the | |
// alert boxes that I have tested use. | |
alertClose: function (subject) { | |
if(subject.location == "chrome://global/content/commonDialog.xul") { | |
window.setTimeout(function() { subject.close(); }, 1000); | |
} | |
} |