Sunday, May 24, 2009

My Simple facebook App - Sort of


I wanted to be able to browse my friends' profiles not just the list of things that comes to my facebook home. I found no quick easy way so I made my own.

A list of all my friends appears as a set of icons with names at the bottom of the web browser and facebook in the top half of the browser window. When you click on the icon of a friend their profile loads in the upper half. The friend window is resizable to make it easy to find a friend or so you can make it small and out of the way.

Unfortunately it is not really an app when I looked into making an app takes more than I have to give right now. I did use one of the simple developer tools online to dig the face book user id, name, icon, and link-too-profile for all of my friends out of my own face book account. Then set it up in a way I can use at home.

This is how:


http://developers.facebook.com/tools.php?api

I went to the facebook developers page under Tools / API test console I was able to run a couple simple facebook queries on my own facebook account. First a (friends.get) query with output set to JASON format to get the user id of all my friends. Jason format gives you a list of IDs seperated by commas which is what you need for the next step so copy that output and paste it in to notepad or any text editor.

The second query was facebooks getuser.info I pasted in my comma seperated list of user IDs then told it the info I wanted "pic_square,first_name,profile_url" the small picture, first name, and link to that profile. I set the output format this time to XML because I know how to turn that into a useable html web page with a simple xsl style sheet.

I copied the XML out put and put that in a file I called friendinfo.xml

XML is just the out put of data from a database wrapped by tags that show the name of that bit of data in the database.

Here's just the top 2 users of that long file:

   <?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="usericons.xsl"?>
<users_getInfo_response>
<user>
<uid>2790206</uid>
<pic_square />
<first_name>Karen</first_name>
<profile_url>http://www.facebook.com/profile.php?id=2790206</profile_url>
</user>
<user>
<uid>27903944</uid>
<pic_square>http://profile.ak.facebook.com/v225/1988/42/q2790394_8682.jpg</pic_square>
<first_name>Jennifer</first_name>
<profile_url>http://www.facebook.com/profile.php?id=2790394</profile_url>
</user>
etc. etc.

Before I could format it as a web page with the xsl stylesheet I had to modify just 2 lines in the XML output:
One I had to add this link to my xsl stylesheet as the second line:

 <?xml-stylesheet type="text/xsl" href="usericons.xsl"?>
Then I had to remove all the extra attributes that were in the users_getInfo_response tag. They refered to the facebook api addons junk you would only need for the original query.

Make it just a plain tag like this:

 <users_getInfo_response>

This was the XSL code i put in the file. It basically says for each user put first_name, pic_square, and profile_url in a div tag set to 80 by 60w pixels and uses the "float: left" so they will all hold to gether any shape or size browser window. It first sorts the output by first name.

 <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="users_getInfo_response">
<html><body>
<xsl:for-each select="user">
<xsl:sort select="first_name"/>
<div STYLE="height: 80;width: 60;float: left;font-size: x-small;
font-family: Sans-Serif;">
<xsl:value-of select="first_name"/>
<br /><a href="{profile_url}" target="Facebookmain"><img src="{pic_square}"
alt="{first_name}" /></a></div></xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Now that the XML was working like a web page of icons that were links to my friends profile pages. I needed keep both the icons and facebook in the same browser window. The easiest way to do that was make frames page. A frames page is an HTML web page that puts more than one web page in one browser window. I set up a small frame on the bottom and linked that with my XML. Then set the rest of the page to http://facebook.com. If you look in the XSL you will see the target="Facebookmain" in the link. Facebookmain was the name I added called the upper frame in my frames html page.


This is all that is in my frames page:

<html>

<frameset rows="*,125px">
<frame src="http://www.facebook.com/" name="Facebookmain" />
<frame src="friendinfo.xml" />
</frameset>

</html>

The three files I made have to stay in the same folder friendinfo.xml, usericons.xsl, friendframetest.html.

Run the HTML page and click through all your friends user profiles.

