Friday, October 1, 2010

Testing Aixiz lasers

I bought some infrared lasser from Aixiz to build an interactive multitouch surface.
To avoid any damage to my eyes, I was wearing Infrared protection glasses from Dragon Lasers

Now, the thing that I hadn't planned was how to power the lasers :-)
As they are rated at 3.2VDC, drawing approximately 30ma of current, this seems something my Arduino Duemilanovae could do.


  1. Connect the Arduino to the USB port of the computer
  2. Connect an infared camera to the computer ( here using a modified PS3eye with a 850nm filter - same wavelength as the lasers)
  3. Position the camera, and launch a viewer (here using the CL-Eye Test from Code Laboratories )
  4. Put the protection glasses on, close all doors & windows  to the room you're in (and you are alone right!)
  5. Hook up a laser to the Arduino: red cable on the "3v3" , black cable on "Gnd"
  6. You should now see the laser beaming (or not) through the viewer


Repeat for all the lasers you ordered to make sure they are all working properly...and give a good feedback to Aixiz if you bought your lasers from their eBay store

You can see a bit of the laser in this picture because a picture camera will see infrared (whereas your eyes cannot).
Now I have to find something to power 4 lasers at the same time (something I'm not sure the Arduino can do)

Wednesday, September 15, 2010

Google Goggles: What's this thing with no name on it?

Every time I came home, I wondered what was this thing nailed to the wall in the hall of my building.
I couldn't anything written on it either. And I didn't want to take it off to read the back of it.
All I could make out of it was this logo on it.


Enter "Google Goggles"
Install it on your Android phone, then snap a picture with Google Goggles.


That's how I found out that this was some kind of Ubiquiti Wifi bridge. Just by taking a picture of the logo.
I opened a maintenance closet in the staircase, and found a Power-over-ethernet module to power this device, along with an ethernet cable running one floor up.
Someone running a big wifi network around here ;-)

Tuesday, September 14, 2010

SCCM : converting programs to Windows 7

This is a VBS program I wrote for a customer, who has a SCCM 2007 R2 environment.

They had over 400 programs in various packages, and they weren't sure if all of them would run under Windows 7.

Visually, we had to make sure this box was ticked.

After a little digging in the SCCM SDK (link), and a script from Stuart James, the following will go through ALL programs in ALL packages. If a program is not set to "Run on all platforms", we add that it can run on "All x86 Windows 7"

It outputs changes with comma separated values (csv) so you can send this to a file and dress it up nice in Excel for your boss :-)

'===================================== 
'SetRunFromTS - Sets all programs to be able to run in Windows 7 x86
'Author: Patrick Paumier / Stuart James 
' 
'Requirements: Change line 22 to connect to your site server
' 
'Usage: CScript xxx.vbs or double click 
'===================================== 


'Check we're using CScript and if not then relaunch 
If "CSCRIPT.EXE" <> UCase(Right(WScript.Fullname, 11)) Then 
Set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "CSCRIPT.EXE /nologo " & WScript.ScriptFullName 
Wscript.Quit 
End If 

' Setup a connection to the local provider. 
Set swbemLocator = CreateObject("WbemScripting.SWbemLocator") 
Set swbemServices= swbemLocator.ConnectServer("MY-SCCM-SERVER", "root\sms") 
Set providerLoc = swbemServices.InstancesOf("SMS_ProviderLocation") 

For Each Location In providerLoc 
If location.ProviderForLocalSite = True Then 
Set swbemServices = swbemLocator.ConnectServer(Location.Machine, "root\sms\site_" + Location.SiteCode) 
Exit For 
End If 
Next 

'Main call 
QueryPrograms swbemServices 

Sub QueryPrograms(connection) 

On Error Resume next 

Dim programs 
'Dim program 
' Run the query. 
Set programs = connection.ExecQuery("Select * From SMS_Program WHERE PackageID='TDE0024F'") 

If Err.Number<>0 Then 
Wscript.Echo "Couldn't get programs" 
Wscript.Quit 
End If 
For Each program In programs 
ModifyProgram connection,program.PackageID, program.ProgramName 
Next 
If programs.Count=0 Then 
Wscript.Echo "No packages found" 
End If 

End Sub 

Sub ModifyProgram (connection, existingPackageID, existingProgramName) 

' Build a query to get the specified package. 
packageQuery = "SMS_Package.PackageID='" & existingPackageID & "'" 

' Run the query to get the package. 
Set package = connection.Get(packageQuery) 
' Output package name and ID. 
wscript.echo VBCrLf 'New Line
Wscript.StdOut.Write package.PackageID & "," 'Package ID
Wscript.StdOut.Write package.Name & "," 'Package Name
' Build a query to get the programs for the package. 
programQuery = "SELECT * FROM SMS_Program WHERE PackageID='" & existingPackageID & "'" 
' Run the query to get the programs. 
Set allProgramsForPackage = connection.ExecQuery(programQuery, , wbemFlagForwardOnly Or wbemFlagReturnImmediately) 
'The query returns a collection of program objects that needs to be enumerated. 
For Each program In allProgramsForPackage                
If program.ProgramName = existingProgramName Then 
'Get all program object properties (in this case we specifically need some lazy properties).
programPath = program.Put_
Set program = connection.Get(programPath) 

