Tuesday, December 23, 2014

Location of JDK 17 on mac

If you are looking for the location of JDK 1.7 after installing run this command in terminal
/usr/libexec/java_home -v 1.7
This will give you the location of JDK.
If you are looking for another version just change the version code at the end.

This is how it worked for me

Friday, December 5, 2014

How to define multiple CSS attributes in jQuery

I have been doing like this
$('#id).css('background-color': '#ffff00', );
$('#id).css('color', '#ff0000');

yes it works but Could be done like this using chaining 
$('#id).css('background-color': '#ffff00'.css('color', '#ff0000'); 

But still the better way is to do like this

$('#' + id).css({'background-color': '#ffff00','color': '#ff0000'});
#notice the curly braces Even better way is to simply change class of the element using jquery

Saturday, November 29, 2014

How to replace a character in MySQL table

Use this command in phpMyAdmin or in MySQL console:

update tablename set column_name = replace(column_name, 'character_to_be_replaced', 'characer_to_replaced_with');

For example:
I wanted to replace '&' with 'and' in table named 'tags' and column name 'tag' because that interfered with the URL.
I used following command

update tags set tag = replace(tag, '&', 'and');

I hope this help

Wednesday, August 27, 2014

How this work

I have been doing all of this online stuff alone for many years now and have realized that if you do things alone it becomes quite difficult to keep yourself motivated for long.

All the big wig entrepreneurs preach this very basic principle of getting started with any start-up:

Never start alone.

I followed this advice this time and started a basic online tutorial blog on wordpress with my friend Dev.

We purchased our first domains together about 6 years ago and started blogging. Learnt together but never actually did any project together.

We got separated in between. I shifted to different town, he got new job and we gone on with our lives separately.

Now after all those years we again thought of sharing our knowledge and this time we thought of doing some project together.

So, we created this blog howthiswork.net. I purchased this domain a month ago when there was no plans that I am going to do this with Dev but when the idea came of doing something together we started on this domain.

We started on 15th august and till today we have written 16 blog posts.

I hope we will continue to work along and get successful in this endeavour.

Friday, August 8, 2014

Clear Mac OSX DNS cache

Here is the command to clear Mac OSX DNS cache.
sudo killall -HUP mDNSResponder
Works only on Mountain lion or lion

Saturday, June 28, 2014

Location on App Engine SDK in Mac OSX

I use PyCharm to develop Google app engine python application. I updated it to newer version recently. After the update it started showing me this:
"error: please specify a valid app engine SDK folder"
This PyCharm error came up whenever tried to launch the application.
I tried finding the location of Google app engine SDK and it took me some time to figure it out. If you are also looking for fixing the same, here is where you should point PyCharm to:

that's a symlink that links to the Google App engine SDK.
Hope this help.

PS: If you are find its broken after updating app engine app to newer version open the app as it requires setting it up again after updating.

Sunday, June 8, 2014

How to clear php session files via ssh

My linux vps was giving problem and I found it’s because php was saving all the session files and now thousands of session files were causing the trouble.
To get it fixed I needed to remove/delete the session files.

To remove session files first I located the path where php is saving session files using this command
php -r 'echo session_save_path(), "\n";'

When I tried to remove the files by using the usual file/directory removing command
$ rm –r /session-path/*

It gave me following error
bash: /bin/rm: Argument list too long

After some googling I found this command that worked for me
$ rm -r /session-path/

Nothing special in this command just ‘*’ is not typed in the end but it does the trick.
It deletes the directory and all the saved session files.

Remember to recreate the directory or you will have login errors.
To do that use this command:
$ mkdir /session-path/

I hope it help.

Locate php session files via ssh

There are times when you need to know where php is saving session files in your Linux file system. If you try to find it by opening all directories one by one it becomes very irritating.

Here is simple ssh command that will get you the path on session files.

php -r 'echo session_save_path(), "\n";'

I hope this will help few.

Saturday, March 22, 2014

How to Format Internal Hard Drive in exFAT

I built a Hackintosh and enjoyed using mac OS X but there are few times I needed to use windows to get things done. And using my laptop to do that seem far slower as it has a older configuration compared to my new Intel i7 powered 8 GB RAM desktop. I wanted to install windows 7 on my desktop and ordered a new 1 terabyte WD hard disk from Flipkart as I used 120 GB Samsung SSD while building the hackintosh. 120 GB seems small to have partitions and and installing 2 operating systems.
I partitioned the new WD hard disk and installed windows on it. I planned to use the bigger partition to use it as storage with both windows and mac.
When I formatted partition as NTFS it worked fine with windows and I can access the files from Mac OS X  but I could not write to it from OS X. So I formatted it as FAT32 and I could read/write to it from both windows and mac. But still I found a problem.
The new windows installation needed drivers for Ethernet, sound and other hardware and I had those on DVDs. I did not installed a optical drive in my desktop as I have 2 laptops with optical drives and I can share the DVD drive of these laptops with my desktop. As the Ethernet driver was missing I could not connect to the laptops/network to use their drives.
I needed to copy the drivers from DVD to Desktop via my laptop. I made ISO images of the disks using powerISO (free version is fine for that). Booted my desktop in mac as it can connect to the network. I accessed the laptop from it and tried to copy the iso image which are more than 4 GB in size to the newly formatted bigger partition on my WD hard disk. There I found the problem. I saw an error that I can not copy file this big in the drive.
I googled why this error and I found that I can not copy files more than 4 GB in a disk that is formatted in FAT32. DAMN!
After some googling I figured to use disk in both mac and windows and also to have it store files >4 GB I needed to format it in exFAT format. exFAT format will work both in windows and mac, and also in Linux as well. Now a new problem
When I tried to format it with mac there was no option for exFAT and same goes with the windows 7.
I new windows command prompt can do the trick.
I opened the command prompt and typed:
format /?
This showed me the options to format disk. And the final command that did the trick for me was:
format d: /FS:exFAT
Here "d:" is the drive I was trying to format. Change it accordingly. 
It took a long time to get formatted but finally I have a disk that I can use with both mac and windows and also store large files.
Hope this help few

Thursday, January 30, 2014

Traffic Gone!

Now this was a big break. My last post here was in October 2013 and now January 2014 is ending. I guess I need to kick my ass hard this time.
As the wise men said we should learn from all mistakes I tried to find something and managed to locate this very old known thing but very important when it comes to blogging.
“Post regularly or you are gone from Google.”
This actually did happened this time. I went through the stats and as expected the traffic was at the bottom but what’s interesting is that the post that were showing up earlier in Google search results are now nowhere to see in first few pages. Now good.
I admit that am not writing very good posts here and I am not making any money from it either but few visitors here and there are really nice. Loosing that sucks and I will try to write something more often and hope I will get back some of the guys.
Ok enough for today. Now let me try to kick my ass as I said in the first paragraph ;)