Search this blog ...

Friday, September 24, 2010

IP Subnetting Manual Calculation

Here is a nifty online subnetting calculator http://www.subnet-calculator.com/

And here is an excellent doc that describes how the calculation is made http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a00800a67f5.shtml

Below are some manual calculations that I performed:

The machines has an ip address 10.228.137.4, with assigned subnet mask 255.255.248.0

This IP addresses falls in the Network Class A range (1.0.0.0 - 127.255.255.255)

Thus, it has a standard network mask of 255.0.0.0

Representing 255.255.248.0 in binary :-

(n = standard network mask)

(s = subnet bits claimed)

(h = available host bits)

n   n   n   n   n   n   n   n     s   s   s   s   s   s   s   s     s   s   s   s   s   h   h   h     h   h   h   h   h   h   h   h
128 064 032 016 008 004 002 001   128 064 032 016 008 004 002 001   128 064 032 016 008 004 002 001   128 064 032 016 008 004 002 001 

             255                               255                         128+64+32+16+8 = 248

meaning 13 bits (8 + 5) are now being repurposed for subnet bits
2^13 = 8192 maximum subnets

8 standard network mask bits + 13 repurposed bits = 21 mask bits in total.

11 bits (3 + 8) remain for hosts
2^11 = 2048 ;
subtract 1 for broadcast address; subtract 1 as host ids all 0 are now allowed; = 2046 hosts per subnet

# 21 mask bits activated, 11 bits remaining for host
n   n   n   n   n   n   n   n     s   s   s   s   s   s   s   s     s   s   s   s   s   h   h   h     h   h   h   h   h   h   h   h
128 064 032 016 008 004 002 001   128 064 032 016 008 004 002 001   128 064 032 016 008 004 002 001   128 064 032 016 008 004 002 001 

# representing 10.228.137.4 as binary
0   0   0   0   1   0   1   0     1   1   1   0   0   1   0   0     1   0   0   0   1   0   0   1     0   0   0   0   0   1   0   0

# leaving the host/subnet portion unchanged, zero out the host bits
0   0   0   0   1   0   1   0     1   1   1   0   0   1   0   0     1   0   0   0   1   0   0   0     0   0   0   0   0   0   0   0
# = 10.228.136.0

# leaving the host/subnet portion unchanged, replace host bits with all 1's
0   0   0   0   1   0   1   0     1   1   1   0   0   1   0   0     1   0   0   0   1   1   1   1     1   1   1   1   1   1   1   1
# = 10.228.143.255

thus current mask 255.255.248.0 using ip 10.228.137.4 falls is in the subnet with range 10.228.136.1 through 10.228.143.254

given we have 21 mask bits (8 standard network mask bits + 13 repurposed bits) .. we could write the above subnet as...

10.228.136.0/21

Tuesday, September 21, 2010

JDeveloper 11gR1 - integrated WebLogic Server and OWSM

Documented below are the steps/tips I have employed to get JDeveloper 11g1, embedded WebLogic Server, and WSM to play nicely (on Windows).

Tip 1 - Ensure the ‘User Home Directory’ is free of whitespace.

The user home directory contains the user's preferences for Oracle JDeveloper (in the system subdirectory).

On my XP machine, the user home directory for JDeveloper gets created under the %USERPROFILE% directory.  For example “C:\Documents and Settings\Administrator\Application Data\JDeveloper

The whitespace in the directory path above I have found out can be bad news and may lead to an error such as:

java.net.URISyntaxException: Illegal character in path at index 18: file:/C:/Documents and Settings/....

To determine existing value from within Oracle JDeveloper, go to the Help menu, select About, go to Properties tab, and view the value of ide.user.dir

There are a number of different ways to override the JDeveloper user home directory; I chose to leverage the JDEV_USER_HOME environment variable, and set it to “C:\JDeveloper

You can explicitly set the home environment variable by adding the following line in the <Middleware Home>\jdeveloper\jdev\bin/jdev.boot file:
ide.user.dir = <Path to preferred user directory>

The user home directory can also be specified from the command line using this command:
jdev.exe -J-Dide.user.dir=<Path>

The home directory can also be set based on the value of an environment variable.

MW_HOME/jdeveloper/jdev/bin/jdev.boot contains an entry such as:
ide.user.dir.var = JDEV_USER_HOME, JDEV_USER_DIR

This is the default variable(s) that Oracle JDeveloper will look for at startup to determine the home directory.
You can define or add any environment variable that Oracle JDeveloper should use.

To set the value of an environment variable from Windows:

1. From Control Panel, select System, Select the Advanced tab, and then click Environment Variables.
3. In the User Variables section, click New.
4. Add JDEV_USER_HOME, or the name you chose for ide.user.dir.var, as a user variable.
5. Set the value of this variable to your home directory (for example, N:\users\jdoe), and click OK.

Tip 2 – Embedded / Integrated WebLogic Server (Re)Creation

The first time a JEE project is run/debug from JDeveloper, the integrated WebLogic Server starts and provisions a domain named “DefaultDomain”.

You can find it under the JDeveloper user home directory in the systemXXXXXX folder; for example:

C:\JDeveloper\system11.1.1.3.37.56.60\DefaultDomain

If you ever mess things up,  or want to start from fresh (reverting any changes you may have performed– including users / groups / credential store settings / deployments etc), you just just remove the DefaultDomain directory.  

1. Shutdown your IntegratedWeblogicServer (if running) and exit JDeveloper
2. Delete the systemXXXXXX/DefaultDomain directory

The next time you run a JEE application, JDeveloper will recreate a fresh DefaultDomain for you.

Alternatively, rather than waiting for a JEE application to get run, you can get JDeveloper to create the default domain straight up.
1. From the View menu, choose ApplicationServerNavigator
2. Right click on Application Servers / IntegratedWeblogicServer, select "Create Default Domain..."

The Integrated WebLogic server domain in JDeveloper is by default configured with:

adrs_template
jsf_template
jrf_template
adf_logging_fine
oracle.ucm.ridc_template
wsmpm-config-template
wsmpm-template
oracle.wc_adrs_template_11.1.1

Tip 3 – Credential Store and Keystore configuration in DefaultDomain of integrated WebLogic Server

Note, DOMAIN_HOME below refers to %JDEV_USER_HOME%\system11.1.1.3.37.56.60\DefaultDomain