' Output the program name 
Wscript.StdOut.Write program.ProgramName & "," ' Program Name
Wscript.StdOut.Write program.ProgramFlags & "," 'Program Flags

If program.ProgramFlags AND 2^27 Then
Wscript.StdOut.Write "OK for all platforms"
Else
' RUN_ON_SPECIFIED_PLATFORMS is set.
Win7OK = FALSE
For Each myOS in program.SupportedOperatingSystems
osver = Left(myOS.MinVersion,3)
If osver="6.1" And myOS.Platform="I386" Then
Wscript.StdOut.Write "OK for Windows 7" ' Name: " & myOS.Name & " MinVersion: "& myOS.MinVersion & " MaxVersion: " & myOS.MaxVersion & " Platform: " & myOS.Platform
Win7OK = TRUE
Exit For
End If
Next
If Win7OK = FALSE Then
'Add Windows 7 32bit platform
' Create 
Set tempSupportedPlatform = connection.Get("SMS_OS_Details").SpawnInstance_
' Populate tempSupportedPlatform values.    
tempSupportedPlatform.MaxVersion = "6.10.9999.9999"
tempSupportedPlatform.MinVersion = "6.10.0000.0"
tempSupportedPlatform.Name       = "Win NT"
tempSupportedPlatform.Platform   = "I386"

' Get the array of supported operating systems.
tempSupportedPlatformsArray = program.SupportedOperatingSystems   

' Add the new supported platform values (object) to the temporary array.
ReDim Preserve tempSupportedPlatformsArray (Ubound(tempSupportedPlatformsArray) + 1)
Set tempSupportedPlatformsArray(Ubound(tempSupportedPlatformsArray)) = tempSupportedPlatform

' Replace the SupportedOperatingSystems object array with the new updated array.
program.SupportedOperatingSystems = tempSupportedPlatformsArray

' Save the program.
program.Put_

' Output success message.

Wscript.StdOut.Write "Added Win7"
End If
End If
End If        
Next 
End Sub 

Saturday, September 11, 2010

SyntaxHighlighter with Blogger

I've been away from Blogger for a while, and I'm happy it got some new templates.
I've implemented a syntax highlighter to better view code, it's called SyntaxHighlighter.
Here are the steps to use it on Blogger

  1. Download SyntaxHighlighter to your computer
  2. Create a "Google Site" if you don't have one yet
  3. Create a "File Cabinet" page
  4. Upload the "shcore.js", the css files and the brushes (=code highlights for specific languages) as described in the SyntaxHighlighter installation notes
  5. Edit your Blogger template, link the js files and css in to the files you've uploaded (copy the link from "Download" on the file cabinet)
  6. Use the 'pre' method as described in the installation notes
  7. Don't forget the inclusion of SyntaxHighlighter.all()

Wednesday, January 27, 2010

As part of a job interview, I was asked to program a VB script.

The goal was to:
"Disable LAN,WAN,Bluetooth devices as soon as any user (except shopAdmin) makes a login to the Computer (VB).
Hint this is only possible with the extra software piece called Devcon"


How do I start?
  1. search on the internet to see if someone else did it. If I judge it's well done, why reinvent what has already been invented?
  2. search in my scripts if I've already done it or part of it. Most likely, I will reuse generic scripts I made.

In this case, the "hint" meant that since a command line program would be used, some string parsing would be involved. A few Google searches turned up some ideas but nothing as complete as what was requested.

'Assuming devcon is the WINDOWS folder
'Assuming the logged on user has the right to disable devices.

LANadapter = "Broadcom Loca Network Adapter"
BTadapter = "BT adapter"
WLANadapter = "Dell Wireless 1470 Dual Band WLAN Mini-PCI Card"

Set objShell = WScript.CreateObject("WScript.Shell")

Set objNet = CreateObject("WScript.NetWork")

If Not objNet.UserName = "shopAdmin" Then
Set objExecObject = objShell.Exec("cmd /c devcon listclass Net")

Do While Not objExecObject.StdOut.AtEndOfStream

strText = objExecObject.StdOut.ReadLine()

If Instr(strText,LANadapter)>0 Then
ID = Split(strText,"\",3)
Set objExecObject = objShell.Exec("cmd /c devcon.exe disable " & ID(0) & "\" & ID(1) )
WScript.Echo "LAN disabled"

ElseIf Instr(strText,BTadapter )>0 Then
ID = Split(strText,"\",3)
Set objExecObject = objShell.Exec("cmd /c devcon.exe disable " & ID(0) & "\" & ID(1) )
WScript.Echo "Bluetooth disabled"

ElseIf Instr(strText,WLANadapter)>0 Then
ID = Split(strText,"\",3)
Set objExecObject = objShell.Exec("cmd /c devcon.exe disable " & ID(0) & "\" & ID(1) )
WScript.Echo "WLAN disabled"
End If

Loop
End If