Posts Tagged ‘code’

Eclipse IDE – New Project, No Android Build Targets Available

Tuesday, January 25th, 2011

Installed the Andorid SDK on Windows as per guide at http://developer.android.com, all pretty straight forward. Decided to also use the Eclipse IDE for developing apps since it seems to be the recommended way of doing this (haven’t really done any Java development in the past).

Installed Eclipse 3.6 (Helios) and installed the ADT plugin for it, as detailed here.

Following that, tried to build a new project following the guide here.

Got to the New Project page but there were no Build Targets available in the list.

For me, the issue was that Eclipse didn’t know where the Android SDK was located, so it didn’t know what builds were available. To fix:
1. In Eclipse go to Window -> Preferences
2. Click on Android
3. Browse to the path of the SDK (for me, on Windows, this was default C:\Program Files\Android\android-sdk-windows)
4. Click Apply, then OK

The builds that have been added to the SDK will appear in the list. Go to File -> New -> Project again and this time the Build Targets list is there:

Popularity: 14% [?]

VMware PowerCLI for Host and Guest CPU Details, Includes OS and Power State

Tuesday, January 25th, 2011

The following will get CPU (num of cores) counts from hosts and will also get vCPU counts from VM’s. It will also get the operating system of each VM, its power state and the average CPU for the past week. The end of each section also has a count of the number of objects (hosts and VMs) in the environment.

Connect-VIServer <Your_vCenter_Server>
# define start and finish days (1 week period)
$startdate=(get-date).addDays(-7)
$finishdate=(get-date).addDays(-1)
# initialise counters
$vmcount=0
$hostcount=0

ForEach ($esxhost in (Get-VMHost | Sort Name)){
	Write-Host $esxhost.Name","$esxhost.NumCPU
    $hostcount++
}
Write-Host "Total Hosts:" $hostcount

ForEach ($vm in (Get-VM | Sort Name)){
    If ($vm.PowerState -eq 'PoweredOn'){
        $vstats = (Get-Stat -entity $vm -stat cpu.usage.average -Start $startdate -Finish $finishdate | measure-object -property value -average)
        # round to two decimal places
        $vavg = [system.math]::round($vstats.average,2)
    }Else{
        $vavg = 0
    }
	Write-Host $vm.Name","$vm.Guest.OSFullName","$vm.PowerState","$vm.NumCPU","$vavg
    $vmcount++
}

Write-Host "Total VM's:" $vmcount

Popularity: 35% [?]

Idea: Twitter Search – Random User Profile Image

Wednesday, January 12th, 2011

Its a random scatter of user profile images based on search criteria. Where? Here (suggest using Chrome for this):

http://danejeffrey.com/projects/twitsearch.php 

Using: Twitter Search API, JavaScript, jQuery and some CSS (also ref: http://johnmc.co/llum/using-json-to-access-the-twitter-search-api/ for use of $.getJSON).

Popularity: 8% [?]

Active Directory Site and Subnet List VBScript

Tuesday, January 4th, 2011

This will list Active Directory sites and subnets and display in a MsgBox. Formatting is ugly but that’s easy to change as required.

'Get list of AD subnets

Set oRootDSE = GetObject("LDAP://RootDSE")
sConfigurationNC = oRootDSE.Get("configurationNamingContext")
Set oRootDSE = Nothing 

sSubnetsContainer = "LDAP://cn=Subnets,cn=Sites" & "," & sConfigurationNC
Set oSubnetsContainer = GetObject(sSubnetsContainer)

For Each sResult In oSubnetsContainer

	aSNInfo = Split(sResult.cn, "/")
	If Instr(sResult.siteObject, ",") = 0 Then
		sSN = sSN & aSNInfo(0) & vbTab & vbTab
	Else
		sSN = sSN & aSNInfo(0) & ": " & _
			Mid(Left(sResult.siteObject, Instr(sResult.siteObject, ",") - 1), 4) & _
			vbTab & vbTab
	End if
Next
wscript.echo sSN

To display your computer’s site:

Set adsSystemInfo = CreateObject("ADSystemInfo")
WScript.echo "Your site is: " & adsSystemInfo.SiteName
Set adsSystemInfo = Nothing

Popularity: 12% [?]

HTTP Get Using MSXML2.XMLHTTP Object VBScript

Thursday, December 23rd, 2010

Use the XMLHTTP object to issue an HTTP Get on a remote web server.

Set objHTTP = CreateObject("MSXML2.XMLHTTP")
objHTTP.open "GET", "http://localhost/default.htm, False
objHTTP.send
strResponse = objHTTP.responseText

Ref: http://msdn.microsoft.com/en-us/library/ms757849(VS.85).aspx

Popularity: 6% [?]