The file %DOMAIN_HOME%\config\fmwconfig\jps-config.xml contains the various service provider types and actual instance/implementations of these configured for the domain.

    <serviceProviders>
        <serviceProvider type="CREDENTIAL_STORE" name="credstoressp" class="oracle.security.jps.internal.credstore.ssp.SspCredentialStoreProvider">
            <description>SecretStore-based CSF Provider</description>
        </serviceProvider>

        <serviceProvider type="KEY_STORE" name="keystore.provider" class="oracle.security.jps.internal.keystore.KeyStoreProvider">
            <description>PKI Based Keystore Provider</description>
            <property name="provider.property.name" value="owsm"/>
        </serviceProvider>

    </serviceProviders>

    <serviceInstances>
        <!-- JPS Credential Store Service Instance -->
        <serviceInstance name="credstore" provider="credstoressp" location="./">
            <description>File Based Credential Store Service Instance</description>
        </serviceInstance>

        <!-- KeyStore Service Instance -->
        <serviceInstance name="keystore" provider="keystore.provider" location="./default-keystore.jks">
            <description>Default JPS Keystore Service</description>
            <property name="keystore.type" value="JKS"/>
         <property name="keystore.csf.map" value="oracle.wsm.security"/>
            <property name="keystore.pass.csf.key" value="keystore-csf-key"/>
            <property name="keystore.sig.csf.key" value="sign-csf-key"/>
            <property name="keystore.enc.csf.key" value="enc-csf-key"/>  
        </serviceInstance>

    </serviceInstances>

    <jpsContexts default="default">
        <!-- This is the default JPS context. All the mendatory services and Login Modules must be configured in this default context -->
        <jpsContext name="default">
            <serviceInstanceRef ref="credstore"/>
            <serviceInstanceRef ref="keystore"/>
            <serviceInstanceRef ref="policystore.xml"/>
            <serviceInstanceRef ref="audit"/>
            <serviceInstanceRef ref="idstore.ldap"/>
        </jpsContext>

    </jpsContexts>

The credential store instance referenced above, is a wallet-based credential store (also referred to as a file-based credential store), and will essentially be referring to a file named cwallet.sso in the same directory as the jps-config.xml file (%DOMAIN_HOME%\config\fmwconfig)

The keystore instance referenced above is a “JKS” file-based keystore, named default-keystore.jks , and found in the same directory as the jps-config.xml file (%DOMAIN_HOME%\config\fmwconfig)

When DefaultDomain in the integrated WebLogic server is provisioned, cwallet.sso is created, whereas default-keystore.jks is not created!!

You can leverage the orapki command to get a basic listing of the cwallet.sso contents:

C:\JDeveloper\system11.1.1.3.37.56.60\DefaultDomain\config\fmwconfig>

c:\Oracle\Middleware\oracle_common\bin\orapki wallet display -wallet cwallet.sso

Oracle PKI Tool : Version 11.1.1.2.0
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Requested Certificates:
User Certificates:
Oracle Secret Store entries:
Trusted Certificates:
Subject:        OU=Class 1 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        OU=Secure Server Certification Authority,O=RSA Data Security\, Inc.,C=US
Subject:        CN=Entrust.net Secure Server Certification Authority,OU=(c) 1999 Entrust.net Limited,OU=www.entrust.net/CPS incorp. by ref. (limits liab.),O=Entrust.net,C=US
Subject:        CN=GTE CyberTrust Global Root,OU=GTE CyberTrust Solutions\, Inc.,O=GTE Corporation,C=US
Subject:        OU=Class 3 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        CN=Entrust.net Secure Server Certification Authority,OU=(c) 2000 Entrust.net Limited,OU=www.entrust.net/SSL_CPS incorp. by ref. (limits liab.),O=Entrust.net
Subject:        OU=Class 2 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        CN=Entrust.net Certification Authority (2048),OU=(c) 1999 Entrust.net Limited,OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.),O=Entrust.net

Tip 4 – Oracle WSM – SAML Policies (wss11_saml_token_with_message_protection_service_policy) / leveraging DefaultDomain of JDeveloper integrated WebLogic Server for testing

http://download.oracle.com/docs/cd/E14571_01/web.1111/b32511/setup_config.htm#BABJJBFF

Ultimately both the Web Service, and the Web Service client need their own private/public key pair.

Additionally, both client and service need to be able to verify each other's respective public certificate by traversing the certification path until a valid root CA certificate is obtained.

Note:
- the client sends its public key to the service as part of the request.
- the client must obtain the server's public certificate; It can either be published in the WSDL with latest 11g OWSM release ( http://download.oracle.com/docs/cd/E14571_01/web.1111/b32511/setup_config.htm#BABJCGBC ), or, manually added to client's keystore and referenced through recipient key alias (ClientConstants.WSS_RECIPIENT_KEY_ALIAS).
- with SAML Policy, we must use the RSA key mechanism, the SHA-1 algorithm, and AES-128 bit encryption to satisfy the policy requirements for the key.


Three Approaches for generating private/public key pair:

- Self-Signed Certificate (1)
- Signed using Oracle Demo Certificate Authority (2)
- Signed using traditional Certificate Authority (3) (such that, one whom is present in the JVM's cacerts [java keystore file])

1) A self-signed certificate is a certificate in which the "issuer" entity and actual "subject" entity are the same.
In other words, a seft-signed certificate is a certificate where the "issuer" signs his own public key with his private key.

2) Oracle Provides a Demo Certificate Authority (CertGenCA - also self-signed as all root CAs are)

$WL_HOME/server/lib/CertGenCA.der (public certificate)
$WL_HOME/server/lib/CertGenCAKey.der (private key)

keytool -printcert -file C:\Oracle\Middleware\wlserver_10.3\server\lib\CertGenCA.der

Owner: CN=CertGenCAB, OU=FOR TESTING ONLY, O=MyOrganization, L=MyTown, ST=MyState, C=US
Issuer: CN=CertGenCAB, OU=FOR TESTING ONLY, O=MyOrganization, L=MyTown, ST=MyState, C=US
Serial number: 234b5559d1fa0f3ff5c82bdfed032a87
Valid from: Fri Oct 25 01:54:45 EST 2002 until: Wed Oct 26 01:54:45 EST 2022
Certificate fingerprints:
         MD5:  A2:18:4C:E0:1C:AB:82:A7:65:86:86:03:D0:B3:D8:FE
         SHA1: F8:5D:49:A4:12:54:78:C7:BA:42:A7:14:3E:06:F5:1E:A0:D4:C6:59
         Signature algorithm name: MD5withRSA
         Version: 3
...

3) JDK 1.6 out of the box ships with support for most of the standard/traditional Certificate Authorities (similar to what you would find in the Browser - VeriSign etc).
The public certificate of the CAs can be found in the cacerts file.
Additionally, one can import their own CA in to the cacerts (keystore) file.

To view the list of CAs ...

%JAVA_HOME%\bin\keytool -list -keystore %JAVA_HOME%\jre\lib\security\cacerts -storepass "changeit" –v

Taking the following scenario:

1) Web Service deployed to an appropriate WebLogic server on some central Linux server
2) Testing a Web Service client app running from JDeveloper integrated WebLogic server on local Windows machine
3) Using the Oracle Demo Certificate Authority

the following steps would be required:


From Server Domain (where the Web Service is running)

1) source $DOMAIN_HOME/bin/setDomainEnv.sh

2) cd $DOMAIN_HOME/config/fmwconfig

3) Create service key-certificate pair signed by the demo CA cert "CertGenCA"

java utils.CertGen -certfile ServerPublicCertificate -keyfile ServerPrivateKey -keyfilepass welcome1 -cn "`hostname -f`"

4) Create service keystore with service key-certificate pair

java utils.ImportPrivateKey -keystore default-keystore.jks -storepass welcome1 -certfile ServerPublicCertificate.der -keyfile ServerPrivateKey.der -keyfilepass welcome1 -alias serverkey -keypass welcome1

5) Now add the root CA to the service keystore

keytool -importcert -file $WL_HOME/server/lib/CertGenCA.der -keystore default-keystore.jks -storepass welcome1

6) Add options to credential store (CWALLET.SSO) so as to access keys/certificates from keystore