This could be so much more. This is just the most simple way to browse my friends profiles. It could be a stelar App in fact in the it should be part of facebook but in a cooler form.

Monday, May 18, 2009

Everything Everywhere is Empty Space

So I was reading the Einstein issue of Discover magazine and it was explaining relativity in a nutshell. It gave me a bunch of cool ideas that I was jotting down on post-its because I couldn't find a sheet of paper. It was fun for me so I thought I would lay them on you . . . all.

It was saying time was not fixed; the rate it passed got slower the faster you moved. Then in parentheses it said "(Gravity also slows the passage of time.)"

On the next page it was talking about gravity and said gravity is mass causing a distortion in space-time.

That really got me thinking, why would a distortion in space-time, gravity, change time in the same way as moving fast.

Then it hit me, space time is not merely distorted by gravity, space-time is always moving toward the center of gravity. Thus if you are motionless relative to the center of gravity you are moving quickly through space time. (or space time is moving quickly through you.)

If mass only distorted space-time in the wake of massive objects would be a region where it would push less massive objects away from each other or at least slow the rate at which they were drawn together. I've never heard of that so I think I'm right space-time is like a moving fluid.

That felt good so I kept reading and thinking.

Why does space-time affect matter why are matter (mass) and space time interacting. They must share part of their nature in common or they would not be rubbing up against each other like that. Either that or they both had way too much to drink.

Then there is energy and it also makes space-time behave like a fluid. Electromagnetic waves are ripple like changes in density of space-time. The more dense areas can behave like matter sometimes because matter also creates areas of higher density of space time. Higher density areas space-time in waves could be broken down into packets of denser space time and thereby behave like both particles and waves. I guess that could also explain particles that appear to have no mass.

OK, since mass and energy both interact with space-time, they are both in contact with space time in some way and therefore they share part of their nature in common with space-time. Another way to say that is they are related to space-time. A relationship can be expressed with and equation. In the same way Energy equals mass times the speed of light squared. E=mc2

You could say

(E=mc2) X some unknown factor = Space-Time

OR in other words

Everything everywhere is empty space

If I had to guess what the unknown factor was that could convert mater and energy into empty space I would have to say a black hole. Matter and energy go in but they don't come out. Another thing about black holes is that their super mass does not remain constant, if they are not feeding on mass around them they slowly loose mass and die.

Right now the biggest mystery in cosmology is why the expansion of the universe is expanding at a faster and faster rate. They are creating ideas like dark energy to explain the unknown repulsive force that is pushing the universe out.

Matter and energy being converted into space-time could explain why the universe is expanding faster and faster.

If Black holes are creating empty space that empty space is not showing up in areas of lots of matter. We would have detected that because it would show as objects near each other would not be attracted to each other as quickly as the force of gravity would predict. Therefore this new empty space would have to be added to the universe in areas with the least matter.

It just so happens that is exactly what cosmologists see in the expansion of the universe. The arrangement of galaxies in the universe has been described being like bubbles; mater filled areas surrounding large rounded mostly empty pockets of space with the most matter in areas where those "bubbles" meet.

Ok so now that I have answered a few of the greatest mysteries of cosmology and physics where do I pick up my check? This has to be worth a payday, who's going to cough it up?

Wednesday, May 9, 2007

CHANGING OVER A PC FOR A NEW USER in XP

Since new users are easy to add to a windows XP PC you may just think Every time a PC is reset for a new user just make a new user on the PC. But doing it that way means redoing a lot of user set up. Plus Some programs that are setup on the PC may even require you to set them up again, and surprisingly PC performance will slow for each new user profile you add. This slightly slower performance may have something to do with files arranged and optimized on the hard disk for the original user. So renaming the PC and the User profile is the way to go.

Here are some quick instructions for changing an XP PC for a new user. User profiles do involve passwords and if these instructions looks slightly different to you it may be because I wrote them for a Novell network environment.

  • At the PC first Log on to the network with your own username and password
  • Log onto the Windows user prompt as the administrative user. We have changed the name of the administrative user on our PCs but PC set up is another topic.

