Skip to content

Instantly share code, notes, and snippets.

@fabrizioc1
fabrizioc1 / outlook_out_of_office.rb
Created February 28, 2012 19:12
Automating Outlook Out Of Office
##
## This script uses OLE automation to set the out of office message at a given date
##
require 'win32ole'
outlook = WIN32OLE.new('MAPI.Session')
outlook.Logon 'Outlook'
puts "Out of Office = #{outlook.OutOfOffice}"
outlook.OutOfOffice = true
outlook.Logoff
@fabrizioc1
fabrizioc1 / cachespec_example1.xml
Created April 1, 2012 00:01
Cache Invalidation Blog Post - Example 1
<cache-id>
<component id="" type="pathinfo">
<required>true</required>
<value>/ProductDisplay</value>
</component>
<component id="storeId" type="parameter">
<value>10151</value>
<required>true</required>
</component>
<component id="catalogId" type="parameter">
@fabrizioc1
fabrizioc1 / wc-server.xml
Created April 23, 2012 23:20
WCS cXML Message Adapter
<HttpAdapter
deviceFormatId="-10000"
deviceFormatType="XmlHttp"
deviceFormatTypeId="-10000"
enabled="true"
factoryClassname="com.ibm.commerce.programadapter.HttpProgramAdapterImpl" name="XML/HTTP">
<ProgramAdapter>
<SessionContext class="com.ibm.commerce.messaging.programadapter.security.CredentialsSpecifiedProgramAdapterSessionContextImpl">
<SessionContextConfig/>
</SessionContext>
@fabrizioc1
fabrizioc1 / jruby_windows_color.txt
Created May 22, 2012 23:23
Getting colored output for Cucumber + JRuby + Windows 7 (64 bit) using ansicon.exe
Steps:
1. Download "https://github.com/downloads/adoxa/ansicon/ansi150.zip"
2. Copy the files under the "x64" directory to somewhere in your path, for example "c:\windows\system32"
3. Download "https://github.com/downloads/adoxa/ansicon/ansi6432.zip"
4. Copy the files under the "x64" directory to somewhere in your path, use the same location as step #2
This should overwrite ANSI32.DLL and ansicon.exe
5. Install ansicon by typing "ansicon -I" at a command prompt
@fabrizioc1
fabrizioc1 / IE_cucumber.md
Created June 9, 2012 02:03
Run Cucumber with Internet Explorer 9, JRuby, and Windows 7 (64-bit)
  1. Enable protected mode on all security zones

    1.1. Click on the "Start" button

    1.2. Go to "Control Panel"

    1.3. Select "View by: Large Icons"

    1.4. Click on "Internet Options"

@fabrizioc1
fabrizioc1 / get_top_n_elements.rb
Created June 19, 2012 18:14
Get top n elements from ruby array of hash values
# I have an array where each element is a hash containing a few values and a count.
result = [
{"count" => 3,"name" => "user1"},
{"count" => 10,"name" => "user2"},
{"count" => 10, "user3"},
{"count" => 2, "user4"}
]
# I can sort the array by count as follows:
@fabrizioc1
fabrizioc1 / cucumber_wcs_developer.md
Created August 4, 2012 01:04
Setting up WebSphere Commerce Developer to run Cucumber projects
  1. Maven Eclipse Plugin

1.1. Navigate in the RAD menu to the software update setup:

 Help -> Software Updates -> Available Software -> Add Site

1.2. Enter the following URL: http://m2eclipse.sonatype.org/sites/m2e-e34/

  1. Gherkin Syntax Highlighting
@fabrizioc1
fabrizioc1 / wcde_gitignore.rb
Created August 21, 2012 21:32
Create a .gitignore for WebSphere Commerce Developer
require 'find'
require 'set'
# Make sure to start in ENV['WCS_HOME']
entries = ['\.metadata/'] + Dir['*'].select{|file| File.directory?(file) }
extensions = Set.new
Find.find('.') do |path|
extensions << "*#{File.extname(path)}" unless FileTest.directory?(path)
end
@fabrizioc1
fabrizioc1 / ProxyServer.java
Created September 7, 2012 06:42
Simple Network Proxy
import java.io.*;
import java.net.*;
public class ProxyServer
{
/**
* Thread to handle a single client connection
* This way the server can handle other incoming requests
*/
public static class ClientHandler extends Thread