James' Blog

James’ personal blog

You are currently browsing the Uncategorized category.

Image not refreshing reading from cache

I found this little trick when you have an image or some other object that needs to be refreshed but for some reason the browser is reading from the cache.

var timestamp = new Date().getTime();

Simple get the date and time from the above code and append that after a ‘?’ + timestamp after your image name. This will not affect the image that gets loaded and the browser will automatically reload the image.

Posted 15 hours, 56 minutes ago at 12:15 am.

Add a comment

Animated GIF not animated in Internet Explorer

Issue:  In order to show the user that the system is working during an AJAX call I use an animated gif.  A problem arose in Internet Explorer 8 that when I submitted the form the animated gif would stop and freeze.  This issue does not come up with any other browsers.  I looked for various solutions and some people mentioned resetting the img src in javascript or to use some time of setTimeout, but none of those methods worked for me.  

Here is the line of code that ultlimately worked:

document.getElementById('ajax_spinner').parentNode.style.display = 'block';

The only reasoning that I was able to find from the original poster was that it somehow established a connection with the parent node. In this case, I put a div tag around the image and set the style to display:none, so this line of code actually modifies the div which encapsulates the image. The image style does not control the visibility or display of itself.

*Update*
Additional I have found that putting this code in the onclick of a submit button does not work. I had to replace the submit button with a standard button and submit the form via javascript.
jQuery(“#my_form_name”).submit();

Posted 2 days, 14 hours ago at 1:15 am.

Add a comment

Sort array in Ruby on Rails

>> arr = []
=> []

>> arr << [3,2,1]
=> [[3, 2, 1]]

>> arr<< [1,2,3]
=> [[3, 2, 1], [1, 2, 3]]

>> arr << [2,1,3]
=> [[3, 2, 1], [1, 2, 3], [2, 1, 3]]

>> arr.sort{ |a,b| a[0] <=> b[0]}
=> [[1, 2, 3], [2, 1, 3], [3, 2, 1]]

Posted 1 month, 3 weeks ago at 9:26 pm.

Add a comment

Use Safari Mobile on your Desktop

On OSX,

Open Safari and go to Preferences

Under the Advanced tab, check “Show Develop menu in menu bar”.

Safari’s menu go to Develop->User Agent->Mobile Safari (there should be multiple versions) pick the most appropriate

Posted 5 months, 4 weeks ago at 12:15 pm.

Add a comment

Increase ESX Virtual Machine Size (ubuntu linux)

These instructions are to allow you to increase the size of a virtual machine’s harddrive.  This was done on an ESX 4.0 system running ubuntu 8.10 with thin provisioning, meaning the harddrive only takes up as much space as it uses.  The main problem was that the swap partition was created after the primary partition, so it would not allow the primary to expand to the “right” of the swap.  The solution was to delete the swap and then reallocate the partition, then recreate the swap.

This command may be done via ssh access to ESX to change the VM to use thin provisioning.

vmkfstools -i Ubuntu-s001.vmdk new.vmdk -d thin -a lsilogic
-increase the size from the vsphere client of the hardrive in question
-load gparted iso and set it to boot on startup from vsphere client
-Make sure the cd-rom is “conenct at power on”
-I deleted the linux swap partition (turned it off first) by right clicking on the swap partition
-then I was able to resize my primary partition
-recreated the swap partition at the end [primary + additional partition][swap]

Doing a “df -h” shows that the disk space was automatically recognized by Ubuntu after running gparted.

Posted 7 months, 2 weeks ago at 12:49 pm.

Add a comment

Using VMWare converter + ESXi 4.0 + RHEL 5.3

Installing ESXi 4.0 as the base metal Hypervisor OS.  I tried to use converter to create a VM image of various redhat machines.  Problems encountered with Converter:

1. Failed: File is larger than the maximum size supported by datastore

Solution: Split up the files to different datastores, or use Thin instead of Flat so it only takes the space used and not the full amount of allocated space for a partition.

2. Failed: MethodFault.summary

Solution: Changed number of processors from 8 to 4, because my VM server only has one quad core processor.

3. Failed: Unable to obtain the IP address of the helper virtual machine.

Solution: Assign a DHCP or static IP to the “Helper VM Network” at the bottom of the configuration.  Edit this value.

4.  Failed: An error occurred during the conversion.   Error: Failed to clone the volume mounted on ‘/boot’

Solution: Add the DNS suffix to the Helper VM Network.  Also, I needed to add the IP address to the hosts.allow in my Redhat Linux of the Helper VM, that I assigned in #3 from above.

UPDATE

5. Error: Failed to clone the volume mounted on ‘/’

Solution: again this was a problem with the fact that the machine to duplicate had the security settings setup to block the helper VM.  I had to add the entry into the hosts.allow.  But I can see other potential problems with the firewall (i.e. iptables) where certain ports must be open.  Here is a link to vmware showing which ports to open.

Posted 11 months, 4 weeks ago at 11:47 am.

3 comments

VMWare ESX on Workstation

I needed to do capture an existing physical machine to virtual (P2V) of an old linux box that was getting on in age.  I thought that VMWare would be the clear solution to capture this through the VMWare Converter tool.  Unfortunately, Converter doesn’t directly support capturing a linux machine.

The solution I found was to create a virtual VMWare ESXi OS install on my VMWare Workstation.  This was not very straight forward as ESXi 4.0 is only for 64-bit systems.  I found that ESXi 3.5 was 32-bit and decided to give it a try.  For some reason the ESXi install would not proceed correctly choosing to throw PANIC errors.  Later I realized that it was due to the fact that I did not allocate enough RAM to this machine.  The default value was 256MB and the solution was to up that value to over 1GB of RAM.  Then, I would get stuck during the installation in the first 10% or so and would just not move on.  I found the solution through a youtube video which showed that I need to select an Intel VT option for the processor settings.  This allowed me to continue with the installation.

Note:  On a Dell Quad-core server I had to enable the hardware Intel VT instructions.  Otherwise the installation of ESX may hang.

More to come…

ESXi booted up with some lvm error, but for some reason, I could not get an IP address.  Edited my myvmName.vmx file with note pad and added the blow lines.
Check out this video here


monitor_control.restrict_backdoor = “TRUE”
monitor_control.vt32 = “TRUE”
SMBIOS.reflectHost = “TRUE”
ethernet0.VirtualDev = “e1000″

After that I was able to get a DHCP address!  In my production environment we use static ip addresses, so for now I had to switch it to use NAT.

Now I can use Converter to capture a base virtual image of my remote physical machine.  Make sure to give root remote access rights and use the IP address of your server as the source.  For the destination, in a p2V situation using linux we can only use ESXi and so we need to capture to a VMWare Infrastructure virtual machine.  The IP address is that of your virtual ESX installation and don’t forget to set a root password, otherwise it will not work.

After the image was transferred, I used converter again to bring it over from the VMWare Infrastructure virtual machine to the VMware Workstation or other VMware virtual machine.  This allows me to open the vm from workstation instead of from ESX.  At some point I may deploy to an ESX installation but for now I am content to access my linux box from workstation.

Posted 12 months ago at 8:13 pm.

Add a comment

newline aka \n in an HTML Textarea

Typing \n printed out \n, typing <br/> printed <br/> in the text area.

Until I found this:     &#10;

Posted 1 year, 1 month ago at 9:59 am.

Add a comment

Installing Java6 on Mac…

…was a terrible ordeal. Apple provides 3 different updates for OSX 10.5 and I ran them all. Once I installed them, I did a java -version from the command line and it still said 1.5. Apparently, there’s a /Applications/Utilities/Java/Java Preferences.app program you can run to change these settings. I ran it and it didn’t seem to do anything, until I restarted (was it my computer or my terminal?). Then it seemed to work in user mode, but in root or sudo it still says 1.5. I ended up just writing an alias to the java I wanted
alias java=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java

Posted 1 year, 3 months ago at 2:05 pm.

Add a comment

Google Wave

Is a new developmental demo to explore what email would look like if it were implemented today instead of 40 years ago. The system keeps data on a central server instead of creating a copy for each recipient. Ultimately, this gives you (and everyone else) the ability to modify messages on the server. What that means is that it becomes an incredibly cooperative process because people can immediately see what is updated on a wave (the message). It leads to a bunch of different tools and gadgets that allow very impressive recording/playback and collaboration. Effectively, this char by char updating, from an html5 interface developed in GWT, looks almost like an instant message. Other features include drag and drop, inserting various media, and collaborative games.

*Twave is a twitter wave. Implements interface to post updates using Twitter.
*The system is very impressive, but it is still a little bit buggy since it’s still in development.

http://wave.google.com

Posted 1 year, 3 months ago at 11:08 pm.

1 comment