$MW_HOME/Oracle_ECM1/common/bin/wlst.sh  (or $MW_HOME/oracle_common/common/bin/wlst.sh)

connect('weblogic','welcome1','t3://localhost:7001')
createCred(map="oracle.wsm.security", key="keystore-csf-key", user="n/a", password="welcome1")
createCred(map="oracle.wsm.security", key="sign-csf-key", user="serverkey", password="welcome1")
createCred(map="oracle.wsm.security", key="enc-csf-key", user="serverkey", password="welcome1")

Optional:
listCred(map="oracle.wsm.security", key="keystore-csf-key")
listCred(map="oracle.wsm.security", key="sign-csf-key")
listCred(map="oracle.wsm.security", key="enc-csf-key")

7) Restart

-------------------------------------------------------------------------------------------------------------------------------------

>From Client Domain - JDeveloper integrated WebLogic Server (where the client is running)

1) SET DOMAIN_HOME=%JDEV_USER_HOME%\system11.1.1.3.37.56.60\DefaultDomain

2) %DOMAIN_HOME%\bin\setDomainEnv.cmd

3) cd %DOMAIN_HOME%\config\fmwconfig

4) Create client key-certificate pair signed by the demo CA cert "CertGenCA"

java utils.CertGen -certfile ClientPublicCertificate -keyfile ClientPrivateKey -keyfilepass welcome1

Note
-cn is optional argument, which determines the common name to which the certificate is issued to.
If this argument is skipped, the certificate is issued in the name of the hostname of the machine from which the certificate is generated

5) Create client keystore with client key-certificate pair

java utils.ImportPrivateKey -keystore default-keystore.jks -storepass welcome1 -certfile ClientPublicCertificate.der -keyfile ClientPrivateKey.der -keyfilepass welcome1 -alias clientkey -keypass welcome1

6) Now add the root CA to the client keystore

keytool -importcert -file %WL_HOME%\server\lib\CertGenCA.der -keystore default-keystore.jks -storepass welcome1

7) Add the service's public certificate to the client keystore.
(You must copy the server public certificate across to client)

keytool -importcert -file ServerPublicCertificate.der -alias serverkey -keystore default-keystore.jks -storepass welcome1

(Note
Latest version of OWSM can expose public certificate of service directly in the service WSDL through its Service Identity Certificate Extension
http://download.oracle.com/docs/cd/E14571_01/web.1111/b32511/setup_config.htm#BABJCGBC
Hence, this step may not be required.
In older releases, the service's public certificate had to be added to the client keystore;
If the recipient alias property on the client was not explicitly set, then this certificate would need to have been added under the the alias "orakey"
It appears that a client based on the JRF WS stack supports retrieving service certificate from WSDL, whereas as client based on WLS WS stack does not!
)


8) Add options to credential store (CWALLET.SSO) so as to access keys/certificates from keystore

%MW_HOME%\oracle_common\common\bin\wlst
connect('weblogic','weblogic1','t3://localhost:7101')
createCred(map="oracle.wsm.security", key="keystore-csf-key", user="n/a", password="welcome1", desc="keystore access password")
createCred(map="oracle.wsm.security", key="sign-csf-key", user="clientkey", password="welcome1", desc="signing key alias and password")
createCred(map="oracle.wsm.security", key="enc-csf-key", user="clientkey", password="welcome1", desc="encryption key alias and password")

Optional:
listCred(map="oracle.wsm.security", key="keystore-csf-key")
listCred(map="oracle.wsm.security", key="sign-csf-key")
listCred(map="oracle.wsm.security", key="enc-csf-key")

 

Verify cwallet.sso was updated… (note the addition of the oracle.wsm.security Secret Store entries) :-

C:\JDeveloper\system11.1.1.3.37.56.60\DefaultDomain\config\fmwconfig>

c:\Oracle\Middleware\oracle_common\bin\orapki wallet display -wallet cwallet.sso

Oracle PKI Tool : Version 11.1.1.2.0
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Requested Certificates:
User Certificates:
Oracle Secret Store entries:
oracle.wsm.security@#3#@enc-csf-key
oracle.wsm.security@#3#@keystore-csf-key
oracle.wsm.security@#3#@sign-csf-key
Trusted Certificates:
Subject:        OU=Class 1 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        OU=Secure Server Certification Authority,O=RSA Data Security\, Inc.,C=US
Subject:        CN=Entrust.net Secure Server Certification Authority,OU=(c) 1999 Entrust.net Limited,OU=www.entrust.net/CPS incorp. by ref. (limits liab.),O=Entrust.net,C=US
Subject:        CN=GTE CyberTrust Global Root,OU=GTE CyberTrust Solutions\, Inc.,O=GTE Corporation,C=US
Subject:        OU=Class 3 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        CN=Entrust.net Secure Server Certification Authority,OU=(c) 2000 Entrust.net Limited,OU=www.entrust.net/SSL_CPS incorp. by ref. (limits liab.),O=Entrust.net
Subject:        OU=Class 2 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        CN=Entrust.net Certification Authority (2048),OU=(c) 1999 Entrust.net Limited,OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.),O=Entrust.net

Monday, August 23, 2010

XBMC CrystalHD Update #2 August 2010

