Monday, September 9, 2013

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.

Thursday, March 21, 2013

Good links for PHP


Here's some good links accumulated from the answers below/Found myself for understanding the OO architecture/Unique Features in PHP, of course, it is meant for people from other areas like java and .net to have an overview of PHP features.

OO

Using namespace
http://php.net/manual/en/language.namespaces.basics.php

Fallback for global namespace
http://www.php.net/manual/en/language.namespaces.fallback.php

Class(overidden class, Const, static class) using ::
http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php

Array

http://php.net/manual/en/language.types.array.php

An array can be created using the array() language construct. It takes any number of comma-separated key => value pairs as arguments.
array(
    key  => value,
    key2 => value2,
    key3 => value3,
    ...
)


the key can either be an integer or a string. The value can be of any type.
Additionally the following key casts will occur:
  • Strings containing valid integers will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.
  • Floats are also cast to integers, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8.
  • Bools are cast to integers, too, i.e. the key true will actually be stored under 1 and the key false under 0.
  • Null will be cast to the empty string, i.e. the key null will actually be stored under "".
  • Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.
If multiple elements in the array declaration use the same key, only the last one will be used as all others are overwritten.
Example #2 Type Casting and Overwriting example
<?php
$array 
= array(
    
1    => "a",
    
"1"  => "b",
    
1.5  => "c",
    
true => "d",
);
var_dump($array);?>
The above example will output:
array(1) {
  [1]=>
  string(1) "d"
}



The key is optional. If it is not specified, PHP will use the increment of the largest previously used integer key.
Example #4 Indexed arrays without key
<?php
$array 
= array("foo", "bar", "hallo", "world");var_dump($array);?>
The above example will output:
array(4) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(3) "bar"
  [2]=>
  string(5) "hallo"
  [3]=>
  string(5) "world"
}


It is possible to specify the key only for some elements and leave it out for others:
Example #5 Keys not on all elements
<?php
$array 
= array(
         
"a",
         
"b",
    
6 => "c",
         
"d",
);
var_dump($array);?>
The above example will output:
array(4) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [6]=>
  string(1) "c"
  [7]=>
  string(1) "d"
}

Multidimentional array

Accessing array elements with square bracket syntax

Array elements can be accessed using the array[key] syntax.
Example #6 Accessing array elements
<?php
$array 
= array(
    
"foo" => "bar",
    
42    => 24,
    
"multi" => array(
         
"dimensional" => array(
             
"array" => "foo"
         
)
    )
);
var_dump($array["foo"]);var_dump($array[42]);var_dump($array["multi"]["dimensional"]["array"]);?>
The above example will output:
string(3) "bar"
int(24)
string(3) "foo"


Creating/modifying with square bracket syntax

An existing array can be modified by explicitly setting values in it.
This is done by assigning values to the array, specifying the key in brackets. The key can also be omitted, resulting in an empty pair of brackets ([]).
$arr[key] = value;
$arr[] = value;
// key may be an integer or string
// value may be any value of any type
If $arr doesn't exist yet, it will be created, so this is also an alternative way to create an array. This practice is however discouraged because if $arr already contains some value (e.g. string from request variable) then this value will stay in the place and [] may actually stand for string access operator. It is always better to initialize variable by a direct assignment.
To change a certain value, assign a new value to that element using its key. To remove a key/value pair, call the unset() function on it.
<?php
$arr 
= array(5 => 1, 12 => 2);$arr[] = 56;    // This is the same as $arr[13] = 56;
                // at this point of the script
$arr["x"] = 42; // This adds a new element to
                // the array with key "x"
                
unset($arr[5]); // This removes the element from the arrayunset($arr);    // This deletes the whole array?>

Multidimentional array

Accessing array elements with square bracket syntax

Array elements can be accessed using the array[key] syntax.
Example #6 Accessing array elements
<?php
$array 
= array(
    
"foo" => "bar",
    
42    => 24,
    
"multi" => array(
         
"dimensional" => array(
             
"array" => "foo"
         
)
    )
);
var_dump($array["foo"]);var_dump($array[42]);var_dump($array["multi"]["dimensional"]["array"]);?>
The above example will output:
string(3) "bar"
int(24)
string(3) "foo"
Note:
Both square brackets and curly braces can be used interchangeably for accessing array elements (e.g. $array[42] and $array{42} will both do the same thing in the example above).

Useful functions

There are quite a few useful functions for working with arrays. See the array functions section.
Note:
The unset() function allows removing keys from an array. Be aware that the array will not be reindexed. If a true "remove and shift" behavior is desired, the array can be reindexed using the array_values() function.
<?php
$a 
= array(1 => 'one', 2 => 'two', 3 => 'three');
unset(
$a[2]);/* will produce an array that would have been defined as
   $a = array(1 => 'one', 3 => 'three');
   and NOT
   $a = array(1 => 'one', 2 =>'three');
*/
$b = array_values($a);// Now $b is array(0 => 'one', 1 =>'three')?>
The foreach control structure exists specifically for arrays. It provides an easy way to traverse an array.


Regarding modification of the array:
http://stackoverflow.com/questions/5179606/php-replace-array-value

Note
Array assignment always involves value copying. Use the reference operator to copy an array by reference.



Include and require

http://www.php.net/manual/en/function.include.php
require is identical to include except upon failure it will also produce a fatal E_COMPILE_ERROR level error. In other words, it will halt the script whereas includeonly emits a warning (E_WARNING) which allows the script to continue.


foreach

The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, 
foreach (array_expression as $value)
    statement
foreach (array_expression as $key => $value)
    statement
<?php
$arr 
= array(1, 2, 3, 4);
foreach (
$arr as &$value) {
    
$value = $value * 2;
}
// $arr is now array(2, 4, 6, 8)unset($value); // break the reference with the last element?>
Reference of a $value and the last array element remain even after the foreach loop. It is recommended to destroy it by unset().

You may have noticed that the following are functionally identical:
<?php
$arr 
= array("one", "two", "three");reset($arr);
while (list(, 
$value) = each($arr)) {
    echo 
"Value: $value<br />\n";
}

foreach (
$arr as $value) {
    echo 
"Value: $value<br />\n";
}
?>

Wednesday, March 6, 2013

Issue regarding "You are NOT logged in to SoC-VPN"

This is mainly for National University of Singapore, School of Computing Students and Staffs.

You are NOT logged in to SoC-VPN

https://noc.comp.nus.edu.sg/netlogon?1.0.2


How to solve it:
Right click the SoC-VPN shortcut, 
Choose compatibility tab,
and check Run this program as an administrator

Monday, February 11, 2013

How to get google page rank?

Answer: You can use the php here -
http://code.google.com/p/seostats/

Source:
http://stackoverflow.com/questions/1344917/getting-google-pagerank-via-an-api-php