Search this blog ...

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!

Wednesday, January 13, 2010

Obtain Apple TV XBMC nightly build



# Should you want the latest available nightly Apple TV xbmc build, then ...

# ssh to apple tv as user frontrow, then ...

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-add http://mirrors.xbmc.org/nightlies/osx/update_urls.plist
fi

# From the Apple TV User Interface, Go to the launcher menu, then choose "Settings", then choose "Downloads"
# - Obtain the appropriate xbmc download build.



Friday, January 8, 2010

Thanks Davilla and XBMC team - Apple TV support for Broadcom Crystal HD BCM70012

NOTE - the following instructions are here for historical reasons! There is now a much more elegant way to setup XBMC with Crystal HD on the ATV; See the following post

Thanks to Davilla!!! and Turbo!!

http://xbmc.org/forum/showthread.php?t=55042


# Step 0: http://rufn.it/aTV/ - Install the BroadCom BCM970012 Mini PCI-e HD card as per ewequeone's instructions.
# Note! - there is no need to clip the wireless antenna leads. You can electrical tape them up / heat-shrink-tube them

# 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

cd /tmp

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

unzip crystalhd-for-osx-1.0.1.zip

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

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

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

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

chmod 755 /usr/lib/libcrystalhd.dylib

mv crystalhd-for-osx-1.0.1/bcmFilePlayFw.bin /usr/lib/

chmod 644 /usr/lib/bcmFilePlayFw.bin

rm -rf /tmp/crystalhd-for-osx-1.0.1

# Step 3: Ensure that the crystalhd kext is activated at boot time by adding an entry to /etc/rc.local

# 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://0xfeedbeef.com/appletv/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

# 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


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


# Step 4: Next, we want to add support from laucher for downloading
# TheQuestor's svn builds which provide the latest xbmc builds with crystalhd support


# Note! You should now be the user frontrow.

# add custom xbmc download location entry for launcher if not present ...

defaults read com.teamxbmc.xbmclauncher XBMCAdditionalDownloadPlistURLs 2>/dev/null | grep --silent www.sshcs.com/xbmc/Info.asp
if [ $? -eq 1 ]; then
defaults write com.teamxbmc.xbmclauncher XBMCAdditionalDownloadPlistURLs -array http://www.sshcs.com/xbmc/Info.asp
fi


# Step 5: From the Apple TV User Interface, Go to the launcher menu, then choose "Settings", then choose "Downloads"
# - Obtain the latest xbmc download build available from TheQuestor e.g. XBMC r26651.



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

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


# Check under "Settings -> Video -> Playback -> Render method", there is an option Auto-Detect, which could be changed to "Broadcom Crystal HD"

# If no /usr/lib/libcrystalhd.dylib or no BroadcomCrystalHD.kext loaded, then Broadcom Crystal HD will NOT show up as a rendering option.


# 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 | grep -i crystal

Output :-
BroadcomCrystalHD::start
BroadcomCrystalHD: Found HW and started driver SW.


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

Output :-
75 0 0x2f588000 0xb000 0xa000 com.broadcom.crystalhd.driver (0.9.26) <5>


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

Output :-
16:19:54 T:2684407808 M: 14409728 DEBUG: Loading: libcrystalhd.dylib
16:19:59 T:2684407808 M: 11501568 INFO: CrystalHD: device opened
16:40:28 T:51790336 M: 20217856 INFO: Trying Broadcom Crystal HD Decoder...
16:40:29 T:51790336 M: 13025280 DEBUG: CrystalHD: codec opened
16:40:29 T:51790336 M: 13025280 INFO: DVDVideoCodecCrystalHD: Opened Broadcom Crystal HD Codec





People should strongly think about donating to the xbmc team/davilla to ensure that further development continues. They have effectively extended the lifetime of the ATV! ( PS.. yes I donated ;) )
http://xbmc.org/contribute/donate/

Additionally, if you want to duplicate the instructions found in this guide, please at least link back to it.