Remove user password

We try to keep the network and Windows password the same so users see only one password prompt. We Passwords rotate every 180 days. New Users get the default password “password” and will be forced to set one by the network at first login.

  • In the control panel got to User Accounts
  • Click on the staff person user
  • Click the Remove My Password Link - If it is not there is no password continue to next step

Rename the PC user

We name PC users with their campus network ID, shared PCs in any office get the default user name we arranged ahead of time.

  • Right click MyComputer
  • Choose Manage
  • Click Local Users and Groups Then Users
  • Right click on the user and choose Rename
  • Enter the name
  • Then double click on the user account and make the full name entry the same – it helps
  • Click ok and exit Management Console

Do not remove passwords using the management console

Rename the PC

We name each PC with the campus network ID of the user plus the letters PC at the end. If it is a shared PC we name it for its function like “acqoffice2PC” this name must be unique on the network.

  • Right click on MyComputer
  • Choose Properties
  • On the Computer Name tab click the Change button
  • Enter the name
  • Click the More button
  • Make sure it says “newpaltz.edu”
  • Click ok to the properties windows – If you have removed the password it is OK to reboot when prompted

Set Up Automatic Login on a Shared PC

Shared PCs or PCs that login automatically login to the network get the shared network user name we arranged ahead of time. We set up this account with limited network rights because it is used by student workers etc. We also set it up to login automatically and we in fact find this more secure than requiring a password and login for a shared pc. Whenever we have required a password the office invariably writes down the password and sticks it to the monitor for the whole world to read and share with friends.

  • Reboot the PC and login at the shared network user
  • Logon to the windows prompt with the user “staff” with no password or with whatever name you gave the staff user account.
  • Passwords should have been cleared in a prior step
  • We have placed a tool we got from the Novell cool tools web page called Autolog to set up automatic logins.
  • Set up automatic login with Autolog
  • We keep a batch tools folder on every PC with all our scripts and tools.

NOTE: Autolog has an excellent set off command line options with which to script logon we will see this again for changing login from batch files later in PCs in Public

Tuesday, May 8, 2007

Scripting Windows Update Avoids Errors Fixes Problems

The windows update service on the PCs at work has gone mad. In the past the Windows Automatic Update has been a really trusted ally on our staff Windows XP Professional machines until a couple months after the release of Vista. Gosh I wonder why? Now occasionally it seems to use up all the processor cycles and suck up every last k of memory during its search phase. Some of our newer faster machines were just crashing.
Our Public PCs have been using a script to do windows updates since I discovered the script on the Microsoft Developers web site more than a year ago. To modify it for use on our staff PCs I wanted to change it to only download Security and Critical Updates and not to install any update that required a user to answer prompts. We will turn off windows update and add this script to the Maintenance script that runs when our staff users leave for the day.
I found the information I needed to modify the script on a great scripting resource, Active Experts, they have a page that shows all the properties and methods you can script for in windows update. Bookmark the Active Experts site, they are wonderful, I found on their site a property of a windows update that tells you if it requires user interaction and I Scripted a check for that property before installing so it would not install those updates.
The fabulous, Hey Scripting Guy, website gave me the method to force a script to run in the command line CSCRIPT shell.
    The script has been:
  • Modified for getting only security and critical updates
  • look for the comments that start with "MY MOD -"
  • The action starts at the bottom of script setting types of updates then calls the function DoWindowsUpdates. Get All updates, and other update types can be setup at the bottom of this script.
  • Modified to reject updates that need user interaction from installing
  • Modified to only run at the command line with cscript.
  • Tested in Windows XP Professional XP sp2 and Windows Vista Business
  • Tested with PCs set up for Windows Update and also Microsoft Update.
  • Don't copy the code from the screen to use Download the zip file here if you are brave enough to try it.
The Code____________

