MongoDB Shell Cheat Sheet

I’ve been working with MongoDB for a little over a year now and one of the things that I’ve found that is missing from the community is a really good in depth full coverage cheat sheet for the Mongo shell.

I’ve recently just finished up the Mongo University courses for M101JS: MongoDB for Node.js developers, and M102: MongoDB for DBA’s and I wanted to have a 1 page reference sheet to summarize everything I had learned.

I’ve looked around the web and there are a few but they all are either several pages long which is not a real cheat sheet, its a short tutorial on different commands. I wanted a real cheat sheet. You know the kind that just lists all the API commands in reference format so you can look at it and be reminded of all the different commands and operators available.

So since I couldn’t find one I created one.

It contains everything I could fit on an 11in x 17in page sized for print. But in PDF form it also has every single command hyperlinked to its full documentation page in the MongoDB reference. So for those times when your not sure exactly what the parameters or options for a command are, you can just click the item in the PDF to go straight to the page in the MongoDB reference for full details.

MongoDB Shell Cheat Sheet for MongoDB v2.4

Feel free to leave corrections, comments, or suggestions for updates below. I’m also thinking of making a 2 page 8.5in x 11in version as well if I can make it all fit properly. I don’t think this version would be very legible printed on 8.5×11 scaled down.

Creating a UEFI/BIOS Windows 7 USB and installing to GPT partitions

I bought a new Asus Zenbook a few days ago and decided to format it and replace the win 7 home premium with bloatware with a clean install of win7 ultimate.

With no DVD drive you have to boot off USB to install it. Then I realized I’d never actually setup a bootable windows install USB before.

After some research I noticed it’s not as easy as it seems if you want to install on a UEFI computer that already has GPT partitions created.

Steps to create bootable Windows 7 USB for UEFI support and GPT partitions:

  1. Open a command line in administrator mode
  2. run DISKPART
  3. type LIST DISK
  4. Look for the disk number that represents your USB drive
  5. type SELECT DISK # where # represents the number of your USB drive. Get this right or you will wipe a different drive out.
  6. type CLEAN
  7. type CREATE PARTITION PRIMARY
  8. type SELECT PARTITION 1
  9. type ACTIVE
  10. type FORMAT fs=fat32
  11. type assign
  12. The drive should now be formatted and marked as active and fat32. Do not format the drive as NTFS or you will only be able to boot into the installer in BIOS mode.
  13. Now you will need to copy the contents of the windows 7 install dvd to the USB with a regular copy paste from windows explorer.
  14. Once this is done you will need to get a copy of the EFI boot manager firmware file from a computer that has windows 64 bit installed on a UEFI system.
  15. This file is located in C:WindowsBootEFIbootmgfw.efi
  16. On your USB (Let’s assume it’s drive E:) look in E:efimicrosoftboot and copy this boot folder up one level so it sits in E:efiboot
  17. Now copy the bootmgfw.efi file from your computer which has windows installed to this new E:efiboot folder and rename it to bootx64.efi
  18. Insert the USB in the machine and turn it on and boot into the UEFI/BIOS loader and check for boot options. On the ASUS Zenbook it detected two boot options on the USB drive. One was UEFI and one was regular BIOS. I made the UEFI option the first choice and restarted the machine.
  19. I could now install windows to the formatted existing GPT partitions that were on the machine.

The reason I didn’t want to install in a regular BIOS MBR scenario is because there are recovery partitions on this drive that are GPT as well and to convert back to MBR from GPT you have to delete all partitions on the drive which would have caused me to lose my recovery and data partitions.

This solution was perfect and gives me the added bonus of UEFI and GPT partitions.

If you need to find out if you have booted into BIOS mode or UEFI mode when the installer starts you can press SHIFT+F10 when the welcome installer shows up to open a cmd prompt. from here you will likely be at X:Sources. Type cd .. to go back a dir and move into WindowsPanther

Then type notepad setupact.log

Within this file do a ctrl+f and search for

    Callback_BootEnvironmentDetect: Detected boot environment:

It should either say BIOS or UEFI.

Don’t let yourself get scammed by Rogers telecom. Check your bills.

The TLDR summary of this article is this: Switch to Teksavvy for internet in Canada if you can get it in your area and stay away from Rogers under all circumstances.

Our monthly usage

I noticed a problem with our internet bill from Rogers the other day and started to investigate what was going on with significant overage charges on our account over the last few months with Rogers.

