Sunday, June 8, 2014

How to reduce SQL Server transaction Log

Well, the transaction log is a headache when it comes to the space requirements. That however, is necessary if you want to restore your database to a given previous time. Personally, I've never used this.

If you try to shrink the file by going into SQL Server Management Studio - > Right Click the database - > Go to tasks - > Shink - > Files -> Select Log from the drop down
            this will reduce some amount of the file, but if it is really big and you don't want it and you want it all removed try the following.


  1. Backup the current transaction log.
    Right Click the Database -> Tasks -> Backup -> Select 'Transaction_Log' from the backup type drop down -> OK
  2. Now try to shrink the Log file.
     Right Click the database - > Go to tasks - > Shrink - > Files -> Select Log from the drop down
  3. See now that your file size is reduced for your relief.

Remember, Never detach the db and reattach without the log file or delete the log file just to get rid of it!!!

Saturday, March 31, 2012

struts JSP set value for s:textfield, s:submit

In JSP when using struts to create forms, the fields like s:textfield, s:submit .etc have an attribute named 'value'.

This value cannot be dynamically set using direct jsp tags. If you try something like this

<s:hidden name="form" value="<%=System.currentTimeMillis() %>" />


 you'll get

"According to TLD or attribute directive in tag file, attribute value does not accept any expressions".


Check this struts reference for 'value is and Object' part.
http://struts.apache.org/2.0.6/docs/tag-syntax.html.

This is how struts defines it's fields in s:textfield, s:submit .etc attributes. Trying to insert <% %> tags into this will be very difficult. However, we can remove s:textfield and replace it with the corresponding html tags.

Example:
<s:hidden name="form" value="studentsList" />
 will be
<input type="hidden" name="form" value="studentsList" id="Forms_form"/>


when passed through struts.


In the same way
<s:submit value="Students List"/>


will be
<tr> <td colspan="2"> <div align="right"> <input type="submit" id="Forms_0" value="Students List"/> </div> </td> </tr>


Now we can use <%= %> tags inside the value fields as below.


<td colspan="2">
<div align="right">
<input type="submit" id="Forms_0" value="<%= s.getFirstName()+" "+s.getLastName() %>"/>
</div>
</td>


The best way to do this is first complete the forms fields setting the required field value to any string. Use the s:textfield tags and set value="xxx". Then deploy the project and view the page source. The run the project and in the relevant page view the page source(Ctrl+U). This will show you the converted html form of the struts form. Copy the relevant field and insert the JSP scripts to value. value="<%=System.currentTimeMillis()%>". Now it should work!!!

Struts JSP style="display:none" not working?

When I wanted to hide some 'div's from my JSP page, when I used

<div id="tab1" class="tabContent" style="display: none;">
This proves to be working on simple html version

<form name="ff".... >

But when I added struts form

<s: form action="StudentDetailsForm">
this makes the 'display:block' function freeze. This also happens to only some of the long forms.

To fix this what I did was set the struts form theme to simple and it worked!!!


<s:form action="StudentDetailsForm" theme="simple">

Sunday, August 21, 2011

Sharing your PC internet connection with Android in Windows 7

Have you ever wanted to share your pc's net connection with your android device through wifi. Well there are few tools you can use to do this. They are Connectify and Virtual Router. But they are not very stable and went through several blue screens myself. But if you're running on Windows 7, don't bother. The OS itself supports this feature. Here's how to do it.


  1. First check wheather your drivers support the feature. Open command prompt in Administrator mode and enter the following
    netsh wlan show settings
    If it says hostednetwork = enable or something similar you're ready to go.
  2. Create a net hosted network by entering the following command
    netsh wlan set hostednetwork mode=allow ssid=new_network_name key=new_network_password
    This will create a wifi hosted network
  3. Then go to the network and sharing center and go to adapter settings and choose your internet connection -> properties -> sharing and tick the share this network and seleted the newly created wifi network.
  4. Then turn on the hosted network by entering this in the command prompt
    netsh wlan start hostednetwork
    check with your wifi enabled device, you'll find the network is available


    That's it, all done and enjoy!!!
This works not only for Android device, you can connect your laptop, your i-phone or any other wifi enabled device...

Wednesday, April 6, 2011

These Times...

Well,
     It's been some time before I logged into the Blogspot. But it's okay considering that past few weeks have been very very productive. We had so many projects, practicles + lab reports, presentations, interviews for trainning, a world cup etc. To tell you the truth it's actually okay to have so many projects because we can at least start to learn from those. And it's really fun doing group projects all members being enthusiastic about their work, urging to improve the system, it's really really good.
   And about the lab reports, you all know it's fun, but in some occasions it can boring. But considering all aspects doing a practical and writing a report is really a great thing to do if you don't have anything else to do. It can be done easily by typing it in a computer and printing, but it's not fun like writing it. And also if you type it, others can copy and paste the same answers. So writing it by hand is the greatest solutions, I'm sure of it.
   Ahhh... now the real fun starts when moving on to facing interviews part. Now 06 batch will be more agreeable with me than 07 batch of how fun it is. Only very few interviewers are bad, all others are very good and always wants to teach us more even in the interview itself. Considering we're from UOP, nobody says NO to us. I mean why wouldn't they be, we're doing a great favor for them by developing their apps for a low price like Rs 10000/= per month.
   And since the world cup is a successful, doubtful effort no point talking about it. Again it's from A to Z till 2015 and Mahinda has nothing to do with it.

