Monday, December 20, 2010

Speeding up torrents in uTorrent

Most common reason for slow torrents is that the number of seeds are low or the upload speed of the seeds is limited. To overcome this problem

right click the torrent in uTorrent and select copy magnet URI. The magnet URI is similar to
magnet:?xt=urn:btih:RB4BJJ65RL6OEA5STGYG4ER6WW2K5DFX
here RB4BJJ65RL6OEA5STGYG4ER6WW2K5DFX is a 32 bit hash code

go to http://darkfader.net/toolbox/convert/ and convert the 32 bit hash code into 16 bit hash code. And search for the resulting 16 bit code. The search will give alternate download locations. Download the .torrent files add them to uTorrent and allow uTorrent to add trackers from the file.

This approach will be helpful if the availability of the torrent is low or to verify the authenticity of the torrent

Thursday, November 25, 2010

Take snapshot of an web page

After some searching i found CutyCapt to suit my needs.

After successful installation it gave me the error
QPainter::begin: Paint device returned engine == 0, type: 3

After some searching i found out that that error means that QImage::__construct is failing.
The constructor is failing because i am behind a proxy and CutyCapt did not find any content to create an image

./CutyCapt --url=http://www.google.org --out=example.png --http-proxy=http://144.16.192.245:8080

worked finally

Sunday, November 21, 2010

Apache Mod Rewite

Apache Mod Rewrite is enabled and Rewrite Engine is on, yet rewrite is not working

Likely reason is that AllowOverride is set to None. Changing back to All will resolve the problem
If the problem persists try
RewriteLog logfile
RewiteLogLevel level; 0 - no log 9 - highest 
No log means mod_rewrite is not executing

Saturday, August 21, 2010

xmanager for linux

The title may seem stupid. But believe me that is what I have searched for. I wanted to run the applications of a far_away_computer on a local_computer as of they are applications of local_computer
The steps

  1. In the sshd_config if far_away_computer check for

    X11Forwarding yes
  2. On the local_computer edit ssh_config to have

    ForwardX11 yes
    or use the -X flag every time u connect to far_away_computer
  3. Once you are connected to far_away_computer from local_computer, start xterm on the far_away_computer.

Both ssh_config and sshd_config will be present in either /etc or /etc/ssh

Sunday, August 15, 2010

disable zend layout on home page

$this->_helper->layout()->disableLayout();

where $this represents the controller

Zend Router application.ini

if you want http://domain.com/user to be mapped to http://domain.com/index/index/username/kranthi
use this in your application.ini file
resources.router.routes.route_id.route = "/user/:username/*"
resources.router.routes.route_id.defaults.controller = "index"
resources.router.routes.route_id.defaults.action = "index"
resources.router.routes.route_id.defaults.username = "kranthi"

this code executes before transferring the control to the controller

in zend docs it is mentioned
$router = $ctrl->getRouter();
here $ctrl is an instance of Zend_Controller_Front and should be declared before running your bootstrap file in your index.php (single point of entry) file
$ctrl  = Zend_Controller_Front::getInstance();
$router = $ctrl->getRouter();
.
.
.
$application->bootstrap()
            ->run();

Monday, August 9, 2010

Datatype mismatch

Dont use the typecast blindly. Make it a practice to log datatype mismatches

Saturday, August 7, 2010

Syntax highlighter for this blog

Typecasting to int or float

easy solution is
$val = $val + 0;
And PHP will take care of the rest.
If you want to ensure that the variable is integer is_numeric is the way to go. is_int and is_float will be of little help here.
Also note that will always evaluate to true
if ((int)$value == $value)
that is because of the internal typecasting of the equality operator

Monday, July 26, 2010

absolute positioning not working in firefox

position: absolute works in Firefox. Most likely the top and left attributes are not specified. An important point to note here is that firefox does not allow tags like top: 124 px; note the space between 124 and px. Or may be it is an issue with the padding of the parent element. Either way firebug is an excellent tool to debug css issues in firefox and chrome

Tuesday, July 20, 2010

Virtualbox Bridged Adapter Linux

Host OS: 2.6.32.12-115.fc12.i686
Guest OS: Windows XP

Error:
NAT connection is working fine and mine is a wired connection but when I try to connect via bridged adapter I get
Failed to open/create the internal network 'HostInterfaceNetworking-eth0'
(VERR_SUPDRV_COMPONENT_NOT_FOUND)
moreover
-bash: /etc/init.d/vboxdrv: No such file or directory

Solution: Run following as root before launching VBox

insmod /lib/modules/`uname -r`/extra/VirtualBox-OSE/vboxnetflt.ko
insmod /lib/modules/`uname -r`/extra/VirtualBox-OSE/vboxnetadp.ko

Virtualbox Shared folders Windows XP Guest

  1. Install VirtualBox guest additions from http://dlc.sun.com.edgesuite.net/virtualbox/
  2. Share the folder from devices menu of virtualbox window
  3. Windows Explorer->tools->folder options->select classic windows
  4. Windows Explorer->my network places->entire network->virtualbox shared folders
  5. For write access add a new network places with a different name from the name given in VirtualBox

Saturday, May 29, 2010

Thursday, May 13, 2010

Wanna learn something new? Ensure u know the prerequisites.

As a first step of learning ZF I've developed a simple blog after I've finished the quick start guide. Unfortunately, I did not care much about the RewriteEngine. So, when I tried to include an external css file I got an error saying
Invalid controller specified (css)
Now I tried creating
css/global.css
in my document root (with out any content). Even that did not help. As a final resort I tried putting some text into css/global.css And viola!! That worked.
If u are new to ZF I recommend to get the basics of mod_rewrite

Wednesday, May 12, 2010

Logs are there for a purpose

If u ever encounter 500 Internal server error, 403 Forbidden, 404 not found errors the best place to check will be the log files. Moreover ensure you use RewriteLog every time You use RewriteEngine

A chain is only as strong as its weakest link

In the qualification round of GCJ '10 there was a problem involving integers ~1050. I had to use gmp_* for that. Every thing worked fine for a small data set. But the program gave unexpected results for a large dataset. Then I realized that I've used mod in my code. Replacing that with gmp_mod did the job.