Category Archives: Others

Force directly linked file to download

Is there any way to provide a direct link to a file & force the browser to download it using PHP?


We’re dealing with huge files here & Chrome in particular seems to have a problem rendering the image, so all the user sees is a blank screen when visiting the file directly. Even though they can still right-click in the blank screen & download the file it’s confusing.

We used to output the files from PHP yet we ran into memory problems so switched to providing a direct link instead. The files go up to approximately 5GB, they aren’t all images. We have zips, PDFs, PSDs etc.

Currently, the file is requested through a PHP script which accepts the ID of the file & obtain its URL. The PHP script then redirects to the user to full URL of the file.

How can we ensure that downloads are forced & we don’t run into memory issues with the larger files?

Thank you

Just use X-Sendfile yet you need to configure it first … using XSendFilePath

Note* Please ensure $file is properly escaped before you verify & serve the file

XSendFilePath only works on Apache for other servers please see : Caching HTTP responses when they are dynamically created by PHP

Oracle extract values from xmltype

This is the code I am currently using:

The above code uses xml to extract & save the existing node values to particular local variables. It is been used in the case for multiple sets of data & is working fine. I just wanted to know whether can I able to use the same without “for x loop”, because I will only have one data in the i_xml from now onwards & I will only have either
name or age tags .

The following code should be used to save into l_name or l_age without the “loop” method like I used above:


And I’ve tried using the following:

Any better way is appreciated.. Thanks

If you’re really sure you’ll only have one ROW then you can do:

That will work if you have name or age, or both, or neither (where ‘work’ means doesn’t error, at least). If you did have more than one row it would concatenate the results, so with your original data, l_name would be aabbb, & l_age would be 2025. Which might not be what you expect.

opencv – how to save Mat image in filestorage

I want to save a floating point one-channel image & I don’t want to convert it. So I decided to use filestorage class to save it yet I couldn’t quite obtain how to do it from the documentation. And what I tried didn’t work. Can anybody assist me with this?

Writing to file

Reading from file

Dojo, setAttribute with Internet Explorer

I’m working on a web application that I didn’t make myself & it has been done using Dojo & specially Dijit.
The part which I’m struggling with is approximately a form that gets changed depending on radio buttons.
Therefore, I’m using dijit.byId('id').setAttribute('disabled',true); to disabled a field & this works on FF yet not with IE8. Although, it works yet not directly when I check the radio button, I have to do one more action (like clicking in a random area on the page) & the action is applied. I tried with stuff like: document.getElementById('id').disabled=true; yet it doesn’t work correctly either.

Would you please have any suggestion?
Thank you.

Dojo Widgets have a convention to set attributes using the set method.

This convention will call the _setDisabledAttr method on the widget which will take care of making itself disabled.

what is white color in GetPixel() method? [on hold]

as you can see from topic I just have a very simple question:

what is the RBG value of white color in GetPixel() method?
is it 255 255 255?
or 0 0 0?


White = 255 255 255

Black = 0 0 0

There’s an effortless code to check it

Python requests hook returns a value to cause exception

The Documentation for python requests module says for hooks that “If the callback function returns a value, it is assumed that it is to replace the data that was passed in. If the function doesn’t return anything, nothing else is effected”

Now i am trying to return a value(int in my case) from my hook function & it throws an exception. This will be valid in all the cases when the return value is an object that DOESNOT have the raw() method defined for it.

Here is some code

And here is the exception:

The code in @line 446 is trying to extract cookies after the dispatch_hook..From source

Either the documentation needs to alter or the handling needs to be re-worked. What is the best way to handle this ?


Based on the comments I tried to return the base response object. Turns out it cannot be used in that manner moreover since some of its fields are initialized to None.

Newer code:

Exception thrown now:

What seems is that i will have to implement a full pseudo response?

If the callback function returns a value, it is assumed that it is to replace the data that was passed in. If the function doesn’t return anything, nothing else is effected.

This means that whatever you return is expected to take the place of the response object you were passed.

Nothing in the documentation states that you can return just anything. What did you expect to happen instead?

If you wanted to return a response that has different data, return something that acts like a response still. This means that either you need to subclass the requests response object, or implement something that provides the same API:

You may want to copy over some of the other attributes from the original response; check the documentation on what attributes Response objects have.