' Modified for getting only security and critical updates
' look for the comments that start with MY MOD -
' BE WARNED Don't even bother trying this or any other script you find online if you don't have test PCs to waste
' any issues you have with this script are your responsibility
' There is a MOD below that forces the script to run from the command line CSCRIPT
' Starts at the bottom of script setting types of update call the function DoWindowsUpdates
' All updates and other update types can be setup at the bottom of this script
' Modified to reject updates that need user interaction from installing
' Tested in WindowsXP Professional XP sp2 and Windows Vista
' Tested with PCs set up for Windows Update and Microsoft Update
' ------------------------------------------------------------------------------
' Filename: WindowsUpdates.vbs
' ------------------------------------------------------------------------------
' Description: Automatically downloads and installs relevant updates
' ------------------------------------------------------------------------------
' Version: Beta
' Notes:
' ------------------------------------------------------------------------------
' Copyright (C) Microsoft Corporation 2005, All Rights Reserved
' ------------------------------------------------------------------------------
Option Explicit
' MY MOD - had to define aka dim the last four items in the line below to go with my mods
Dim I, I2, oSession, oSearcher, oSearchResult, oUpdate, oUpdatesToDownload, oUpdatesToInstall, oDownloader, oInstaller, oInstallationResult, installcount, strPath, strCommand, objShell

' ------------------------------------------------------------------------------
' create objects
' ------------------------------------------------------------------------------
Set oSession = CreateObject("Microsoft.Update.Session")
Set oSearcher = oSession.CreateupdateSearcher()
' MY MOD - This 7 line group below forces the script to run in the Cscript command line where it belongs
' Because of the Option Explicit above we must add every variable to the DIM line above
Set objShell = CreateObject("Wscript.Shell")
If LCase(Right(Wscript.FullName, 11)) = "wscript.exe" Then
strPath = Wscript.ScriptFullName
strCommand = "%comspec% /k cscript " & Chr(34) & strPath & chr(34)
objShell.Run(strCommand)
Wscript.Quit
End If

Public Function DoWindowsUpdates

' ------------------------------------------------------------------------------
' search for updates
' ------------------------------------------------------------------------------
WScript.Echo "Searching for updates..." & vbCRLF
WScript.Echo "List of applicable items on the machine:"

I2=0
For I = 0 To oSearchResult.Updates.Count-1
Set oUpdate = oSearchResult.Updates.Item(I)
I2=I2+1
WScript.Echo I + 1 & "> " & oUpdate.Title
Next

If I2 = 0 Then
WScript.Echo "There are no applicable updates."
Exit Function
End If

' ------------------------------------------------------------------------------
' create collection of upates to download
' ------------------------------------------------------------------------------
WScript.Echo vbCRLF & "Creating collection of updates to download:"
Set oUpdatesToDownload = CreateObject("Microsoft.Update.UpdateColl")

For I = 0 to oSearchResult.Updates.Count-1
Set oUpdate = oSearchResult.Updates.Item(I)
WScript.Echo I + 1 & "> adding: " & oUpdate.Title
oUpdatesToDownload.Add(oUpdate)
Next

' ------------------------------------------------------------------------------
' download updates
' ------------------------------------------------------------------------------
WScript.Echo vbCRLF & "Downloading updates..."
Set oDownloader = oSession.CreateUpdateDownloader()
oDownloader.Updates = oUpdatesToDownload
oDownloader.Download()

' ------------------------------------------------------------------------------
' create a collection of downloaded updates to install
' ------------------------------------------------------------------------------
WScript.Echo vbCRLF & "Creating collection of downloaded updates to install:"
Set oUpdatesToInstall = CreateObject("Microsoft.Update.UpdateColl")
installcount = 0
' MY MOD - this if else in the loop checks to see if an update in the collection requires interaction and rejects it
For I = 0 To oSearchResult.Updates.Count-1
Set oUpdate = oSearchResult.Updates.Item(I)
If oUpdate.InstallationBehavior.CanRequestUserInput="True" Then
WScript.Echo I + 1 & "> Not Adding Needs User Input: " & oUpdate.Title
Else
WScript.Echo I + 1 & "> adding: " & oUpdate.Title
oUpdatesToInstall.Add(oUpdate)
installcount = installcount + 1
End if
Next

