This tutorial explains how to add a directory to system path.
- Open ~/.profile
- Add the path to the line PATH=”$HOME/bin:$PATH
- Use : to separate each path
- Save the file
- Log out and log back in
IT and anything that fascinates me
This tutorial explains how to add a directory to system path.
On my eclipse running on Ubuntu, I had just updated my Android SDK and was trying to run my android applications when I ran into the following error
error unknown option ‘–no-crunch’
android asset packaging tool
…
I thought I may be missing something, so I tried updating both my Android AVD and SKD but noticed another error while updating the SDK. The message was similar to the following:
Failed to fetch url https://dl-ssl.google.com/android/repository/repository.xml
In order to fix the problem of fetching the repository, I set the option to force https downloads to take place by http as advised by Vikram Pant in his blog.
To do this, I opened the Android SDK and AVD manager by going to <path to sdk>/tools/ directory.
Then I ran the following command :
$ ./android
Then I clicked Settings and checked the option to force https downloads to use http.
Next, I opened the Android SDK manager in eclipse. There were a few packages to install and others to update.
I first pressed the Delete Packages… button to delete the obsolete ones. Next, I pressed the Install Packages… to install fresh ones. That solved the problem.
This blog covers briefly how to log queries in MySQL.
As of MySQL 5.1.12. It is possible to switch on or switch off query logging during runtime. The following switches on query logging in runtime:
SET GLOBAL general_log=’ON’;
The following switches off general log in runtime:
SET GLOBAL general_log=’OFF’;
By default, the general log file used by MySQL is located at /var/lib/mysql/host_name.log in ubuntu, where host_name is be the name of your machine.
Here I present are few tips for writing HelloGridView tutorial on Google Android website – http://developer.android.com/resources/tutorials/views/hello-gridview.html
With javascript, it is fairly easy to transfer data between a popup window and the window which opened it. You can also call functions, or even set location of the opening window from a popup window. This is possible because a popup window holds a reference to the opening window in a javascript variable called ‘opener’.
So the variable:
window.opener
refers to opener window.
In this tutorial, we have an original webpage win_opener1.php and a popup webpage win_opener2.php. A link in the opening page (win_opener1.php) opens the popup (win_opener2.php). When the user types in some text in a form on win_opener2.php and submits it, the popup window closes, and the original window shows an alert of the text entered in the popup.
In the source code of the popup window javascript, there is also commented code, which when uncommented, makes the opening window redirect to a specified URL.
The source code for win_opener1.php is
<!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <a id="opener" href="#">Click to open child window</a> <form name="parentform" action="" > <input name="myinput" type="hidden" /> </form> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"> </script> <script type="text/javascript"> $(document).ready(function(){ $("#opener").click(function(e){ e.preventDefault(); window.open("/resources/js/ data-trans-multiple-windows/win_opener2.php", "mywindow", "menubar=no,width=500,height=500"); }); }); function process(){ alert("You entered "+document.parentform.myinput.value); } </script> </body> </html>
The code for win_opener2.php is :
<!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form name="childform" action=""> Enter name: <input id="myname" name="myname" type="text" /> <input type="submit" value="Submit" /> </form> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"> </script> <script type="text/javascript"> $(document).ready(function(){ $("form").submit(function(e){ e.preventDefault(); // to set url on window opener // window.opener.location="http://www.yahoo.com"; // passing data to window opener window.opener.document.parentform.myinput.value = window.document.childform.myname.value; window.close(); // to call a function on window opener window.opener.process(); }); }); </script> </body> </html>
What is Memcache? Memcache is an object-oriented mapping that is used to speed up dynamic database-drive applications by storing data in key-value pairs in RAM. In this blog, I will go through steps involved in setting up Memcache on a machine running Ubuntu and running a simple PHP program with Memcache.
For installing software, I will use Synaptic Package Manager.
Installing Memcache
$ pecl install memcache
extension=memcache.so
$ memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211
Writing a PHP program using Memcache
Below is a sample program that demonstrates how Memcached works:
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or
die("Couldn't connect to memcache");
function getCache($key){
global $memcache;
return ($memcache) ? $memcache->get($key) : false;
}
function setCache($key, $object, $timeout = 60){
global $memcache;
return ($memcache) ? $memcache->set($key,
$object, MEMCACHE_COMPRESSED, $timeout) : false;
}
$connection = mysql_connect('localhost', 'root', 'foobar')
or die("can't connect to mysql");
mysql_select_db('test', $connection);
// test query
$key = md5("SELECT * FROM testtable WHERE id=2");
$get_result = getCache($key);
if($get_result){
echo $get_result['name'];
echo $get_result['id'];
echo "Data pulled from cache";
}else{
$sql = "SELECT * FROM testtable WHERE id=2";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
print_r($row);
setCache($key, $row, 20);
echo "Data pulled from database";
}
It is assumed that the table used exists. If all goes well, you will see that the data is pulled from database initially, and from memcached afterwards.
That’s it for now. Till next time, Goodbye.
gVim is a powerful editor that makes a lot of editing work a piece of cake. Here’s a cheat sheet that can help you get the most off this editor. For those who would like to get the work done without using a mouse, it may be the perfect editor. This cheat sheet is geared towards beginners who use editors a lot, perhaps programmers, and will like an easy introduction.
First, for those from a Windows background, there are 3 modes of working in gVim, command mode, insert mode, and visual mode. On opening gVim, you start off in command mode. To type in text, you must go to insert mode. To select text by highlighting, as you do in Windows, you go to visual mode. Without further ado, to the commands.
Opening, saving, moving between files, and closing files
Switching between differnt modes
Switching from command to insert mode
Switching from insert to command mode or from visual mode to command mode
Switching from command to visual mode
Moving around documents
Moving accross screen
Copying and pasting
Inserting and Replacing text
Deleting
Indenting
Copy and Paste between gVim and other applications
Searching and Replacing
That’s all for now. Happy gViming.