Create Access Point in Windows 7 For Android Device instead of ADHoc

This tricks shows how to create a Access Point instead of ADHoc network on your Windows 7 in order to allow the user to create
For those user who need Android device to connect to ADHoc network, this is the best alternative way to connect internet through your laptop. NO ROOT Required

1. Create a hosted network
run CMD as administrator, & type

2. Open the Control Panel->Network & Internet->Network Connections
Right click the internet connection adapter & select Property, click Sharing tab, & tick allow other network users to connect through this computer’s internet connection. Select the connection name of Microsoft Virtual Wifi Miniport Adapter. Normally, it is namely “Wireless Network Connection 2” or “Wireless Network Connection 3”

3. In command prompt in step 1. type

This will create a Access Point instead of ADHoc & it is connectable by any Android Device.

In future, after you restart your computer, you can always run “netsh wlan start hostednetwork” to start the Access Point.

Trouble Shooting:
If you installed some third party VPN software it may breaks the connection, if you find you can connect to the network yet internet does not work, try to uninstall any third party VPN software & try again.

Glassfish stream mp3 for HTML5 audio to IE 9

By default, Glasshfish handle the MIME-TYPE as audio/x-mpeg for mp3 file, thus IE 9 can not play the mp3 with HTML5 audio object.

The solution is:

Open the Glassfish/domain/domain1/config/default-web.xml


and alter it to

Restart the glassfish & now IE 9 should be able to play mp3 file without problem.

Don’t forget to define following tag in your HTML file

Make Chameleon wowpc.iso boot OSX86 by default

This article introduce a simple way to alter the chameleon boot in Mac OS by default, this method suit for any one installed Chameleon on Windows drive to make dual boot.

1. Open a terminal window & mkdir bootmedia

2. open wowpc.iso in Finder, & copy all files to bootmedia folder.

3. Edit bootmedia/Extra/ file with text editor, add

<key>Default Partition</key>


then save it.

4. Now rebuild the wowpc.iso file & replace the one in your windows partition.

5. Replace the original wowpc.iso file in your windows drive.

[Guide] Install 10.6.8 on AMD, getting around all errors (pci configuration)

Before you install

  • Download my Zip from rapidshare
  • Unzip
  • Burn The mod CD to a disk
  • Go out & “buy” a copy of 10.6.3 or 10.6.4
  • Reboot & go into bios
    • Make sure the drive you are installing to is set to AHCI
    • Turn off Cool N’ Quiet
    • Turn off C1E


  • Boot from that Mod CD that you burned earlier
  • Wait till it shows the nawcom chameleon screen, insert the 10.6.3 or 10.6.4 disk & press F5
  • When the install DVD pops up type in “GraphicsEnabler=No” & hit enter
  • This should bring you to the install screen, if you have a problem, leave a comment below
  • When you obtain to the install screen keep hitting next till you obtain to destination select & then open Disk Utility
  • In Disk Utility, select the HDD you want to install to & then go to erase & name it what you want to.
  • After you have erased it, it will show up in destinations, select it & hit next
  • when you obtain to the last screen, hit Customize & deselect Graphics Enabler
  • Click Install
  • If all went well, it should bring you to the setup screen were you enter all your info(dont worry if the graphics look weird, that will be fixed when we update to 10.6.8)
  • Go through everything, & then transfer the folder from the zip on to the mac desktop

Updateing to 10.6.8 to donate you the app store & full graphics support

  • Download & install the 10.6.8 combo update (DO NOT CLICK RESTART!!!)
  • With the 10.6.8 window still open, go into the folder from the zip
    • Open up the legacy kernel package & complete installing that
    • Open MultiBeast & install the IOUSBFamily Rollback & System utilities ONLY
    • Once that is complete, go in the Kexts folder, & open up Kext Wizard
    • In Kext Wizard, go to the Installation tab, find & select the 2 kexts in kexts folder, click the System/Library/Extensions button, & click install
    • Once completed, go into Maintenance click on the System/Library/Extensions button, & then click Execute
    • After it is done(it takes a while), close Kext Wizard
  • Go back to the combo update window, & click restart

Your Done!

(Hopefully, if you have any problems leave a comment & ill try to assist you)