' ------------------------------------------------------------------------------
' install updates
' ------------------------------------------------------------------------------
' MY MOD - this if else in the loop prevents the script from halting if all updates are rejected
If installcount = 0 Then
WScript.Echo "No Updates to install"
Else
WScript.Echo "Installing updates..."
Set oInstaller = oSession.CreateUpdateInstaller()
oInstaller.Updates = oUpdatesToInstall
Set oInstallationResult = oInstaller.Install()
End If

' ------------------------------------------------------------------------------
' output results of install
' ------------------------------------------------------------------------------
' MY MOD - this if else in the loop prevents the script from halting if all updates are rejected
If installcount = 0 Then
WScript.Echo "No Updates Installed"
Else
WScript.Echo "Installation Result: " & oInstallationResult.ResultCode
WScript.Echo "Reboot Required: " & oInstallationResult.RebootRequired & vbCRLF
WScript.Echo "Listing of updates installed and individual installation results:"

For I = 0 to oUpdatesToInstall.Count - 1
WScript.Echo I + 1 & "> " & oUpdatesToInstall.Item(i).Title & ": " & oInstallationResult.GetUpdateResult(i).ResultCode
Next
End if
End Function

' MY MOD - Had to find the category IDs and Numbers with type listed again for the controlling sections below
'CATEGORY_SERVICEPACK = "68C5B0A3-D1A6-4553-AE49-01D3A7827828"
'CATEGORY_SECURITYPATCH = "0FA1201D-4330-4FA8-8AE9-B877473B6441"
'CATEGORY_CRITICALUPDATE = "E6CF1350-C01B-414D-A61F-263D14D133B4"
'CATEGORY_UPDATE = "CD5FFD1E-E932-4E3A-BF74-18BF0B1BBD83"
'CATEGORY_UPDATE_ROLLUP = "28BC880E-0592-4CBF-8F95-C79B17911D5F"


' Installation Types Control the script really starts down here then calls the function above
' This group of sections sets what kind of updates the script will search for using category ID Critical security etc.
' The last group that is commented out does not use a category ID and tries to get all updates good after you install a PC from scratch
' Above is the Collecting Downloading and installing work
' GROUP 1
Wscript.Echo "Downloading and Installing Critical Updates"
Set oSearchResult = oSearcher.Search("IsInstalled=0 and Type='Software' and CategoryIDs contains 'E6CF1350-C01B-414D-A61F-263D14D133B4'")
Call DoWindowsUpdates
wscript.echo vbCRLF
' GROUP 2
Wscript.Echo "Downloading and Installing Security Updates"
Set oSearchResult = oSearcher.Search("IsInstalled=0 and Type='Software' and CategoryIDs contains '0FA1201D-4330-4FA8-8AE9-B877473B6441'")
Call DoWindowsUpdates
wscript.echo vbCRLF
' GROUP 3
'wscript.echo "Downloading and Installing Service Packs"
'Set oSearchResult = oSearcher.Search("IsInstalled=0 and Type='Software' and CategoryIDs contains '68C5B0A3-D1A6-4553-AE49-01D3A7827828'")
'Call DoWindowsUpdates
'wscript.echo vbCRLF
' MY MOD - GROUP 4
'wscript.echo "Downloading and Installing Every Singe Update ever Devised"
'Set oSearchResult = oSearcher.Search("IsInstalled=0 and Type='Software'")
'Call DoWindowsUpdates
'wscript.echo vbCRLF

Sunday, May 6, 2007

Here We GO!

I have been managing PCs in a library and in a classroom for 13 years. I have setup managing them in the most sophisticated way I could and tried to do it all for free and as cheap as possible.

I am going to get together all my notes scripts and batch files and try to give back some free information.

I hope this site will become a place where others share there PC support and management experience combine and improve on each others ideas.