It turns out that without notifying us, Rogers increased our internet plan from $59.99 a month and $3.00  per month modem rental, to $61.99 a month and $4.00 a month modem rental. They moved us onto the ‘Rogers Extreme’ plan without telling us and charged us more. The Rogers Extreme plan offers 28mbps download speed (the speed you can download files at), and 120GB per month of bandwidth allowance (the amount of data you can download per month).

Rogers Extreme plan
Rogers Extreme plan modem options

What Rogers did (and has done to possibly tens of thousands of other customers) is kept us on our old plan details of 10mbps download speed instead of 28mbps, and 95GB of monthly bandwidth instead of 120GB which they are charging us for.

Our monthly usage since March has ranged from 92GB to 116GB keeping in line with the monthly allowance of 120Gb per month which we are paying for. However because they kept us back at 95GB we have been charged every month since march that we have gone over 95GB for overage fees on a plan that has enough monthly allowance (120GB) to cover our usage.

Monthly allowance on extreme not updated

Let’s take a timeout to explain the what the two metrics are on these internet plans. There is speed that data can come in and out at which is referred to as downstream and upstream speeds or download and upload speed. the plan provides 28mbps (mega bits per second) they are providing us 10mbps and claiming DOCSIS 2.0 modems do not support more than that and that we must pay more for a different modem. This is simply not true. The second claim is that an upgraded modem is required to get the full 120gb of download per month. The cap on the amount of bandwidth allowance has nothing at all to do with what kind of modem you have or even what speed you can get. Monthly bandwidth allowance is simply how much data you can download per month. You can easily download over 1000GB of data per month on a standard DOCSIS 2.0 modem at 10mbps speed.

Think of it like this: the speed metric is how much water you can push through the pipe per second so think a bigger radius pipe is more water per second. The monthly bandwidth allowance pipe is how many liters of water your allowed to consume per month in total. If you have a small pipe and leave the water on all month you can get just as much water through in the month as if you have a pipe that’s twice as big in diameter but you only leave it on for half the month. Monthly bandwidth has nothing to do with the thickness of the pipe, strictly how many liters you consume.

You could use the analogy of cars driving so many kilometers when you rent them from a rental company but imagine if you were also only allowed to drive a max of 100km/h but you could pay more for a luxury car to drive 150km/h instead as long as you only drive under the set number of kilometers for the rental, lets say 95KM a month.

Well they made us pay for a faster car and for more kilometers allowance per month but didn’t let us drive faster or farther as promised and then charged us extra for it for 5 months after they upgraded our plan to a bigger car without telling us.

