• WMI query to find if the SCCM client is running a program

    Using PowerShell, this will tell you if the SCCM client is running a program and its state:

    gwmi -Namespace ROOT\CCM\SoftMgmtAgent -Class CCM_ExecutionRequestEx
    

  • CentOS: HowTo install ruby, rubygems and passenger for a redmine install

    I like to put my complied software in /opt vs /usr/local. Make sure rpm version is not installed.

    install ruby:

    wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p174.tar.gz
    ./configure --prefix=/opt/ruby-1.8.7-p174
    sudo make && sudo make install
    

    user alternatvies to create sym links:

    /usr/sbin/alternatives --install /usr/bin/ruby ruby /opt/ruby-1.8.7-p174/bin/ruby 1 \
    --slave /usr/bin/rdoc rdoc /opt/ruby-1.8.7-p174/bin/rdoc \
    --slave /usr/bin/ri ri /opt/ruby-1.8.7-p174/bin/ri \
    --slave /usr/bin/irb irb /opt/ruby-1.8.7-p174/bin/irb \
    --slave /usr/bin/erb erb /opt/ruby-1.8.7-p174/bin/erb \
    --slave /usr/bin/testrb testrb /opt/ruby-1.8.7-p174/bin/testrb \
    --slave /usr/bin/gem gem /opt/ruby-1.8.7-p174/bin/gem \
    --slave /usr/bin/rake rake /opt/ruby-1.8.7-p174/bin/rake
    

    make sure current ruby is set to 1.8.7: /usr/sbin/alternatives –config ruby

    install rubygems:

    wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
    sudo ruby setup.rb
    

    install gems (No docs):

    gem install --no-rdoc --no-ri rails
    gem install --no-rdoc --no-ri passenger
    gem install --no-rdoc --no-ri mysql
    gem install --no-rdoc --no-ri rack -v=1.0.1
    

    Passenger said I needed to install curl-dev  (yum install curl-devel)

    install passenger apache module:

    	/opt/ruby-1.8.7-p174/lib/ruby/gems/1.8/gems/passenger-3.0.0/bin/passenger-install-apache2-module
    

    modify your httpd conf file

       LoadModule passenger_module /opt/ruby-1.8.7-p174/lib/ruby/gems/1.8/gems/passenger-3.0.0/ext/apache2/mod_passenger.so
       PassengerRoot /opt/ruby-1.8.7-p174/lib/ruby/gems/1.8/gems/passenger-3.0.0
       PassengerRuby /opt/ruby-1.8.7-p174/bin/ruby
    

    Install redmine according to Docs


  • My current WordPress Update Script

    Below is my current WordPress update script. First this script downloads the most recent version and determines which version it is:

    cd ~/src/
    rm -f ~/src/latest.tar.gz
    rm -rf ~/src/wordpress/
    wget -q http://wordpress.org/latest.tar.gz
    tar -xzf latest.tar.gz
    CURRENTVERSION=$(grep "wp_version =" wordpress/wp-includes/version.php | cut -f 3 -d " " | sed "s/;//" | sed "s/'//g")
    echo "Latest Version: $CURRENTVERSION"
    

    Next it looks for all wp-config.php files in all the websites to identify which sites have WordPress installed. Then and finds the version from the versions.php script. If the version is not equal to the most recent downloaded version (from the code above), it copies the updated source to the website:

    for installpath in $(find /webdir -name wp-config.php)
    	do
    	BASEDIR=$(dirname $installpath)
    	INSTALLEDVERSION=$(grep "wp_version =" $BASEDIR/wp-includes/version.php | cut -f 3 -d " " | sed "s/;//" | sed "s/'//g")
    	if [ ! $CURRENTVERSION == $INSTALLEDVERSION ]; then
    		echo "updating" $BASEDIR from $INSTALLEDVERSION "to" $CURRENTVERSION
    		cp -R  ~/src/wordpress/* $BASEDIR/
    	else
    		echo $BASEDIR "is already" $CURRENTVERSION
    	fi
    	done
    

  • Using ajax to query XML in SharePoint Doc Lib, for use in a form’s input autocomplete

    Long title, but I wanted to get across what I was trying to do. If I had and XML file in a document library (you could mail enable the doc lib, and send XML from a query in SQL server using the “FOR XML” statement!), could I use jquery to add Autocomplete values to an input field in a newform.aspx? Ended up being not that difficult.

    1. Once the ajax call sucessfully retrievs the xml file, the parseXml routine is called.
    2. Seems there is an issue that IE will not think the file is XML, but rather as txt, so there some quick code to load the file as XML
    3. Then I just look in the file and grab the values I want, and append them to an array
    4. Then just set the array to be used as the autocomplete source
    <script type="text/javascript">
    $(document).ready(function() {
    $.ajax({ 	
    	type: "GET",
    	url: "http://URL/To/xmlfile.xml",
    	dataType: ($.browser.msie) ? "text" : "xml",
    	success: parseXml
    });
    });
    function parseXml(data)
    {
        var xml;
         if (typeof data == "string") {
           xml = new ActiveXObject("Microsoft.XMLDOM");
           xml.async = false;
           xml.loadXML(data);
         } else {
           xml = data;
         };
     	var results = []; 
    	$(xml).find("ID").each(function(){  
    		var ClientName = $.trim($(this).find('Name').text());
    		var ClientCode = $.trim($(this).find('ZipCode').text());
    		results[results.length] = ClientName + "(" + ClientCode + ")"
    	});
    
    	$('input[title=Title]').autocomplete({
    	source: results,
    	delay:10,
    	minLength: 3
    	});
    };
    </script>
    

  • Apple to push virtualization of OSX?

    Seems that Apple is discontinuing their XServe product. I hope this means that Apple is moving towards virtualizion of OSX in the enterprise. VDI with OSX would be sweet!


  • jQuery, SharePoint Web Services and adding thumbnail to a List

    We have a SharePoint list with thumbnails attached to the list items. The request was to show a thumbnail of the image that is attached. I believe this can be done via SharePoint designer, but I thought jQuery would be easier. I added a Content Editor WebPart to the top of the page. Next I inserted the jQuery code below. This code queries the SharePoint Web Services for every item (not tested on a large list), and then loops through them. If there is an attachment, jQuery takes the ID and the path to the attachment and replace the ID column (has to the first column) for the item with the tumbnail image.

    The tricks were:

    1. The soapEnv has to have “<IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls>”
    2. Finding the right selector to get to the ID column:
    $("table.ms-listviewtable tr:has(td.ms-vb2)").find("td:first").filter(function() {
    			return $(this).text().toLowerCase() == ID;
    			}).html("<img src='" + url[1] + "' width=150 height=100 />");
    

    Here is the rest of the code:

    $(document).ready(function() {
    querySPWebServices();
    });
    
    function querySPWebServices() {
            var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
    		<soapenv:Body> \
    		<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
    		<listName>Projects</listName> \
    		<viewFields> \
    		<ViewFields> \
    		<FieldRef Name='Title' /> \
            <FieldRef Name='Body' /> \
    		<FieldRef Name='ID' /> \
    		<FieldRef Name='Attachments' /> \
    		</ViewFields> \
    		</viewFields> \
    		<query> \
    		<Query /> \
    		</query> \
    		<queryOptions> \
    		<QueryOptions> \
    		<IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls> \
    		</QueryOptions> \
    		</queryOptions> \
    		</GetListItems> \
    		</soapenv:Body> \
            </soapenv:Envelope>";
    
            $.ajax({
            	async: false,
                url: "http://server.name.com/site/_vti_bin/lists.asmx",
                type: "POST",
                dataType: "xml",
                data: soapEnv,
                complete: processResult,
                contentType: "text/xml; charset=\"utf-8\""
            	});
    };
    function processResult(xData, status) {
    	$(xData.responseXML).find("z\\:row").each(function() {
    		if ($(this).attr("ows_Attachments") != 0) {
    		var url = $(this).attr("ows_Attachments").replace(/#/g, "").split(';');
    		var ID = $(this).attr("ows_ID");
    		$("table.ms-listviewtable tr:has(td.ms-vb2)").find("td:first").filter(function() {
    			return $(this).text().toLowerCase() == ID;
    			}).html("<img src='" + url[1] + "' width=150 height=100 />");
    		};
    	});
    };
    

  • Countdown Clocks and the MTA

    Waiting for the subway this morning, it occurred to me that the MTA should not bother spending millions of dollars on Countdown Clocks. Instead, why not invest in app development for smart phones. Since there will be wifi in the subways, why not work on getting data to people’s devices. No citywide maintenance costs on installed hardware, power , or labor.

    Since there will already be an infrastructure in place to handle the pushing of the data to the clocks, why not push it to an app on my phone. Basically shifting the hardware costs of the colcks to the riders. Added benefit: info is available where ever you are, so you can time your arrival.

    I am sure I am not the first to think of this, but it occurred to me this morning.


  • My esxupdate script

    I was having problems using update manager on an esx box at a remote site. I needed to install several prerequisite patches before i could get to U5.
    I went to : http://www.vmware.com/patch/download/ and found the patches I needed.

    So I used lwp-download to download the files(esx does not have wget) like so:

    lwp-download http://download3.vmware.com/software/vi/ESX350-200911210-UG.zip
    lwp-download http://download3.vmware.com/software/vi/ESX350-200911211-UG.zip
    lwp-download http://download3.vmware.com/software/vi/ESX350-200911212-UG.zip
    lwp-download http://download3.vmware.com/software/vi/ESX350-200911214-UG.zip
    lwp-download http://download3.vmware.com/software/vi/ESX350-200911215-UG.zip
    lwp-download http://download3.vmware.com/software/vi/ESX350-200911217-UG.zip
    lwp-download http://download3.vmware.com/software/vi/ESX350-200911219-UG.zip
    lwp-download http://download3.vmware.com/software/vi/ESX350-200911221-UG.zip
    lwp-download http://download3.vmware.com/software/vi/ESX350-200911222-UG.zip
    lwp-download http://download3.vmware.com/software/vi/ESX350-200911223-UG.zip
    

    Then I used the following simple bash script:

    for i in ESX350-2009*.zip
    do
    unzip $i
    mv {,_}$i
    cd ${i%%.*}/
    esxupdate --noreboot update
    cd /back/to/location/of/patches
    mv {,_}${i%%.*}/
    done