Wednesday, 20 January 2010
Subtitles editor
I got a software to edit subtitles - here
I took the first one (Aegisub) and installed it.
I wanted to shift the time of subtitles forward by 20 Seconds. It is pretty simple.
Just open the file with Aegisub and click on "Open Shift Times Dialogue" - the icon on toolbar with the pic of an arrow and a vertical stripe. Enter the required values.
:)
Now I can watch any movie with better understanding. \0/
By the way, if you have a movie without subtitles, then search for subtitle file of that movie on internet. Some of them have .srt extension. (I used the same.) There can be .sup too. I don't know what the difference is. But .srt worked for me.
Take the file. Rename it with the same name as that of your movie file name. (keep the extension as .srt; don't change that).
Keep both the movie file and srt file in the same folder.
Open your movie player. I used VLC player. In that, select Video menu-> Subtitles Track -> Track 1.
It should work. (You might need to restart the VLC player.)
Saturday, 16 January 2010
Behavior of "inherited protected" variable in Java
There are 2 basic aspects of a variable– inheritance (can be inherited or not; with values – yes/no) and access (can be accessed or not; with values – default/public/private - ignore protected for now)
Consider 2 scenarios:
Scenario 1:
As shown in the above figure –
Result is -
B inherits x, C can access x through object of A and through object of B both.
D inherits x.
E cannot access x at all.
Scenario 2:
As shown in the above figure –
Result is:
B, C inherit x.
Class D cannot access x at all.
Conclusion:
This is about variable x of B.
When protected variable is inherited inside package (Scenario 1), it behaves like default for access and yes for inheritance.
When protected variable is inherited outside package (Scenario 2), it behaves like private for access and yes for inheritance.
Thus, the table is as follows - (click on the table image)
Tuesday, 12 January 2010
When you want to carry your heavy laptop
Monday, 30 November 2009
Unix Shell Differences
http://www.faqs.org/faqs/unix-faq/shell/shell-differences/
The list of shells that are developed till now are -
bourne shell – sh – input language: bourne shell language
c shell – csh - input language: c language
T shell – tcsh - input language: c language – enhanced c shell
Korn shell – by At&T – ksh – POSIX compatible - input language: bourne shell language
Bourne Again shell – by GNU – bash – POSIX compatible – input language: bourne shell language
Ksh and bash are almost similar – but the first is not free and later is free.
RC – it got enhanced later to es.
Zsh – the recent shell
(Next time something in detail about every shell)
We can also find some of the shells in detail over here on the same site. Also I got some harry potter sites. ;)
Also, the file name completion, command completion; it is called TENEX style completion. I didn’t know this.
Monday, 23 November 2009
varargs
- They are to be used when you need to use unknown number of arguments of same type.
e.g. log function where you need to print a string which can be formed of any number of string objects.
- This argument must be the last parameter of a method.
For examples -
click
This works nice in case of polymorphism.
public class Test
{
public static void fun(Parent... args){
for (Parent i : args){
i.setA(5);
System.out.println("a is " + i.getA());
}
}
public static void main(String args[])
{
Parent p = new Parent();
ChildA a = new ChildA();
ChildB b = new ChildB();
fun(p,a,b);
}
}
Thursday, 20 August 2009
Small tip
Check Features and Release notes of the tool on internet and then accordingly try doing them.
Tuesday, 14 April 2009
Hiding Vs Overriding! Interesting!!
package test;
class FieldHiding {
public String InstanceField = "Instance Field in SuperClass";
public static String StaticField = "Static Field in SuperClass";
public static int StaticIntField = 1;
}
public class FieldHidingDemo extends FieldHiding {
public String InstanceField = "Instance Field in SubClass";
public String StaticField = "Static Field changed to Instance Field in SubClass";
protected String StaticIntField = "public static int in super class -> protected String in subclass";
public static void main(String[] args) {
FieldHiding fieldHiding1 = new FieldHiding();
FieldHiding fieldHiding2 = new FieldHidingDemo();
FieldHidingDemo fhd = new FieldHidingDemo();
System.out.println(fieldHiding1.InstanceField);
System.out.println(fieldHiding1.StaticField);
System.out.println(FieldHiding.StaticField);
System.out.println(fieldHiding1.StaticIntField);
System.out.println(FieldHiding.StaticIntField);
System.out.println(fieldHiding2.InstanceField);
System.out.println(fieldHiding2.StaticField);
System.out.println(fieldHiding2.StaticIntField);
System.out.println(fhd.InstanceField);
System.out.println(fhd.StaticField);
System.out.println(fhd.StaticIntField);
}
}
This example is from geekexplains.blogspot.com
Fields and static methods cannot be overridden. They are just hidden.
What is overriding?
Binding is done depending upon the type of calling object, not on the type of reference used.
And what is hiding?
Binding is done depending upon the type of reference used, not on the type of calling object.
Field Hiding:
We can narrow or widen the visibility of variables. i.e. a public variable in superclass can be made private in subclass and vice-versa.
Static Method Hiding:
We cannot narrow the visibility of functions. But we can widen.
Good link for this. Specially the last question. ;)
Update:
In java, non-static methods are always overridden and static methods are always hidden when they are redefined in subclass.
But in C#, there are options to either hide or override the method. It is possible with some combinations of keywords new, virtual and override.