This is where the nightmare of customer service begins. To summarize I will put the flow of conversation and details into point form.

  • We phone up Rogers customer service. My sister in law worked for Rogers for several years and knows how things work there. She gets us started with the first customer service rep.
  • We talk to this rep for about 10 minutes before being transferred to billing.
  • After a few minutes on hold the rep begins to tell us that we must upgrade to the highest end wireless modem for $7 a month in order for it to be possible for them to provide this service to us. This is an outright lie. Our modem is a DOCSIS 2.0 modem which they have documented in their system and which can handle speeds of up to 42mbps (http://en.wikipedia.org/wiki/DOCSIS). More than capable of handling 28mbps service.
  • Then the rep also tells us it is not possible to give us 120GB of monthly allowance without this top end modem and that’s why we have only gotten ‘the slower service’ because we haven’t upgraded our modem. Both of these statements are pure lies from a technical point of view and it just doesn’t make sense to say you cant download over 95GB a month because of your modem… but THEN BILL YOU OVERAGE  for going over 95GB of usage for a month. How can I not get over 95GB a month with this modem and then download over that and be charged for it then? I asked the rep this question and she was silent for about 20 seconds with nothing to say.

Regardless of the modem being insufficient they claim that there is only one modem which can be used with this service, yet have three listed on their website as compatible with this service. The standard modem being one for $4 a month. We do not want a wireless modem because we already have a wireless router here and adding a second wireless network is just going to cause more interference than we already have and there is no justification or written notice on Rogers website that says you _must_ use the upgraded modem. They clearly offer three options on their website as shown above and at http://www.rogers.com/web/link/hispeedBrowseFlowDefaultPlans under ‘hardware options’ or ‘hardware options which one is right for you?’ again clearly saying you have three options and explain how to choose which one you want.

  • At this point we ask to speak to the rep’s supervisor which is typical for Rogers customer service you usually have to go through 4-5 people before you get things fixed when they incorrectly bill you. (We have been over billed on cell service for over $400 in the last two years on two occasions and had to fight for 6 hours on the phone over 3 days to fix it last year.)
  • The supervisor tells us it is not possible to download over 95GB a month with our old modem and that’s why they wont upgrade our plan. This is again a lie and a misinformed, poorly trained service representative who knows nothing about technology.
  • We then ask to be sent to retentions. Retentions is the department in the Canadian telecoms that deals with the worst case customer service scenarios and who have the power to give you great discounts and bill adjustments to keep you as a customer. We have been customers with Rogers for over 10 years, paying an average monthly bill of between $200-$400 per month for various services over the years. At its peak we had HD cable, PVR, internet, home phone, and 3 cell phones with Rogers and were paying over $500 a  month before discounts. We have been excellent customers to them, We now have only internet and 2 cell phones on two accounts and pay about $250 a month to Rogers.
  • At this point we are put on hold for 35 minutes and then are disconnected after 1hour and 53 minutes on the phone with the first four reps.
  • We call back and get a new rep. We explain the scenario to him and how Rogers owes us $80 and needs to upgrade our plan to give us the service we have been paying for for the last 5 months. We politely ask him to please not hang up on us like the last lady did
  • He puts us on hold for 20 minutes, and hangs up on us.
  • We call back again for the third time to speak to our now sixth representative of the night. Our call time is now at over 2 hours.
  • We explain to this lady our story again all the way through from the beginning. She tells us it says right on the website that we need the higher modem to get this plans speed. We ask her to show us where and she leads us to the fine print details hidden in a small link at the bottom of the page that appears in a popup when you click it.
The fine print
  • No where in these details does it say you must get the $7 a month modem to get the plan it only says there is a $7 a month modem rental fee for the ‘N’ home networking modem which has a wireless router built in. The plan clearly shows three options for the service. Rogers is simply telling lies to avoid refunding the charges at this point. If we needed a new modem why did they not provide one to us.. OR TELL US THIS, after changing our plan, also without telling us.
  • We then ask to be sent to retentions again to speak to another rep.
  • This new rep is now our seventh rep we have spoken to. We explain our whole story to her and she says please hold. She comes back after about 10 minutes and says the best she can offer us is a $40 credit on our account.
  • So at this point Rogers has offered to return half the money they have stolen from us in overage fees so we will only be 50% scammed instead of 100% scammed.
  • The rep said absolutely nothing about any conditions for this credit or that we would have to remain as customers with them to receive it. She simply said I’m adding the credit to your account now and then said it had been processed.
  • Once the credit had been processed we politely asked to cancel our service and that we would be switching to Teksavvy. (Teksavvy has amazing plans at amazing prices and I don’t know why we haven’t switched sooner. Friends who have it all recommend it.)
  • At this point the rep said we didn’t inform her that we wanted to cancel our internet before offering us the credit and so she would have to remove it now. She didn’t say anything about having to remain a customer to receive the credit.
  • We said fine cancel our service we are done with being lied to by Rogers.
  • We are put on hold to be transferred to a cancellation department.
  • The 8th lady we have talked to for the night says “can I ask you the reason why you are cancelling sir?’ We politely say “Rogers has overcharged us $80 and is only offering to refund us half of it after changing our plan without notifying us and not giving us the service we have been paying for for the last 5 months”
  • The lady immediately and without hesitation says “What if I can offer you the full $80 refund, will you remain as customers?”
  • No talking to her boss or checking with a supervisor. She didn’t even check to verify the truth about what we said about the overage charges she just instantly offered us an $80 refund on the spot on the condition we stayed as customers for the next 30 days.
  • Her name was Monica, and she was amazing. She clearly informed us ahead of time what the conditions were, and didn’t hang up on us. That’s +2 right there against all the other reps we spoke to for the night.

We accepted the refund and will now call back in 30 days to immediately cancel our service with Rogers once our stolen money is returned to us and switch to Teksavvy for our Internet.

As soon as my contract expires with Rogers I will change my cell service to Wind Mobile or another provider as well.

The new company I work for is also collecting quotes on business internet service and large scale bandwidth and infrastructure hosting for a new software service I am building. Rogers will not be our service provider under any circumstances for our business internet line or our hosting provider. I plan to make the case to my CEO that we go with Teksavvy for all our services. They are cheaper, and have better reputation with regular Canadian internet customers. Their internet presence and their stance on Usage Based Billing in Canada makes them much more trustworthy than Rogers.

If you are an internet customer of rogers I highly encourage you to check your bills and see if you are being scammed into the new rates but given the old service speeds and call and complain about it furiously.

I cannot believe something like this is even legal in Canada. Maybe it’s not I am no lawyer.

 

Microsoft Dynamics CRM 2011 JavaScript Development Reference

I’ve been working on the development of a CRM 2011 deployment for a few months now and I’ve found myself poking around the web to all kinds of different websites looking for references to different parts of the SDK for JavaScript.

Now that I’ve become more familiar with the MSDN Library I’ve decided to compile all the major functions for the JavaScript reference into one easy reference point with links branching out to the MSDN library. The MSDN library is amazing but can be rough to navigate and find what you really want fast.

Hope others find this cheat sheet useful.

If you have anything to add, feel free to leave a comment.

Xrm.Page.context Methods

getAuthenticationHeader A deprecated method that returns the encoded SOAP header necessary to use Microsoft Dynamics CRM Web service calls using JScript.
getCurrentTheme Returns a string representing the current Microsoft Office Outlook theme chosen by the user.
getOrgLcid Returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the base language for the organization.
getOrgUniqueName Returns the unique text value of the organizations name.
getQueryStringParameters Returns an array of key value pairs representing the query string arguments that were passed to the page.
getServerUrl Returns the base server URL. When a user is working offline with Microsoft Dynamics CRM for Microsoft Office Outlook, the URL is to the local Microsoft Dynamics CRM Web services.
getUserId Returns the GUID value of the SystemUser.id value for the current user.
getUserLcid Returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the user selected as their preferred language.
getUserRoles Returns an array of strings representing the GUID values of each of the security roles that the user is associated with.
isOutlookClient Returns a Boolean value indicating if the user is using Microsoft Dynamics CRM for Microsoft Office Outlook.
isOutlookOnline Returns a Boolean value indicating whether the user is connected to the Microsoft Dynamics CRM server while using Microsoft Dynamics CRM for Microsoft Office Outlook with Offline Access. When this function returns false, the user is working offline without a connection to the server. They are interacting with an instance of Microsoft Dynamics CRM running on their local computer.
prependOrgName Prepends the organization name to the specified path.

 

Xrm.Page.data.entity Attribute Methods

Method Attribute Types Description
addOnChange All Sets a function to be called when the attribute value is changed.See also removeOnChange
fireOnChange All Causes the OnChange event to occur on the attribute so that any script associated to that event can execute.
getAttributeType All Returns a string value that represents the type of attribute.
getformat All Returns a string value that represents formatting options for the attribute.
getInitialValue boolean, optionset Returns the initial value for Boolean or optionset attributes.
getIsDirty All Returns a Boolean value indicating if there are unsaved changes to the attribute value.
getMax money, decimal, integer, double Returns a number indicating the maximum allowed value for an attribute.
getMaxLength string, memo Returns a number indicating the maximum length of a string or memo attribute.
getMin money, decimal, integer, double Returns a number indicating the minimum allowed value for an attribute.
getName All Returns a string representing the logical name of the attribute.
getOption optionset Returns an option object with the name matching the argument passed to the method.
getOptions optionset Returns an array of option objects representing the valid options for an optionset attribute.
getParent All Returns the entity object that is the parent to the attribute.
getPrecision money, decimal, integer, double Returns the number of digits allowed to the right of the decimal point.
getRequiredLevel All Returns a string value indicating whether a value for the attribute is required or recommended. See also setRequiredLevel
getSelectedOption optionset Returns the option object that is selected in an optionset attribute.
getSubmitMode All Returns a string indicating when data from the attribute will be submitted when the record is saved. See also setSubmitMode
getText optionset Returns a string value of the text for the currently selected option for an optionset attribute.
getUserPrivilege All Returns an array of privileges that contain Boolean values indicating if the user can create, read or update data values for an attribute.
getValue All Retrieves the data value for an attribute. See also setValue.
removeOnChange All Removes a function from the OnChange event hander for an attribute. See also addOnChange
setRequiredLevel All Sets whether data is required or recommended for the attribute before the record can be saved. See also getRequiredLevel.
setSubmitMode All Sets whether data from the attribute will be submitted when the record is saved. See also getSubmitMode.
setValue All Sets the data value for an attribute. See also getValue.

 

Xrm.Page.data.entity Methods

Method Description
addOnSave Sets a function to be called when the record is saved.
getDataXml Returns a string representing the xml that will be sent to the server when the record is saved.
getEntityName Returns a string representing the logical name of the entity for the record.
getId Returns a string representing the GUID id value for the record.
getIsDirty Returns a Boolean value that indicates if any fields in the form have been modified.
removeOnSave Removes a function from the OnSave event hander.
save Saves the record. This method has three possible parameters.

 

Form Event Handler Execution Context Reference

getContext Returns the Xrm.Page.context object.
getDepth Returns a value that indicates the order in which this handler is executed.
getEventArgs Returns an object with methods to manage the Save event.
getEventSource Returns a reference to the object that the event occurred on.
getSharedVariable Retrieves a variable set using setSharedVariable.
setSharedVariable Sets the value of a variable to be used by a handler after the current handler completes.

 

Xrm.Page.ui Methods

Method Description
close Closes the form.
getCurrentControl Returns the control object that currently has focus on the form.
getFormType Indicates the form context for the record.
getViewPortHeight Returns the height of the viewport in pixels.
getViewPortWidth Returns the width of the viewport in pixels.
refreshRibbon Causes the ribbon to re-evaluate data that controls what is displayed in it.

 

Xrm.Page.ui Control Methods

Method Control Types Description
addCustomView Lookup Adds a new view for the lookup dialog.
addOption Option Set Adds an option to an Option set control.
clearOptions Option Set Clears all options from an Option Set control.
getAttribute Standard, Lookup, OptionSet Returns the attribute that the control is bound to.
getControlType All Returns a value that categorizes controls.
getData Silverlight Web resources. Returns the value of the data query string parameter passed to a Silverlight Web resource. For more information, see setData.
getDefaultView Lookup Returns the ID value of the default lookup dialog view. For more information, see setDefaultView.
getDisabled All except SubGrid. Returns a value that indicates whether the control is disabled. For more information, see setDisabled.
getLabel All Returns the label for the control. See also setLabel
getName All Returns the name assigned to the control.
getParent All Returns a reference to the section object that contains the control.
getSrc IFrame, Web Resource Returns the current URL being displayed in an IFRAME. See also setSrc
getInitialUrl IFrame Returns the default URL that an IFrame control is configured to display.
getObject IFrame, Web resource Returns the object in the form representing an IFrame or Web resource.
getVisible All Returns a value that indicates whether the control is currently visible. For more information, see setVisible.
refresh SubGrid Refreshes the data displayed in a Sub-Grid
removeOption Option Sets Removes an option from an Option Set control.
setData Silverlight Web resources. Sets the value of the data query string parameter passed to a Silverlight Web resource. For more information, see getData.
setDefaultView Lookup Sets the default view for the lookup control dialog. For more information, see getDefaultView.
setDisabled All except Web Resources and SubGrid. Sets a value that indicates whether the control is disabled. See also getDisabled
setFocus All Sets the focus on the control.
setLabel All Sets the label for the control. For more information, see getLabel.
setSrc IFrame and Web Resource Sets the URL to be displayed in an IFrame. See also getSrc
setVisible All Sets a value that indicates whether the control is visible. For more information, see getVisible.

 

Xrm.Page.ui.controls Collection Methods

forEach Applies the action contained within a delegate function
get Returns one or more controls depending on the arguments passed.
Argument Return Value Type
None All the controls Array
String The control that matches the name Object
getLength Returns the number of controls in the collection

 

Xrm.Page.ui.navigation.items Collection Methods

forEach Applies the action contained within a delegate function.
get Returns one or more navigation items depending on the arguments passed.
Argument Return Value Type
None All the navigation items Array
String The item that matches the name Object
Number The item that matches the index Object
Delegate function (attribute, index) Any navigation items causing the delegate function to return true Array
getLength Returns the number of navigation items in the collection.

 

Xrm.Page.ui.formSelector.items Collection Methods

forEach Applies the action contained within a delegate function.
get Returns one or more roleForms.
Argument Return Value Type
None All the items Array
String The item that matches the name Object
Number The item that matches the index Object
Delegate function (attribute, index) Any items that cause the delegate function to return true Array
getLength Returns the number of roleForms in the collection.

 

Xrm.Page.ui.formSelector members

Member Type Description
items Collection A Collection of all the form items accessible to the current user.
getCurrentItem Method Returns a reference to the form currently being shown.

 

Xrm.Page.ui.tabs Collection

forEach Applies the action contained within a delegate function.
get Returns one or more tabs.
Argument Return Value Type
None All the tabs Array
String The tab that matches the name Object
Number The tab that matches the index Object
Delegate function (attribute, index) Any tabs that cause the delegate function to return true Array
getLength Returns the number of tabs in the collection.

 

Xrm.Page.data.entity.attributes Collection Methods

forEach Applies the action contained within a delegate function.
get Returns one or more attributes.
Argument Return Value Type
None All the attributes Array
String The attribute that matches the name Object
Number The attribute that matches the index Object
Delegate function (attribute, index) Any attributes that cause the delegate function to return true Array
getLength Returns the number of items in the collection.

 

Is Processing.js fast yet?

YES

One of my current projects I am working on is an educational game aimed at teaching the concepts of Mendelian Genetics to students.

What I’ve been working on for the last few days is optimizing the game for the web and iPad deployment.

My first shot at optimizations is making the game load up faster.

Comparing Processing.js to Native JAVA Processing on my PC I found the following results and they were surprising!

While the speed results for different pieces of code were different between browsers one thing was clear that the overall total time to complete running the setup() function was fastest in the browser in all cases except for IE9 and Safari on Windows 7. For individual test results only once was one piece of code faster in the JAVA environment compared to the browser.

Test System: Intel core i7, 12gb ram, Windows 7.

The green boxes show the fastest time for that section, when a time was within 1ms I have called it close enough to be a tie. I ran each test 5 times per browser and averaged the results to make sure there were no one offs.

Running the setup() loop to initialize the game

I’m sure I will be able to further optimize it in the next few days to be even faster this is just an initial observation. Now that I know whats slow I can work on some async loading or deferred loading. Or just better code.

How to install Windows Server 2008 R2 on Macbook Pro 2011

I recently took on the challenge of teaching a Windows Server 2008 administration course at Seneca College and I spent the weekend working on installing server on a laptop so I can demo it in class.

Windows Server 2008 R2 on Macbook Pro 2011

Sounds simple enough right? The thing is my only laptop is from 2007 and has no video driver for 64bit server so I cant attach it to a projector. Otherwise I could use my old dell laptop. So what I am working on is installing Windows Server 2008 on a core i7 Macbook Pro with 8gb of ram 🙂

I started off thinking I could just use boot camp assistant to install Windows 7 and then put Server 2008 inside a VM on Windows 7 with Virtual Box but the problem with that is I have to cover a lecture in one of the weeks on Hyper-V. Hyper-V is Windows Server’s virtualization hypervisor technology. You cannot install Hyper-V inside a VM environment and have a scenario where you have a VM inside a VM inside a host.

So my only option is to install Windows Server 2008 R2 as the main host and dual boot OSX Lion with it.

So to begin you’ll need to have a few things up front.

  • Windows Server 2008 R2 DVD
  • A USB with about 2GB of free space formatted as FAT32 not NTFS for storing boot camp support files
  • At least 60GB or more of free space on the HDD, I set aside 200GB (of 500GB total) because I may install Win 7 VM’s that can take 30GB+ each.

Steps involved:

  1. I started out by running the boot camp assistant in OSX. The boot camp assistant lets you download the Windows drivers for the Mac and stick them on a USB for later. It also helps you partition the HDD for Win7.
  2. Once you have a partition ready you’ll reboot and do a normal install of server by booting from the DVD. you’ll have to format the BOOTCAMP partition as NTFS for server. Make sure you dont format the wrong partition or you’ll could wipe out your OSX partition.
  3. Once the install finishes you’ll notice that there is a lot of devices that wont work. You can start by installing all the boot camp drivers on that USB from earlier that boot camp assistant created for you. WARNING: if you do not install boot camp drivers before rebooting you will not be able to press ctrl+alt+del to login to server because the option key is not remapped to alt until you install the bootcamp drivers. You can get around this problem by plugging in a USB keyboard to be able to press ctrl+alt+del.
  4. This will leave you with about 3-4 things still not working. Wireless, Video, Bluetooth, and sound will all not be working.
  5. Windows 7 and Windows Server 2008 R2 were developed in parallel and most windows 7 drivers will work ok in server 2008 R2 just fine. This is mostly the case for everything but video and bluetooth.
  6. The Macbook Pro I have has an Intel HD Graphics 3000 video adapter, and an AMD Radeon HD 6490M graphics card, bootcamp tried to install Nvidia drivers for my video from the USB.
  7. Windows Server 2008 R2 installs as a bare-bones OS with almost everything turned off. This includes wireless and sound. You will need to add the ‘Wireless LAN Service’ feature in Server Manager to enable wireless networking.

    Enable 'Wireless LAN Service'
  8. Sound can be enabled by trying to go into sound properties in control panel. You will get a popup saying the windows audio service is not enabled, do you want to enable it? click yes and your sound should start working and be adjustable by the mac volume keys.

    Enable Windows Audio Service
  9. I started searching the web for discussions about getting the audio working and came across a good post about catalyst not detecting the hardware but the drivers still being able to be installed manually.
  10. I was able to find two different versions of drivers one from ati.com and one from guru3d.com. I installed the one from Guru3D as it was 11.10 instead of 11.9 and it worked but once i enabled Hyper-V I started getting tons of blue screen errors revolving around atikmpag.sys.  When I did some searching I found out that when installing Hyper-V before SP1 on 2008 with Sandy Bridge chipset it can cause BSOD on video errors. And more specifically the AVX feature on Sandy Bridge chips was the cause. A hotfix is available here but I just installed SP1 instead. I ended up uninstalling the video drivers temporarily. If you find yourself getting blue screens boot into safe mode menu with f5 then press f8 for more options and choose last known good configuration and you should be able to boot up and uninstall the video drivers.
  11. If the video drivers are not installed you can probably safely installed the Hyper-V role now.
  12. Do all the Windows Updates now there will be probably about 120 of them in waves because some require others to be installed first. SP1 will show up in Windows Update after about 4 sets of updates. If Hyper-V throws an error saying can’t initialize a VM when trying to start it and the event log shows error 3040 its related to the SP1 fix and Sandy Bridge chipset most likely.

Enjoy.

How to setup Fedora Live 15 on Oracle VirtualBox

For the fall semester 2011 I was lucky enough to pickup a contract at Seneca to teach the ULI101 (UNIX/LINUX, Internet) course in the Diploma programs at the college. One of the weeks included a lecture on using Fedora Live. I decided to show my students how to use virtual box in the labs to use Fedora within a Virtual Machine environment. The infrastructure of Seneca’s computer labs is setup favorably for this way of using Fedora easily. VM’s have also become a standard in large corporate environments to help reduce the total cost of ownership on server hardware and to better utilize CPU cycles, power, and floor space in server rooms.

Below is a step by step guide to setup VirtualBox with the Fedora Live ISO on Windows 7.

Step 1: Download Fedora live cd ISO at:
http://fedoraproject.org/en/download-splash?file=http://download.fedoraproject.org/pub/fedora/linux/releases/16/Live/x86_64/Fedora-16-x86_64-Live-Desktop.iso

Step 2: Install virtual box. (Seneca lab computers already have it included in the image).

Step 3: Run Oracle VM VirtualBox Manager.

VirtualBox Manager

Step 4: Click New to create a new Virtual Machine using the Fedora ISO you downloaded.

Step 5: Click Next on the Create New Virtual Machine wizard window

Step 6: Setup OS

Step 6: Give the VM a Name you can recognize easily like “Fedora Live”, Choose “Linux” from the Operating System list and “Fedora (64 bit)” from the Version list.

Step 7: Allocate RAM for VM

Step 7: Set the memory to the amount of RAM you want to allocate to the VM. The default of 768mb is fine for most needs. Make sure this amount is less than the host machines total ram  minus 2GB to leave 2GB for windows 7 minimum.

Step 8: Create new hard disk

Step 8: Use defaults for Virtual Hard Disk at 8GB space and “create a new hard disk” options, click next.

Step 9: Select VDI option

Step 9: Use defaults for File type of the “virtual disk with VDI”, click next.

Step 10: Dynamically allocated HDD size

Step 10: Use defaults for “Dynamically allocated disk size”, click next.

Step 11: VM file size and location

Step 11: For Virtual disk file location and size you might want to have students put their VDI file on a USB so they can save it and reuse it in other sessions by remounting it. If they are just using it for one session and throwing away the VM each class session and recreating it then the default settings are fine.

Step 12: Press create to create the VM.

Step 13: Start up the VM for the first time

Step 13: Click on the new VM and press start to start it up the first time.

Step 14: Press next to begin, then select the ISO file for Fedora that you downloaded earlier. Press next.

Step 15: Click start to start up the VM.

Running the VM

Notes about using the VM:

When you click inside the VM sometimes the VM hijacks the mouse cursor to the window and wont let it move outside the window. To release it the default key is RIGHT CTRL.

you can map a CD or USB drive from the host machine to the fedora VM so you can access files from the local hosts CD, USB, DVD, or HDD even.

The VM will use whatever amount of RAM you allocated it in the setup from the host. If you set it to use 3GB and the host only has 4GB only 1gb would remain for windows which may cause slow downs or virtual box may not let you start the VM at all if the memory amount is to high that it would starve the host machine.

To close the VM you exit it the same way you would if the OS was running normally with Shutdown from the top right menu. the VM will shutdown and close its window automatically.

You can run the VM in fullscreen mode and it will operate similar to how a remote desktop session would work in windows with a small popup tab at the bottom center of the screen to switch back to windowed mode or close the VM window.

Creating custom JScript for Microsoft Dynamics CRM2011

I’m in the process of creating some custom JScript code to have some fields on an expense report form auto calculate and to enable one textbox if a certain expense type is selected.

I’ve been at this all day and I have been getting errors along the lines of “Error: Object expected” thrown at me from Dynamics when testing on the form.

It turns out the website I was using an example from used the quote characters “ ” instead of ” “.

It took me close to 4 hours to figure out why my ENTIRE SCRIPT LIBRARY was broken because of this when I was following some online examples exactly.

Yes that’s right my entire script library broke because one function had improper quotes and therefor a field object wasn’t being returned even though the function wasn’t being called it broke every other function in the library.

So word to the wise if you get an Error: Object expected in Dynamics CRM2011 check the following things:

  1. Is your field name spelled EXACTLY right including case? my_fieldname is not the same as my_FieldName
  2. Are there any spaces added by mistake in the name?
  3. Are you using the entity field name or the display name? entity name is correct EX: new_mycustomfield not “My Custom Field Label”
  4. Reduce down your JScript library and check for missing semi colons or other functions that may be broken to isolate the proper broken function it may not be where you think it is.
  5. Finally did you copy paste an example from another website? if so check the quotes to make sure they are the proper double quote character it should be ” “ not “ ”
EX: Xrm.Page.getAttribute("new_mycustomfield"); not Xrm.Page.getAttribute(new_mycustomfield);

As a side note always remember to add code to the onSave event handler for the form as well as the onChange handler for a field if you are using read only fields you need to forceSubmit those values to save them.

EX: Xrm.Page.getAttribute("new_mycustomfield").setSubmitMode("always");

Building a commercial game using Processing.js

Today I gave a presentation at FSOSS 2011 here at Seneca College on how we went about building a commercial game using Processing.js.

The presentation covered our development story. It covered what our industry partner does and why they wanted to change from Flash to Processing.js, our development story, and a demo of the game in its beta state.

I created the presentation using the deck.js library which allows you to create slide show presentations in a web browser using HTML and JavaScript. What’s cool about this is that it allows you to do things like put a HTML 5 canvas, audio, or video element in your slide.

With this library I was able to have a live demo of the game in a slide or embed other HTML 5 content.

Here is the video of our talk.

[tube]http://www.youtube.com/watch?v=-i5xSVJEbS8[/tube]

Building a 680 Megapixel image with Processing

For the last 4 months I have been working on a Game project with Processing and Processing.js at the Centre for Development of open Technology here at Seneca College.

This game is designed to help teach the basics of Mendelian Genetics to high school aged students and above.  The concept is to collect and breed different dragons and learn how the genetics of it all works because the offspring are created based on the genetics of the parents.

One of the challenges I ran into when building this game was figuring out a way to handle all the different combinations of dragons.  The dragons have 9 genetic traits that differentiate them from one another and each trait has two or three different phenotypes associated with it.  The end result is there are 2592 different dragons that can be created and collected in the game.

These dragons were being dynamically built from a combination of 27 smaller images and then blended together, colorized, and then had patterns applied to them.  In the native Processing JAVA environment this process took only about 100 milliseconds to build each dragon.  But in the Processing.js environment this process took 700ms on Chrome, 1000ms on Firefox, 2500ms on IE9, and a whopping 4500ms on Safari.

This created a lot of problems, such as slow script warnings, when there were more than 4-5 dragons to build on game load.

To solve this problem I created a sketch in Processing to dynamically build every combination of dragon and call save() on it from a PGraphic to save out an image for every dragon in the game.  Now with an automated build process I can quickly (roughly 5 minutes) generate all 2600 dragons into images and load them up with loadImage() or requestImage() in Processing.js significantly improving the load times when starting the game.

As a side challenge to this sketch to generate all the images I added some code to build a massive collage to stick in a copy of every dragon in the game in a giant PGraphics image.

PGraphics massiveImage = createGraphics(27648,24576,JAVA2D);

Immediately I had problems with this with not enough memory being able to be allocated to the JRE. Because java runs in a 32 bit environment for the PDE I could only allocate about 1600mb of ram to the environment. This meant I would have to create eight separate images and then composite them later in Photoshop unfortunately.  I was still able to do it though and through some crafty code I was able to make eight images that were 6144×13824 in size and then patch them together into a giant 680 megapixel composite image showing all 2592 dragons at 512×512 resolution.

reduced size collage of all 2592 dragons Generated with Processing

Compositing the image in Photoshop took 11 GB of ram, 679477248 pixels, and created a 60MB PNG image file in the end.

If I had been able to allocate 4-5GB of RAM to the PDE I think I could have generated the entire image in one shot and I would have liked to have been able to add a sitting and flying image of each dragon bumping up the resolution to 1.35Gigapixels in total.