PHP : Set document root to be a subdirectory without .htaccess or Virtualhost
Recently I faced a problem with hosting a website on a server to which I have limited access. I was provided with permission only to a sub-directory on the server.
I'm habituated to use relative paths, but my root points to the root of server and not my sub-directory. This forced me to use absolute paths at every point.
I searched for the solution and end up with two results:
.htaccess ot Virtualhost
I never tried to understand .htaccess and I don't have access to set Virtualhost. This forced me to try bit harder and here is the outcome.

I've created a file named rootpath.php on root directory of my website.
(Note: this is not root '/' of the web server, but my sub-directory)
Its contents are as follows:
<?php
    $relative_path = "/subdirectory";
    $server_url = $_SERVER["SERVER_NAME"];

    $root = "http://" . $server_url. $relative_path;
?>
Now, I include this file on top of every file.
Eg: <?php require('rootpath.php'); ?>
and append all paths with <?php print $root; ?>
Eg: <a href="<?php print $root; ?>/index.php">
Note: Initially I used './' and '../' notation, but it won't work always. Consider the following case, which I faced:
/index.php
/header.php
/footer.php
/scripts.php
/contact
--contact/contact.php
I defined a common header for all the pages and stored it in header.php, which in-turn imports all the necessary scripts from scripts.php.
Now, if you import header.php from contact/contact.php, it work work properly because scripts.php is loaded relatively in header.php and now the control searches it in contact directory.
Find an old archived link on web
In recent past, I'm need of a tool, to which the provider no longer provides the link to download. Previously I've blogged about Openlogic, which serves this purpose.
Openlogic contains unofficial fork of the original repository, and to be precise, I haven't found the tool I'm in search of. I found Internet Archive : Wayback Machine, while searching for it.

It has got 412 billion stored pages and you may look into older versions of any website or you can get link to any software/tool which used to be a website.
All you have to do is, provide a link or part of a link to search.

For example, to know how my website used to be in 2013, just type
http://www.thechaithanya.com
and you can see a calender with some of the dates highlighted, on which they had the snapshot of my website.

You can even provide a part of link. For example, to get the link of older version of Android ADT, search using
http://dl.google.com/android/adt/*
You can find a set of links and pick your Magic Wand.
Mac: AppleIntelCPUPowerManangement Kernel Panic
After upgrading from Mac OS X Mavericks 10.9.2 to 10.9.3, my machine (HP Probook 4530s) ran into AppleIntelCPUPowerManangement Kernel panic, and to my surprise none of the boot flags helped me to boot into the system.
I decided to do a fresh install, but even booting from USB resulted the same. Then I decided to remove AppleIntelCPUPowerManangement.kext, but I can't even access terminal.

Here's the solution:
My machine dual boots Windows and Mac.

  1. I logged into Windows
  2. Installed MacDrive, trial version
  3. Rebooted into windows and opened the drive on which Mac is installed
  4. Did two things, don't know which one helped:
Opened /Extra/org.chameleon.Boot.plist with a text editor and added the following code:
<key>GenerateCStates</key>
<string>No</string>
<key>GeneratePStates</key>
<string>No</string>
And deleted AppleIntelCPUPowerManangement related kexts from this directory:
/System/Library/Extensions/
I found two kext folders related to it and deleted both.

Rebooted without any boot flags and voila. It worked.
Mac: Access Mac formatted (HFS+) disks from Windows Mac: Access Mac formatted (HFS+) disks from Windows
Recently I found a very easy and useful tool to access devices (USB, HDD, in-fact drive on which Mac OSX is installed), from windows.

MacDrive:
Once you install MacDrive, it will reboot and all the drives which are Mac-formatted will be mounted alongside the Windows partitions.
Having said that, there is a BIG problem. ITS NOT FREE. But, you can use the trial version, when in need.

Ubuntu: Directory size from terminal

In this post we gonna see how to find size of a directory from Terminal. To summarise disk usage of each file, recursively for directories, we can use the following command
du [option]... [FILE/Directory]...
To get the report in human readable format, along with the overall summary, use
du -hs /path/to/directory

To find sizes of directories recursively unto a certain depth (e.g.: depth = 2):
du -h --max-depth=2 /path/to/directory
Ubuntu: Proxy settings for Maven
Recently I faced problem using maven under a proxy network and by little research, found this solution.
Temporary solution:
Add the following options along with your maven command
-DproxySet=true -DproxyHost=myproxy.com -DproxyPort=3128
For example, to run "mvn package":
mvn -DproxySet=true -DproxyHost=my.proxy.host -DproxyPort=3128 package

Permanent solution:
To add the proxy settings permanently, goto {M2_HOME}/conf/settings.xml and find the <proxies> section. Un-comment the required sections and configure accordingly.
To set proxy without password protection, change it as follows:
<proxies>
   <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
  </proxies>
Change the words in italic format.
Ubuntu: Recent command history (terminal)
Hello guys,
In this post I'm gonna show you "How to display and play with a list of recent commands in Ubuntu?".
To check history of command or to get info about command executed by user, we can use the following command:
history
It will display the list of all the command executed, along with a serial number indiacating the oerder in which they are executed.

Now you may feel it dificult to find a specific command among them. In order to do so, we can combine the history with grep.
history | grep version
This will display a list of command in which the word "version" has appeared.

We can also execute a specific command by knowing its serial number from this list. After getting the result from history command, just type the number preceeded by ! to execute the command. To execute command which is at number 115 in the list, just type
!115
It will run the 115th command in the history list.

To re-run a recent command that starts with xyz, just type !xyz.
!histo
It may display the recent history, if no other command would have been executed after recent history command.

And the most commonly used reverse search:
Ctrl + R
After typing this command, type a keyword to search. When you found your command, just press enter.

Popular Labels

Featured Post (TOP)

Flickr Images

Follow Me on Facebook.com

Follow on Google+

Recent Posts

AD (728x60)

Pages

Powered by Blogger.

Labels

Followers

Popular Posts

Popular Posts

Subscribe Via Email

Sign up for our newsletter, and well send you news and tutorials on web design, coding, business, and more! You'll also receive these great gifts: