Sunday, July 26, 2015

How to present a regular paper in 15 minutes

  • The purpose of presentation is to impress the potential readers of your paper, not to let them understand your paper in 15 minutes.
  • Example organization: 
    • Motivation (e.g., show a running example)
    • Related work and contribution
    • Background and overview
    • Explain the main approaches/results
    • Experimental results (if any)
    • Conclusions (e.g., summary and future work)
  • Use short and simple sentences on your slides. 
  • Use charts and diagrams instead of texts whenever possible.
  • Each slide should have a clear purpose. Remove all slides likely to confuse the audience.
  • Present the materials that your audiences (NOT you) are interested in.
    • They only care about how helpful your paper is for them.
  • Try to skip technical results and use high-level descriptions.
    • Most of the audience only care about the key ideas. 
    • Put the details in backup slides for Q&A.
  • Make sure your audience can follow you to the last slide.
    • Try to use a running example to explain your approaches.
    • Recall definitions, formulas, theorems, etc., upon distant references.

Wednesday, April 1, 2015

JavaScript tricks

Duck typing

You can invoke an object's method on another object, as long as the latter has everything the method needs to operate properly. Example:
function foo() {
  // the last element of arguments is popped
  Array.prototype.forEach.pop.bind(arguments)();
  // this works as if arguments had a "forEach" method
  Array.prototype.forEach.bind(arguments)(function(a){ console.log(a) }); 
}

Dynamic scoping

The easiest way to archive dynamic scoping in JavaScript is to use eval:
var x = 1;
function g() {
  console.log(x);
  x = 2;
}
function f() {
  // create a new local copy of `g` bound to the current scope
  var x = 3;
  eval(String(g));
  g();
}
f();             // prints 3
console.log(x);  // prints 1
Perhaps this is one of the few valid reasons to use eval in JavaScript.

Loose augmentation

Suppose that you have several module files that share a MODULE variable. Then it is preferable to let organize each module file like
var MODULE = MODULE || {}; // MODULE is always declared due to hoisting
(function() { 
  var private_var;         // only accessible to myFunction
  MODULE.myFunction = ...  // augment the module with a new function 
})();
In this way, you can load all of your module files asynchronously without the need to block, given that the functions defined in the module don't depend on each other.

Call-site memorization

The word memoization refers to function-level caching for repeating values. Suppose we have a function G such that G(f) will compute an expensive function f many times. If f is pure, then we can cache the results of f without modifying G or introducing global variables. Instead of calling G(f) directly, we pass to G a closure of f as follows:
var memorize = function(f) {
  var cache = {};
  return function(x) {
    if(!cache.hasOwnProperty(x))
      cache[x] = f(x);
    return cache[x];
  };
};
G(memorize(f));
The use of cache here is totally transparent from the view of G. Note: You may want to use an LRU/LFU cache to avoid running out of memory.

Saturday, March 28, 2015

Tuesday, March 24, 2015

Tricks in solving common programming problems

O(1)-space collision detection

At times, you need to detect for once whether a collision occurs. For example, you may need to enumerate a sequence$$ x_0,\ x_1=f(x_0),\ x_2=f(x_1),\ \dots,\ x_i=f(x_{i-1}),\ \dots $$until either a desired element is found or a cycle is detected. A naive method to detect a cycle requires storing all elements ever enumerated in a hash table. This method however would need to store the entire sequence in the worst case. Instead, you can utilize one of the cycle detection techniques to reduce the space to O(1) at the cost of possibly longer search time.

(more to come...)