To leverage crystalhd kext, library and firmware based on r156 (http://code.google.com/p/crystalhd-for-osx/updates/list), replace Step 2 in the post

http://todayguesswhat.blogspot.com/2010/08/xbmc-crystalhd-updated-instructions.html

with the following:

# Step 2: Obtain the crystalhd kext, driver, and firmware and install in to the appropriate location

# run as root (sudo -s)

cd /tmp

rm -rf crystalhd-for-osx-3.6.0*

wget http://crystalhd-for-osx.googlecode.com/files/crystalhd-for-osx-3.6.0.zip

unzip crystalhd-for-osx-3.6.0.zip crystalhd-for-osx-3.6.0/*

rm -rf /System/Library/Extensions/BroadcomCrystalHD.kext

mv crystalhd-for-osx-3.6.0/BroadcomCrystalHD.kext /System/Library/Extensions

chown -R root:wheel /System/Library/Extensions/BroadcomCrystalHD.kext

chmod -R 755 /System/Library/Extensions/BroadcomCrystalHD.kext

rm -rf /usr/lib/libcrystalhd.dylib

mv crystalhd-for-osx-3.6.0/libcrystalhd.dylib /usr/lib/

chmod 755 /usr/lib/libcrystalhd.dylib
chown root:wheel /usr/lib/libcrystalhd.dylib

rm -rf /usr/lib/bcm7001*fw.bin

mv crystalhd-for-osx-3.6.0/bcm7001*fw.bin /usr/lib/

chmod 644 /usr/lib/bcm7001*fw.bin
chown root:wheel /usr/lib/bcm7001*fw.bin

rm -rf /tmp/crystalhd-for-osx-3.6.0
rm -rf /tmp/crystalhd-for-osx-3.6.0.zip

# reboot

# check that crystalhd driver is loaded :-
kextstat | grep crystalhd

Output :-
   74    0 0x2fff2000 0x18000    0x17000    com.broadcom.crystalhd.driver (3.6.0) <5 4 3 2>

Saturday, August 21, 2010

XBMC CrystalHD Updated Instructions using 2.01 driver – August 2010

There are plenty of simpler ways to install/verify Crystal HD on the Apple TV.   Below steps should work if you like to get your hands dirty :-

(note – cut/paste blocks of colored text as a whole)

# Step 1: SSH in to the apple tv as the user frontrow using your favourite ssh client

# having successfully logged in, switch to the root user
sudo -s

# Note! - you will need to manually supply the ROOT password for the ABOVE command before proceeding ...

# Step 2: Obtain the crystalhd kext, driver, and firmware and install in to the appropriate location

(Note, see the following post for a replacement ‘Step 2’ http://todayguesswhat.blogspot.com/2010/08/xbmc-crystalhd-update-2-august-2010.html if you want to run a newer build based on r156 http://code.google.com/p/crystalhd-for-osx/updates/list)

cd /tmp

rm -rf crystalhd-for-osx-2.0.1*

wget http://crystalhd-for-osx.googlecode.com/files/crystalhd-for-osx-2.0.1.zip

unzip crystalhd-for-osx-2.0.1.zip crystalhd-for-osx-2.0.1/*

rm -rf /System/Library/Extensions/BroadcomCrystalHD.kext

mv crystalhd-for-osx-2.0.1/BroadcomCrystalHD.kext /System/Library/Extensions

chown -R root:wheel /System/Library/Extensions/BroadcomCrystalHD.kext

chmod -R 755 /System/Library/Extensions/BroadcomCrystalHD.kext

rm -rf /usr/lib/libcrystalhd.dylib

mv crystalhd-for-osx-2.0.1/libcrystalhd.dylib /usr/lib/

chmod 755 /usr/lib/libcrystalhd.dylib
chown root:wheel /usr/lib/libcrystalhd.dylib

rm -rf /usr/lib/bcm7001*fw.bin

mv crystalhd-for-osx-2.0.1/bcm7001*fw.bin /usr/lib/

chmod 644 /usr/lib/bcm7001*fw.bin
chown root:wheel /usr/lib/bcm7001*fw.bin

rm -rf /tmp/crystalhd-for-osx-2.0.1
rm -rf /tmp/crystalhd-for-osx-2.0.1.zip

# Step 3: to load kexts, we require Turbo's ATV or Kext enabler ...

# check for presence of /sbin/turbo_atv_enabler.bin or /sbin/turbo_kext_enabler.bin
if [ ! -f /sbin/turbo_kext_enabler.bin ] && [ ! -f /sbin/turbo_atv_enabler.bin ]; then
  wget
http://crystalhd-for-osx.googlecode.com/files/turbo_atv_enabler.bin
  mv turbo_atv_enabler.bin /sbin
  chown root:wheel /sbin/turbo_atv_enabler.bin
  chmod 755 /sbin/turbo_atv_enabler.bin
fi

# Notes crystal_atv_enabler.bin is just a copy of turbo_atv_enabler.bin (they are MD5 equivalent 6a8ec66d5174a4cefacbe12be4b1e079 - 17780 bytes)

# Step 4: Ensure that the crystalhd kext is activated at boot time !!EITHER!! by adding a new startup item under /System/Library/StartupItems or adding an entry to /etc/rc.local ; If you have installed the Crystal HD driver in the past, it is worthwhile having a quick look on disk to see which mechanism is currently being used to load the driver and continue leveraging that approach.

# Use either method 1 or method 2  below ...

# Step 4 - Method 1:
# Rather than put the kextload entry in /etc/rc.local (as in method 2) - below we make use of /System/Library/StartupItems

mkdir -p /System/Library/StartupItems/LoadCrystalHD

# create StartupParameters.plist file
cat > /System/Library/StartupItems/LoadCrystalHD/StartupParameters.plist <<EOF
{
  Description     = "CrystalHD Driver Loader";
  Provides        = ("CrystalHD Driver");
  Uses            = ("Disks");
}
EOF

# create LoadCrystalHD file
cat > /System/Library/StartupItems/LoadCrystalHD/LoadCrystalHD <<EOF
#!/bin/sh
. /etc/rc.common
 
StartService() {
  if [ -f /sbin/turbo_atv_enabler.bin ]; then
    /sbin/turbo_atv_enabler.bin
  else
    /sbin/turbo_kext_enabler.bin
  fi
  /sbin/kextload -v /System/Library/Extensions/BroadcomCrystalHD.kext
}

StopService() {
  return 0
}

RestartService() {
  return 0
}

RunService "\$1"
EOF

# update permissions/ownership
chown -R root:wheel /System/Library/StartupItems/LoadCrystalHD
chmod -R 755 /System/Library/StartupItems/LoadCrystalHD/LoadCrystalHD
chmod -R 644 /System/Library/StartupItems/LoadCrystalHD/StartupParameters.plist

# one can attempt to confirm startupitem script works by typing
# SystemStarter start LoadCrystalHD


# Step 4 - Method 2:
# Rather than add a new startup item to /System/Library/StartupItems (as in method 1) - below we ensure that the crystalhd kext is activated at boot time by adding an entry to /etc/rc.local

# begin rc.local changes ...
touch /etc/rc.local
cp /etc/rc.local /etc/rc.local.original

# check if kext enabler entry missing from rc.local
if [ `grep --count -G '^/sbin/turbo_\(atv\|kext\)_enabler.bin' /etc/rc.local` -eq 0 ]; then
  if [ -f /sbin/turbo_atv_enabler.bin ]; then
    echo "/sbin/turbo_atv_enabler.bin" > /tmp/rc.top
  else
    echo "/sbin/turbo_kext_enabler.bin" > /tmp/rc.top
  fi

  cat /tmp/rc.top /etc/rc.local.original > /etc/rc.local
  rm -rf /tmp/rc.top
fi

# add kexload entry to end of rc.local file if missing
if [ `grep --count -G '^/sbin/kextload -v /System/Library/Extensions/BroadcomCrystalHD.kext' /etc/rc.local` -eq 0 ]; then
  echo "/sbin/kextload -v /System/Library/Extensions/BroadcomCrystalHD.kext" >> /etc/rc.local
fi

# ensure rc.local permissions are correct
chown root:wheel /etc/rc.local
chmod 644 /etc/rc.local

 

# Step 5: Next, we want to add support from laucher for downloading XBMC nightly builds

# exit as user root, and return as user frontrow ...
exit

# Note! You should now be the user frontrow.

# add xbmc nightly download location entry for launcher if not present ...
defaults read com.teamxbmc.xbmclauncher XBMCAdditionalDownloadPlistURLs 2>/dev/null | grep --silent mirrors.xbmc.org/nightlies/osx/update_urls.plist
if [ $? -eq 1 ]; then
  defaults write com.teamxbmc.xbmclauncher XBMCAdditionalDownloadPlistURLs -array
http://mirrors.xbmc.org/nightlies/osx/update_urls.plist
fi


# Step 6: From the Apple TV User Interface, Go to the launcher menu, then choose "Settings", then choose "Downloads"
# - Obtain the latest xbmc download build available


# Step 7: Reboot the Apple TV ...
sudo -s
reboot

# Step 8: After the Apple TV has rebooted, fire up XBMC from the launcher
# check that XBMC has detected the Crystal HD ...

# Check under "System -> Video -> Playback -> there is an option selected "Allow hardware acceleration (CrystalHD)"

# If no /usr/lib/libcrystalhd.dylib or no BroadcomCrystalHD.kext loaded, then CrystalHD will NOT show up above..

# Optional - Basic debugging can be done in the event the Cyrstal HD was not detected:

# switch to root
sudo -s

# check that crystal hd hardware was detected
dmesg

Output :-
...
BroadcomCrystalHD::start
crystalhd_hw_open: setting up functions, device = Link
Starting Crystal HD Device
Opening HW. hw:0x1f28e04, hw->adp:0x200e300
Stopping Crystal HD Device
BroadcomCrystalHD: Found HW and started driver SW.

# check that crystalhd driver is loaded :-
kextstat | grep crystalhd

Output :-
   74    0 0x30157000 0x18000    0x17000    com.broadcom.crystalhd.driver (3.5.0) <5 4 3 2>


# Check the xbmc.log when playing an appropriate movie ..
grep -i crystal /Users/frontrow/Library/Logs/xbmc.log

10:52:16 T:2684407808 M: 18456576    INFO: CrystalHD(new API): device opened

Tuesday, August 17, 2010

ADF11g Add javascript to jspx / trigger javascript onLoad event

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1">
      <f:facet name="metaContainer">
        <af:group id="g1">
          <af:resource type="javascript">
            function someFunction()
            {
              alert('hello');
            }
          </af:resource>
          <af:resource type="javascript" source="xxx.js"/>
        </af:group>
      </f:facet>
      <af:clientListener method="someFunction" type="load"/>
      <af:form id="f1"> …
      </af:form>
    </af:document>
  </f:view>
</jsp:root>

Thursday, July 22, 2010

How to query and obtain MD5 checksum for a file hosted on rapidshare.com

How many times have you downloaded file(s) from rapidshare.com only to extract them / join them / etc and discover that the file appears to be corrupted? You then wonder was it a download issue, or was the actual file itself hosted on rapidshare the problem.

My ADSL2+ internet connection here in Australia is slow by today’s internet speed standards (realworld tests, I get 500 KB/s download and 100 KB/s upload); To add insult to injury, internet quota in Australia is capped!  Thus, I don’t want to have to download a large file again, unless absolutely required.

The solution to this problem, is to make a basic HTTP request to rapidshare and request MD5 checksum information for the specific file(s) concerned, and then compare this with the MD5 checksums of the downloaded files on your local machine.

To perform MD5 checksum on your local files, first get yourself a suitable md5 hash tool for your specific OS platform concerned:

http://www.openoffice.org/dev_docs/using_md5sums.html

You can then use my html script below to query rapidshare for checksum info.  Put in the textarea the rapidshare links to query, for example

 http://rapidshare.com/files/408093110/test.iso

The MD5 checksum is returned as 32-character, hexadecimal-formatted hash. Using the test.iso link above for example, the MD5 checksum component returned by rapidshare appears in bold below:

408093110,test.iso,20348928,153,1,l3,78F8244AF76C6CF9641190780A50A9D8

<html>
  <body>
    <!-- Code by M.Shannon -->

    <script type="text/javascript">

      var debugMode=false; // set to true to enable window alerts

      function findURLs(refFiles, refFileNames)
      {
        var exp=/http:\/\/(www\.)?rapidshare\.com\/files\/\d+\/[\w_\-\.]+/igm;
        var matches = document.getElementById("urls").value.match(exp);

        if (matches != null)
        {
          for (var i = 0; i < matches.length; i++)
          {
            var url = matches[i];
            if (debugMode) { alert(url); }
            var index1 = url.lastIndexOf("/files/");
            var index2 = url.lastIndexOf("/");

            refFiles.push(url.substring(index1 + 7, index2));
            refFileNames.push(url.substring(index2 + 1));
          }
        }
      }

      function validate(form)
      {
        var files = new Array();
        var fileNames = new Array();

        findURLs(files, fileNames);

        if (files.length > 0)
        {
          if (debugMode) { alert(files); alert(fileNames); }
          form.files.value = files.toString();
          form.filenames.value = fileNames.toString();
          return true;
        }
       
        return false;
      }

  </script>

  <form><textarea id="urls" cols="80" rows="4">paste your rapidshare hyperlinks in to this textarea</textarea></form>

  <form method="post" action="http://api.rapidshare.com/cgi-bin/rsapi.cgi" onsubmit="return validate(this);">
    <input name="sub" type="hidden" value="checkfiles_v1">
    <input name="incmd5" type="hidden" value="1">
    <input name="files" type="hidden" value="">
    <input name="filenames" type="hidden" value="">
    <input type="submit">
  </form>

  <script type="text/javascript">
    document.getElementById("urls").focus();
  </script>

  </body>
</html>

Wednesday, July 21, 2010

How to prevent auto-repeat of videos in XBMC

For the best part of the last year, one annoying issue I have found with my particular XBMC setup was that videos would auto-repeat. I could not understand why this was, or where the auto-repeat setting was stored. If you pressed the TV power button mid playback of a movie, the movie would continue to play and repeat over and over.

It was particularly nasty should the video be played from an external USB disk, as the disk would never go to sleep.

Anyway, today I finally worked out where this setting is stored; instructions below assume an AppleTV XBMC setup :-

Navigate to a movie/tv episode etc

Hold down menu button until popup menu appears

from popup menu, choose "Queue item"

hold down menu button once more until popup menu re-appears

from popup menu, choose "Now playing ..."

"NOW PLAYING - VIDEOS" screen should appear

press Previous/Rewind button, and a side-menu on left-hand side should appear

Check the value for the REPEAT option. If it is set to REPEAT:ALL, movie will play over and over.

Set it to REPEAT:OFF

Friday, July 9, 2010

How to determine ATV Software Version Running

-bash-2.05b$ sw_vers
ProductName:    Apple TV OS
ProductVersion: 10.4.7
BuildVersion:   8N5880

AKA – Software Version 2.40

According to XBMC God – S.Davilla:

r1.00 -> 8N5107
r1.10 -> 8N5239
r2.00 -> 8N5400
r2.01 -> 8N5455
r2.02 -> 8N5461
r2.10 -> 8N5519
r2.20 -> 8N5622
r2.30 -> 8N5722

View ORACLE SQL query results with columns rendered vertically

Below is a script I hacked together from various sources to render ORACLE SQL query results in a vertical fashion (column are presented vertically rather than horizontally).

Tested with Oracle Database 11g Enterprise 11.2.0.1.0

:-

REM NAME: vselect.sql - Replacement by M Shannon.
prompt
accept tname prompt "Enter the table or view you wish to display vertically: "
prompt
prompt Enter the "WHERE" clause(s)...
prompt - if there is no "WHERE" clause, press [Enter].
prompt - do not include the word, "WHERE"; just specify syntax beyond "WHERE".
prompt - do not use single quotes for literals; use double quotes (") to enclose literals.
prompt
accept where prompt '=> '
prompt
prompt Enter the "ORDER BY" clause...
prompt - if there is no "ORDER BY" clause, press [Enter].
prompt - do not include the words, "ORDER BY"; just specify syntax beyond "ORDER BY"
prompt - do not use single quotes for literals; use double quotes (") to enclose literals.
prompt
accept orderby prompt '=> '
prompt

set termout on
set serveroutput on

declare
  l_where_clause    varchar2(500);
  l_orderby_clause  varchar2(500);
  l_cur             number;
  l_dtbl            dbms_sql.desc_tab;
  l_cnt             number;
  l_status          number;
  l_val             varchar2(200);
  double_quote      char(1) := '"';
  two_single_quotes char(1) := chr(39);
begin
  if length('&where') > 0 then
    l_where_clause := 'WHERE ' || replace(ltrim(rtrim('&where')),double_quote,two_single_quotes);
  else
    l_where_clause := null;
  end if;

  if length('&orderby') > 0 then
    l_orderby_clause := 'ORDER BY '|| replace(ltrim(rtrim('&orderby')),double_quote,two_single_quotes);
  else
    l_orderby_clause    := null;
  end if;

  l_cur := dbms_sql.open_cursor;
  dbms_sql.parse(l_cur,'select * from &tname '|| l_where_clause ||' '|| l_orderby_clause,dbms_sql.native);
  dbms_sql.describe_columns(l_cur,l_cnt,l_dtbl);
  for i in 1..l_cnt loop
    dbms_sql.define_column(l_cur,i,l_val,30);
  end loop;

  l_status := dbms_sql.execute(l_cur);

  while ( dbms_sql.fetch_rows(l_cur) > 0 ) loop
    dbms_output.put_line(lpad('=',80,'='));
    for i in 1..l_cnt loop
      dbms_sql.column_value(l_cur,i,l_val);
      dbms_output.put_line(rpad(l_dtbl(i).col_name,30) ||' --> '||l_val);
    end loop;
  end loop;
  dbms_sql.close_cursor(l_cur);
end;
/

Sample output:

SQL> @ /home/mshannon/other/scripts/database/vselect

Enter the table or view you wish to display vertically: dba_users

Enter the "WHERE" clause(s)...
- if there is no "WHERE" clause, press [Enter].
- do not include the word, "WHERE"; just specify syntax beyond "WHERE".
- do not use single quotes for literals; use double quotes (") to enclose literals.

=> username like "SY%"

Enter the "ORDER BY" clause...
- if there is no "ORDER BY" clause, press [Enter].
- do not include the words, "ORDER BY"; just specify syntax beyond "ORDER BY"
- do not use single quotes for literals; use double quotes (") to enclose literals.

=> username asc

...

================================================================================
USERNAME                       --> SYS
USER_ID                        --> 0
PASSWORD                       -->
ACCOUNT_STATUS                 --> OPEN
LOCK_DATE                      -->
EXPIRY_DATE                    --> 24-AUG-10
DEFAULT_TABLESPACE             --> SYSTEM
TEMPORARY_TABLESPACE           --> TEMP
CREATED                        --> 13-AUG-09
PROFILE                        --> DEFAULT
INITIAL_RSRC_CONSUMER_GROUP    --> SYS_GROUP
EXTERNAL_NAME                  -->
PASSWORD_VERSIONS              --> 10G 11G
EDITIONS_ENABLED               --> N
AUTHENTICATION_TYPE            --> PASSWORD
================================================================================
USERNAME                       --> SYSMAN
USER_ID                        --> 72
PASSWORD                       -->
ACCOUNT_STATUS                 --> OPEN
LOCK_DATE                      -->
EXPIRY_DATE                    --> 24-AUG-10
DEFAULT_TABLESPACE             --> SYSAUX
TEMPORARY_TABLESPACE           --> TEMP
CREATED                        --> 13-AUG-09
PROFILE                        --> DEFAULT
INITIAL_RSRC_CONSUMER_GROUP    --> DEFAULT_CONSUMER_GROUP
EXTERNAL_NAME                  -->
PASSWORD_VERSIONS              --> 10G 11G
EDITIONS_ENABLED               --> N
AUTHENTICATION_TYPE            --> PASSWORD
================================================================================
USERNAME                       --> SYSTEM
USER_ID                        --> 5
PASSWORD                       -->
ACCOUNT_STATUS                 --> OPEN
LOCK_DATE                      -->
EXPIRY_DATE                    --> 24-AUG-10
DEFAULT_TABLESPACE             --> SYSTEM
TEMPORARY_TABLESPACE           --> TEMP
CREATED                        --> 13-AUG-09
PROFILE                        --> DEFAULT
INITIAL_RSRC_CONSUMER_GROUP    --> SYS_GROUP
EXTERNAL_NAME                  -->
PASSWORD_VERSIONS              --> 10G 11G
EDITIONS_ENABLED               --> N
AUTHENTICATION_TYPE            --> PASSWORD

PL/SQL procedure successfully completed.

Wednesday, July 7, 2010

Mount ISO from Apple TV Command-Line-Interface CLI

hdiutil mount Australia.iso

/dev/disk3                                              /Volumes/AUSTRALIA

ls /Volumes/AUSTRALIA

AUDIO_TS        VIDEO_TS

hdiutil unmount /Volumes/AUSTRALIA

"disk3" unmounted successfully.

Wednesday, June 9, 2010

VBScript FTP Upload Sample (leverages Windows FTP client)

Save the following as upload.vbs and execute

'------------------------------------------------------------------------------
Const appName = "FTP Upload Utility"
'------------------------------------------------------------------------------

Const defaultHostname = "ftp.example.com"
Const defaultPort = 21
Const defaultUsername = "mshannon"
Const defaultPassword = "welcome1"
Const defaultRemoteDir = "/home/mshannon"

' set this var to the fully qualified path of a local file to prevent file
' selection dialog from being displayed
defaultFile = ""
' defaultFile = "C:\Documents and Settings\Administrator\Desktop\SecurityFilter.zip"

' if useDefaultsExclusively = True, the default values above will be leveraged
' as-is, meaning no override options will be prompted for.
Const useDefaultsExclusively = False
' Const useDefaultsExclusively = True

' if skipConfirmation = True, the upload will be attempted without requesting
' confirmation to commence.
Const skipConfirmation = False
' Const skipConfirmation = True

'------------------------------------------------------------------------------

Set shell = CreateObject( "WScript.Shell" )
defaultLocalDir = shell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop"
Set shell = Nothing

hostname = GetNonEmptyValue(useDefaultsExclusively, defaultHostname, _
  "Enter FTP server remote hostname:", "Hostname")

port = GetNonEmptyValue(useDefaultsExclusively, defaultPort, _
  "Enter FTP server remote port:", "Port")

username = GetNonEmptyValue(useDefaultsExclusively, defaultUsername, _
  "Enter username:", "Username")

password = GetNonEmptyValue(useDefaultsExclusively, defaultPassword, _
  "Enter password:", "Password")

If Len(defaultFile) > 0 Then
  file = defaultFile
Else
  file = ChooseFile(defaultLocalDir)
  TestNotEmpty file, "Upload File"
End If

Set fso = CreateObject("Scripting.FileSystemObject")
localFile = fso.getFileName(file)
localDir = fso.getParentFolderName(file)
Set fso = Nothing

remoteDir = GetNonEmptyValue(useDefaultsExclusively, defaultRemoteDir, _
  "Remote upload directory:", "Remote Directory")

Msg = "You have requested to upload " & localFile & " to ftp://" & _
  username & "@" & hostname & ":" & port & remoteDir & _
  vbCRLF & _
  vbCRLF & "Note - This may take quite some time!" & _
  vbCRLF & _
  vbCRLF & "Click OK to start upload."

' VB appears to evaluate all the "OR" conditions when using if t1 OR t2 then ...
' hence, it does not stop testing the conditions after the first condition
' it detects is true. Thus the silly logic below...
If skipConfirmation Then
  Upload hostname, port, username, password, localFile, localDir, remoteDir
ElseIf vbOK = MsgBox(Msg, vbOKCancel, appName) Then
  Upload hostname, port, username, password, localFile, localDir, remoteDir
End If

'------------------------------------------------------------------------------

Function GetNonEmptyValue(useDefaultExclusively, defaultValue, prompt, dialogTitle)

  If useDefaultExclusively Then
    value = defaultValue
  Else
    value = InputBox(prompt, dialogTitle, defaultValue)
  End If

  TestNotEmpty value, dialogTitle
  GetNonEmptyValue = value
End Function

'------------------------------------------------------------------------------

Sub TestNotEmpty(value, description)
  If Len(value) = 0 Then
    MsgBox "ERROR: No value provided for " & description, vbExclamation, appName
    wscript.quit
  End If
End Sub

'------------------------------------------------------------------------------

Function ChooseFile(initialDir)
  Set cd = CreateObject("UserAccounts.CommonDialog")

  cd.InitialDir = initialDir
  cd.Filter = "ZIP files|*.zip|Text Documents|*.txt|Shell Scripts|*.*sh|All Files|*.*"
  ' filter index 4 would show all files by default
  ' filter index 1 would should zip files by default
  cd.FilterIndex = 1
  If cd.ShowOpen = True Then
    ChooseFile = cd.FileName
  Else
    ChooseFile = ""
  End If
  Set cd = Nothing
End Function

'------------------------------------------------------------------------------

Sub Upload(hostname, port, username, password, localFile, localDir, remoteDir)

  Set shell = CreateObject("WScript.Shell")
  Set fso = CreateObject("Scripting.FileSystemObject")

  tempDir = shell.ExpandEnvironmentStrings("%TEMP%")
  ' temporary script file supplied to Windows FTP client
  scriptFile = tempDir & "\" & fso.GetTempName
  ' temporary file to store standard output from Windows FTP client
  outputFile = tempDir & "\" & fso.GetTempName

  'input script
  script = script & "lcd " & """" & localDir & """" & vbCRLF
  script = script & "open " & hostname & " " & port & vbCRLF
  script = script & "user " & username & vbCRLF
  script = script & password & vbCRLF
  script = script & "cd " & """" & remoteDir & """" & vbCRLF
  script = script & "binary" & vbCRLF
  script = script & "prompt n" & vbCRLF
  script = script & "put " & """" & localFile & """" & vbCRLF
  script = script & "quit" & vbCRLF

  Set textFile = fso.CreateTextFile(scriptFile, True)
  textFile.WriteLine(script)
  textFile.Close
  Set textFile = Nothing

  ' bWaitOnReturn set to TRUE - indicating script should wait for the program
  ' to finish executing before continuing to the next statement
  shell.Run "%comspec% /c FTP -n -s:" & scriptFile & " > " & outputFile, 0, TRUE
  Wscript.Sleep 500
  ' open standard output temp file read only, failing if not present
  Set textFile = fso.OpenTextFile(outputFile, 1, 0, -2)
  results = textFile.ReadAll
  textFile.Close
  Set textFile = Nothing
  If InStr(results, "550") > 0 And InStr(results, "226") Then
    fso.DeleteFile(scriptFile)
    fso.DeleteFile(outputFile)
    Msg ="WARNING: Could not change to destination directory on host!" & _
      vbCRLF & "File however appears to have been uploaded to default " & _
      "FTP directory associated with user on host."
    MsgBox Msg, vbExclamation, appName

  ElseIf InStr(results, "226") > 0 Then
    MsgBox "File Uploaded Successfully.", vbInformation, appName
    fso.DeleteFile(scriptFile)
    fso.DeleteFile(outputFile)
  Else
    If InStr(results, "530") > 0 Then
      Msg ="ERROR: Invalid Username/Password"
    ElseIf InStr(results, "550") > 0 Then
      Msg ="ERROR: Could not change to destination directory on host"
    ElseIf InStr(results, "553") > 0 Then
      Msg ="ERROR: Could not create file on host"
    ElseIf InStr(results, "Unknown host") > 0 Then
      Msg ="ERROR: Unknown host"
    ElseIf InStr(results, "File not found") > 0 Then
      Msg ="ERROR: Local File Not Found"
    Else
      Msg ="An ERROR may have occurred."
    End If

    Msg = Msg & _
      vbCRLF & "Script file leveraged: " & scriptFile & _
      vbCRLF & "FTP Output file: " & outputFile & _
      vbCRLF & _
      vbCRLF & "Ensure the above files are manually deleted, as they may " & _
     "contain sensitive information!"
    ' Wscript.Echo Msg
    MsgBox Msg, vbCritical, appName
  End If
  Set shell = Nothing
  Set fso = Nothing

End Sub

VBScript FTP Download Sample (leverages Windows FTP client)

Save the following as download.vbs and execute

'------------------------------------------------------------------------------
Const appName = "FTP Download Utility"
'------------------------------------------------------------------------------

Const defaultHostname = "ftp.example.com"
Const defaultPort = 21
Const defaultUsername = "mshannon"
Const defaultPassword = "welcome1"
Const defaultRemoteDir = "/home/mshannon"
Const defaultRemoteFile = "*.zip"

' set this var to the fully qualified path of a local directory to prevent
' directory selection dialog from being displayed
defaultLocalDir = ""
' defaultLocalDir = "C:\Documents and Settings\Administrator\Desktop"

' if useDefaultsExclusively = True, the default values above will be leveraged
' as-is, meaning no override options will be prompted for.
Const useDefaultsExclusively = False
' Const useDefaultsExclusively = True

' if skipConfirmation = True, the download will be attempted without requesting
' confirmation to commence.
Const skipConfirmation = False
' Const skipConfirmation = True

'------------------------------------------------------------------------------

hostname = GetNonEmptyValue(useDefaultsExclusively, defaultHostname, _
  "Enter FTP server remote hostname:", "Hostname")

port = GetNonEmptyValue(useDefaultsExclusively, defaultPort, _
  "Enter FTP server remote port:", "Port")

username = GetNonEmptyValue(useDefaultsExclusively, defaultUsername, _
  "Enter username:", "Username")

password = GetNonEmptyValue(useDefaultsExclusively, defaultPassword, _
  "Enter password:", "Password")

If Len(defaultLocalDir) > 0 Then
  localDir = defaultLocalDir
Else
  Set shell = CreateObject( "WScript.Shell" )
  defaultLocalDir = shell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop"
  Set shell = Nothing
  localDir = ChooseDirectory(defaultLocalDir, "Local Download Directory")
  TestNotEmpty localDir, "Local Directory"
End If

remoteDir = GetNonEmptyValue(useDefaultsExclusively, defaultRemoteDir, _
  "Remote download directory:", "Remote Directory")

remoteFile = GetNonEmptyValue(useDefaultsExclusively, defaultRemoteFile, _
  "Remote file to download (wildcard ok):", "Remote File")

Msg = "You have requested to download " & remoteFile & " from ftp://" & _
  username & "@" & hostname & ":" & port & remoteDir & _
  vbCRLF & "to: " & localDir & _
  vbCRLF & _
  vbCRLF & "Note - This may take quite some time!" & _
  vbCRLF & _
  vbCRLF & "Click OK to start download."

' VB appears to evaluate all the "OR" conditions when using if t1 OR t2 then ...
' hence, it does not stop testing the conditions after the first condition
' it detects is true. Thus the silly logic below...
If skipConfirmation Then
  Download hostname, port, username, password, localDir, remoteDir, remoteFile
ElseIf vbOK = MsgBox(Msg, vbOKCancel, appName) Then
  Download hostname, port, username, password, localDir, remoteDir, remoteFile
End If

'------------------------------------------------------------------------------

Function GetNonEmptyValue(useDefaultExclusively, defaultValue, prompt, dialogTitle)

  If useDefaultExclusively Then
    value = defaultValue
  Else
    value = InputBox(prompt, dialogTitle, defaultValue)
  End If

  TestNotEmpty value, dialogTitle
  GetNonEmptyValue = value
End Function

'------------------------------------------------------------------------------

Sub TestNotEmpty(value, description)
  If Len(value) = 0 Then
    MsgBox "ERROR: No value provided for " & description, vbExclamation, appName
    wscript.quit
  End If
End Sub

'------------------------------------------------------------------------------

Function ChooseDirectory(initialDir, prompt)
  Set objShell  = CreateObject( "Shell.Application" )

  options = &H10& 'show text field to type folder path
  'options = 0    'don't show text field to type folder path

  Set objFolder = objShell.BrowseForFolder(0, prompt, options, initialDir)

  If objFolder Is Nothing Then
    ChooseDirectory = ""
  Else
    ChooseDirectory = objFolder.Self.Path
  End If

  Set objFolder = Nothing
  Set objShell = Nothing
End Function

'------------------------------------------------------------------------------

Sub Download(hostname, port, username, password, localDir, remoteDir, remoteFile)

  Set shell = CreateObject("WScript.Shell")
  Set fso = CreateObject("Scripting.FileSystemObject")

  tempDir = shell.ExpandEnvironmentStrings("%TEMP%")
  ' temporary script file supplied to Windows FTP client
  scriptFile = tempDir & "\" & fso.GetTempName
  ' temporary file to store standard output from Windows FTP client
  outputFile = tempDir & "\" & fso.GetTempName

  'input script
  script = script & "lcd " & """" & localDir & """" & vbCRLF
  script = script & "open " & hostname & " " & port & vbCRLF
  script = script & "user " & username & vbCRLF
  script = script & password & vbCRLF
  script = script & "cd " & """" & remoteDir & """" & vbCRLF
  script = script & "binary" & vbCRLF
  script = script & "prompt n" & vbCRLF
  script = script & "mget " & """" & remoteFile & """" & vbCRLF
  script = script & "quit" & vbCRLF

  Set textFile = fso.CreateTextFile(scriptFile, True)
  textFile.WriteLine(script)
  textFile.Close
  Set textFile = Nothing

  ' bWaitOnReturn set to TRUE - indicating script should wait for the program to
  ' finish executing before continuing to the next statement
  shell.Run "%comspec% /c FTP -n -s:" & scriptFile & " > " & outputFile, 0, TRUE
  Wscript.Sleep 500
  ' open standard output temp file read only, failing if not present
  Set textFile = fso.OpenTextFile(outputFile, 1, 0, -2)
  results = textFile.ReadAll
  textFile.Close
  Set textFile = Nothing
  If InStr(results, "550") > 0 And InStr(results, "226") Then
    fso.DeleteFile(scriptFile)
    fso.DeleteFile(outputFile)
    Msg ="WARNING: Could not change to destination directory on host!" & _
      vbCRLF & "File(s) however appear to have been downloaded from default " & _
      "FTP directory associated with user on host."
    MsgBox Msg, vbExclamation, appName

  ElseIf InStr(results, "226") > 0 Then
    MsgBox "File(s) Downloaded Successfully.", vbInformation, appName
    fso.DeleteFile(scriptFile)
    fso.DeleteFile(outputFile)
  Else
    If InStr(results, "530") > 0 Then
      Msg ="ERROR: Invalid Username/Password"
    ElseIf InStr(results, "550") > 0 Then
      Msg ="ERROR: Could not open file on host"
    ElseIf InStr(results, "553") > 0 Then
      Msg ="ERROR: Could not create file on host"
    ElseIf InStr(results, "Unknown host") > 0 Then
      Msg ="ERROR: Unknown host"
    ElseIf InStr(results, "File not found") > 0 Then
      Msg ="ERROR: Local Directory Not Found"
    Else
      Msg ="An ERROR may have occurred."
    End If

    Msg = Msg & _
      vbCRLF & "Script file leveraged: " & scriptFile & _
      vbCRLF & "FTP Output file: " & outputFile & _
      vbCRLF & _
      vbCRLF & "Ensure the above files are manually deleted, as they may " & _
      "contain sensitive information!"
    ' Wscript.Echo Msg
    MsgBox Msg, vbCritical, appName
  End If
  Set shell = Nothing
  Set fso = Nothing

End Sub

I’m trying out Windows Live Writer

Posting code samples on Blogger is a major PITA.

So I’m going to try out Micro$oft’s FREE Windows Live Writer and see if it does what it claims, starting with some Visual Basic code samples to script the Windows XP client.

Update:  It works a treat!

Thursday, May 6, 2010

Splendour 2010 Tickets - backdoor direct access

Update 2.16 pm.. all tickets are now sold out

Update 1.44 pm.. camping tix sold out.

Direct access to splendour 2010 tickets; there is no scam people ; it is a simple html file;

splendour.html

Here is the code:

<html><body>
<form id="aspnetForm" action="
https://www.moshtix.com.au/Booking/bookEvent_start.asp?pLock=False" method="post" name="aspnetForm">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="">
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="">
<input type="hidden" name="EventID" value="36343">
<input type="hidden" name="PhoneSale" value="False">
<input type="hidden" name="Caller" value="moshfest">
<input type="hidden" name="noadd" value="False">
<input type="hidden" name="skin" value="">
<input type="hidden" name="CallerUrl" value="
http://www.moshtix.com.au/event.aspx?id=36343&amp;ref=moshfest">
<input type="hidden" name="QueID" value="">
<select name="lTicketTypeID0">
<option value="65479">Carbon Offset Event-Only ticket $363.25</option>
<option value="65480">Carbon Offset Event and Camping ticket $464.85</option>
<option value="65541">Event-Only Ticket $360.20</option>
<option selected value="65542">Event and Camping ticket $461.80</option>
</select>
<select name="lQuantity0">
<option value="1">1 Ticket</option>
<option value="2">2 Tickets</option>
<option value="3">3 Tickets</option>
<option value="4">4 Tickets</option>
</select>
<input type="submit">
</form></body></html>

Thursday, March 18, 2010

Updated Instructions for ATV / XBMC / CrystalHD configuration

andy204 over at XBMC forums has created a launcher application that greatly simplifies setup/configuration of the Broadcom CrystalHD on the Apple TV.

Follow the details from the following post :-
http://forum.xbmc.org/showthread.php?t=69321

My instructions from the post http://todayguesswhat.blogspot.com/2010/01/thanks-davilla-and-xbmc-team-apple-tv.html are subsequently deprecated!