So that's it about the array of last few weeks. Somebody can take it as it is, and somebody can multiply it with another array. For example something like [1,0,0,0,0,0...].
Thanks for reading!!!

Wednesday, February 16, 2011

BROWSERS

Well, it's really hard to tell from the title. But I'm going to talk about browsers, especially which is best for whom.
These are the most popular.

  1. Mozilla Firefox
  2. Google Chrome
  3. Opera
  4. Apple Safari
  5. Internet Explorer

Firefox



Firefox is one of the most widely used web browsers in the world. It's for everybody. Whether you're a developer or a general user it has the right tools for you. Maybe for some, Firefox might not be good as a default browser. But every once in a while Firefox comes to help. Firefox supports almost everything whether if it is a font or a add-on or a tool. So if it's not the best, it's one of the best.




Chrome


Chrome is the best for me. It's simple, it's fast and also has a wide range of extensions to choose from. Since Chrome is installed into application data folder, if it's a shared computer, chrome is good for security as well. But chrome had a problem with some JavaScript, for example twitter is not that much friendly with Chrome. But I'll say for a internet connection of average speed, chrome is the best.

Opera


Well, it's the odd one in the family. Opera 9 was seems to be the slowest browser in it's time. Then Opera 10 was called the fastest browser on earth. Now we have Opera 11. It's actually fast, but with slower connections which I have it doesn't produced that much. But it's features are unmatched. First of all it has a built in mail manager. Without opening a new tab we get a fully functional mail browser. Then 'Opera Unite', a tool that can turn your machine into a file hosting machine. Using Opera Unite we can share any file in our computer with internet without having upload them into a different location (provided by file sharing sites). Then the extensions. They are unique. If you're into web developing or mathematics or something complex, search opera extensions they will have answers. And we can manually add extensions as well. As a way of speaking, I was able to set up Facebook chat as a extension in Opera, so I do not have to log into FB to chat. So when we combine it all,
After I open Opera,
  • My mail is online, I can send,receive and read mails without going to a different tab
  • My Facebook chat is online, I do not have to go to FB site to see whose online
  • My files can be shared with anyone, so I do not have mail them or upload into a sharing site to send my files to a friend.
  • And I forgot to mention above that it has turbo (theoretically this will enhance page viewing if your connection is slow, but doesn't seem to have that much effect).
So my conclusion is, if your connection is reliable ( very reliable), opera is the one.


Safari

Well, it's the Posh guys tool. Comes default with Mac OS, but also have a version for Windows. To tell you the truth it's damn slow. I tried with my Windows 7. It seems to have somewhat Ubuntu look. Then I realized that Ubuntu is the one who copied Mac. So there must have something in their browser, but couldn't find out what. It's simply not good enough. So I say if it's not Mac, don't use it.

Internet Explorer


One sentence, "DON'T EVEN THINK ABOUT IT". It's slow, it's week and it doesn't support anything (anything doesn't support it). It's the worst browser I've ever seen. The problem is IE only designed for browsing web, you can't do anything else. I think most people will agree with this. It's security is very low. The Microsoft's Windows Live program gives out every password we save on it (save a password in Windows Live and run the software called SIW and point to passwords ->it's be able to decrypt Win live password but will be unable to decrypt passwords from most other softwares). So Internet Explorer shouldn't be far behind.



Personally I have installed Chrome, Firefox and Opera on my computer. Chrome is the default, Firefox is configured with IDM for all the downloading stuff, and Opera for developing and testing purposes.

Friday, February 11, 2011

Dear Miss,, To sir with love!

"You won’t remember me or my name. You have failed so many of us.
On the other hand I have often had thoughts about you, and the other teachers, and about that institution which you call ‘school’ and about the boys that you fail.
You fail us right out into the fields and factories and there you forget us."



Those were the words taken from the book "Dear Miss" which was written by eight school boys from the school of Barbiana in Tuscania, Italy 1967. The boys ask the teacher why they stay silent when they see that students write wrong answers in the exam. If it's their duty to teach students, why? Well, this came to my mind when I'm thinking about what's happening to us in the university. Clearly the industry doesn't care about the GPA as long as they get what they want. So why are we given low grades. The book was a collection of letters written by those boys which has several edition other than the above (Letter to a Teacher). The whole school cheers when the principal announces that the next day will be a holiday. The boys ask why the teachers smile when that happens not knowing that the students hates the teachers, teaching & learning that much. The current education system is a marathon. Education is the secondary outcome. It focuses only on determining who's the first.





On the other hand teachers act as the almighty in the class room. Obviously they won't do it for free. Private or government people pay for them. So treating students with some respect is something teachers should learn. E.R. Braithwaite learnt it the hard way and wrote an amazing book called "To sir with love" which was also converted into a movie later. I'm sure some of you have read it. Ricardo Braithwaite was able to introduce a bunch of untamed students into the society as ladies and gentlemen by treating them as ladies and gentlemen. So what we want is not new teaching methods,  but teachers with the capability to understand the student and teach him how to become somebody (not first).