Saturday, October 19, 2013

Highlighting the different between Latex Documents in Windows 7 using Latexdiff

Wondering is there a way how to make a diff for latex files or documents?
The answer is a definite Yes! You need latexdiff which comes with Miktex

Following is a step by step guide for installing it in Windows 7:
Prerequisite
You need to install:
  1. Miktex (http://miktex.org/2.9/setup)
  2. Perl (can use Strawberry Perl: http://strawberryperl.com/releases.html)

Step By Step Guide
Assume Miktex and Perl Interpreter are installed, and Miktex is installed in "C:\Program Files (x86)\MiKTeX 2.9\" (Other directory is fine, just adapt accordingly)

  1. Go to  "C:\Program Files (x86)\MiKTeX 2.9\scripts\latexdiff\"
  2. Create a a new folder "perl" in "C:\Program Files (x86)\MiKTeX 2.9\scripts\latexdiff\"
  3. Copy all files in "C:\Program Files (x86)\MiKTeX 2.9\scripts\latexdiff\" to new folder "C:\Program Files (x86)\MiKTeX 2.9\scripts\latexdiff\perl"
  4. Rename all files (without extension) in "C:\Program Files (x86)\MiKTeX 2.9\scripts\latexdiff\perl", with an extension .ple.g., latexdiff to latexdiff.pl
  5. Add "C:\Program Files (x86)\MiKTeX 2.9\scripts\latexdiff\perl" to the PATH environment (if you are not sure how to do so, see here)
  6. Open Command Prompt, and type in
    latexdiff.pl --flatten PreviousFile CurrentFile> diffe.g., latexdiff.pl --flatten "C:\old.tex" "C:\new.tex" > "C:\Diff.tex"

Sample
Below is  a sample for Diff.tex, where you can see what's old (cross out, red color) and new (underline, blue color) easily, pretty cool right :)







Google Chrome - Adobe Acrobat has Crashed

There is a pretty straightforward solution for it:

Go to Chrome plugins page by typing this in your browser: chrome://plugins/
Look for "Chrome PDF Viewer" and Enable it.

Monday, September 9, 2013

ISynchronizeInvoke implementation example

Put the following code for classes you want to implement ISynchronizeInvoke should do the job
        private readonly object _sync= new object();

        public IAsyncResult BeginInvoke(Delegate method, object[] args)
        {
            var result = new SimpleAsyncResult();

            ThreadPool.QueueUserWorkItem(
                delegate
            {

                result.AsyncWaitHandle = new ManualResetEvent(false);
                try
                {
                    result.AsyncState = Invoke(method, args);
                }
                catch (Exception exception)
                {
                    Debug.WriteLine(exception.Message);
                    Debug.WriteLine(exception.StackTrace);
                    result.Exception = exception;
                }
                result.IsCompleted = true;
            });


            return result;
        }


        public object EndInvoke(IAsyncResult result)
        {
            if (!result.IsCompleted)
            {
                result.AsyncWaitHandle.WaitOne();
            }


            return result.AsyncState;
        }


        public object Invoke(Delegate method, object[] args)
        {
            lock (_sync)
            {
                return method.DynamicInvoke(args);
            }
        }


        public bool InvokeRequired
        {
            get { return true; }
        }
        public class SimpleAsyncResult : IAsyncResult
        {
            private object _state;


            public bool IsCompleted { get; set; }


            public WaitHandle AsyncWaitHandle { get; internal set; }


            public object AsyncState
            {
                get
                {
                    if (Exception != null)
                    {
                        throw Exception;
                    }
                    return _state;
                }
                internal set { _state = value; }
            }

            public bool CompletedSynchronously
            {
                get { return IsCompleted; }
            }


            internal Exception Exception { get; set; }

        }
        
  

Want to read more?

How to put code snippet into blogger like blogspot


// Comment
public class Testing {
public Testing() {
}
 
public void Method() {
/* Another Comment
on multiple lines */
int x = 9;
}
}
Reference here: http://www.craftyfella.com/2010/01/syntax-highlighting-with-blogger-engine.html

[Self Reference] Bug Lists

20 Sep 2013
  1. if…else.. do not consider last redundant assignment
  2. when dividing, denumerator can be zero
8 Sep 2013
  1. Do not initialize class values before using it - Do not initialize the RuntimeAdapter for InitialState (leave empty), when using RuntimeAdapter
  2. == and !=, if(root.Count==1) throw (only allow once) -> Suppose to be !=1
-----
  1. wrong sequence - Clear the ConcreteServices at the wrong place just after populating it, it should be just before populating it
  2. missed item - case.execute() is not implemented
  3. missed item - the switch does exert the event to partialModelState
  4. redundant call - put two calls in start and internal start for simulate()
  5. wrong name - when copy paste forget to change all the names
  6. Not setting global one - declare a lobal Simulator sm, and didn't set to global one
  7. terminate event not sent -  skip is never called as it won't evoluate to that event, correct way to send terminate event is via the Bprocess execute()
  8. Unexpected - parallel.run(…), in … throw exception (a duplicate var can solve the problem)
  9. parallel.invoke bug can't throw outside: http://stackoverflow.com/q/18764007/1497720
----


Previous two days
  1. not initialize v with maximum when doing v=min(v, value)
  2. not initialize v with zero and maximum separately, when v has to do with min and plus
  3. in switch, change the case activity value
  4. does not understand that geteventid, is a state with previous edges
  5. using a the terminal states without initializing it with value


  1. Index out of bound - action0Col[1] == "if", but action0Col may not have index 1 (e.g., for atomic action)
  2. copy paste - result.Add(new ActionPair(actionPair.Value[0], actionPair.Value[1], action0Col[2] == "c"));
  3. not assigning value to instance - not assigning the value to Available of Nonfunctional Attribute, but assign to a variable totAvailability
  4. split value problem(knowledge problem) - [if:0:c] split becomes {"[if","0","c]"}
  5. copy paste -  avgResponseTime += nf.ResponseTime;  should be  avgResponseTime += nf.avgResponseTime;
  6. Concept problem - in AggregateActions firstResponseTime and firstAvgResponseTime treat the same
  7. "a:name:<empty>", string split, then only have two columns, access 2 index out of bound



  1. Value is null, lock{..}{}..this .. is empty!
  2. Queue and trace not initialize when accessed

Sunday, August 11, 2013

Singnet and NUS Proxy Server

Singnet:
proxy.singnet.com.sg
8080

NUS:
pali.nus.edu.sg
3128

Thursday, March 28, 2013

How to prevent a page open in IFRAME

Set
X-FRAME-OPTIONS: SAMEORIGIN
 in the header will do.