python appcfg.py –email your-email@gmail.com –no_cookies update your-app-id
–no_cookies is very important na ja
python appcfg.py –email your-email@gmail.com –no_cookies update your-app-id
–no_cookies is very important na ja
1. import > Existing Project into workspace
2. Properties > Android
Checked ! ” Project Build Target : Android 3.0 “
Apply
Very Important !! You have to apply first before going to next step.
3. Properties > Java Build Path
Libraries
Add Library
> Android Classpath Container
Loop
1.
for (i = 0, max = myarray.length; i < max; i++) {
2.
Count down to 0, is usually faster
it’s more efficient to compare to 0 than to the length of the array or to anything other than 0
For loop
for (i = myarray.length; i--;) { i = myarray.length;
while (i--) {
For in / hasOwnProperty
Adding method to all objs
// somewhere else in the code
// a method was added to all objects
if (typeof Object.prototype.clone === "undefined") {
Object.prototype.clone = function () {};
}
// 1.
// for-in loop
for (var i in man) {
if (man.hasOwnProperty(i)) { // filter
console.log(i, ":", man[i]);
}
}
/* result in the console
hands : 2
legs : 2
heads : 1
*/
// 2.
// antipattern:
// for-in loop without checking hasOwnProperty()
for (var i in man) {
console.log(i, ":", man[i]);
}
/*
result in the console
hands : 2
legs : 2
heads : 1
clone: function()
*/
Another pattern to filter
for (var i in man) {
if (Object.prototype.hasOwnProperty.call(man, i)) { // filter
console.log(i, ":", man[i]);
}
}
Or
1.
var i, hasOwn = Object.prototype.hasOwnProperty;
for (i in man) {
if (hasOwn.call(man, i)) { // filter
console.log(i, ":", man[i]);
}
}
2.
// Warning: doesn't pass JSLint
var i, hasOwn = Object.prototype.hasOwnProperty;
for (i in man) if (hasOwn.call(man, i)) { // filter
console.log(i, ":", man[i]);
}
eval()
// antipattern
var property = "name";
alert(eval("obj." + property));
// preferred
var property = "name";
alert(obj[property]); // antipatterns
setTimeout("myFunc()", 1000);
setTimeout("myFunc(1, 2, 3)", 1000);
// preferred
setTimeout(myFunc, 1000);
setTimeout(function () {
myFunc(1, 2, 3);
}, 1000);
Here only un remains as a global variable polluting the namespace
console.log(typeof un); // "undefined"
console.log(typeof deux); // "undefined"
console.log(typeof trois); // "undefined"
var jsstring = "var un = 1; console.log(un);";
eval(jsstring); // logs "1"
jsstring = "var deux = 2; console.log(deux);";
new Function(jsstring)(); // logs "2"
jsstring = "var trois = 3; console.log(trois);";
(function () {
eval(jsstring);
}()); // logs "3"
console.log(typeof un); // number
console.log(typeof deux); // undefined
console.log(typeof trois); // undefined
eval() can access and modify a variable in its outer scope, whereas Function cannot
(function () {
var local = 1;
eval("local = 3; console.log(local)"); // logs 3
console.log(local); // logs 3
}());
(function () {
var local = 1;
Function("console.log(typeof local);")(); // logs undefined
}());
string to number
Prevent octal confusion
var month = "06",
year = "09";
month = parseInt(month, 10);
+"08" // result is 8
Number("08") // 8
Code convention
Naming globals with all caps can reinforce the practice of minimizing their number and can make them easily distinguishable.
// precious constants, please don't touch
var PI = 3.14,
MAX_WIDTH = 800;
private with _
var person = {
getName: function () {
return this._getFirst() + ' ' + this._getLast();
},
_getFirst: function () {
// ...
},
_getLast: function () {
// ...
}
};
Other conventions :
ref : tutsplus
Tools > Burn DVD ISO Image
'ascii' codec can't decode byte 0xe0 in position 5: ordinal not in range(128)
Solution :
Execute setdefaultencoding in Interactive Console at http://localhost:8080/_ah/admin/interactive
import sys
reload(sys); sys.setdefaultencoding('utf-8')
scale invarient : correspondences often requires their comparison where they are seen at different scale
DoG : Different of Gaussian
Integral image can be used to up-scale at constant cost as seen in the right side of picture below.

ref : cornell, surf paper
Definition
Discreate form
Properties
1.
2.
In image processing : two dimensions convolution
h is called convolution kernel or mask
Sliding kernel throughout the image. If image is like in kernel, we will have peak value of y(m, n). –> roughly use to detect same image ??
The pictures below is a good visualization from Wiki.
ref : hmc
At each pixel (x,y), calculate sum of the rectangle [(0, 0), (x, y)] by using the following formulas
Integral Image at location
Suppose we want to find sum in D in the picture
D = (A+B+C+D) – (A+C) – (A+B) – A
ref : cornell
การอินทิเกรท ก็คือ การหา พื้นที่ใต้กราฟ ซึ่งคิดว่า เคยทำกันมาแล้ว
ซึ่ง คุณ มณฑล สุกใส อธิบาย พร้อม พิสูจน์ ได้ดีมากๆ ที่เวป thaifoodscience ซึ่งคำอธิบายในรูปที่ว่า ” ถ้าคิดไม่ออก ก็ทำเป็นสี่เหลี่ยมคางหมูซะเลย ” ทำให้ระลึกชาติ ได้ดีทีเดียว
ผมจดมาแค่ทฤษฎีนะครับ
รูปและสมการเอามาจาก initmath
สังเกตว่า ตัวแรกกับตัวท้าย ค่าสัมประสิทธิ์เป็น 1
นอกนั้น 4 กับ 2 สลับกัน
ส่วนวิธีเลือกค่า ให้เลือกตาม วิธีด้านล่าง โดยการ diff f(x) ไป 4 ที
If for all x in interval a <= x <= b,
and h = (b-a)/n then
Error <= M * h^4*(b-a)/180
where n is the number of subintervals
ถ้าเรามี
เมื่อ error
จะได้ว่า เมื่อ ‘ คือ transpose นะ เดาเอา
และ เมื่อ hat คือ ค่าประมาณ
n = จำนวนข้อมูลที่นำมาคิด
k = จำนวน params ที่ประมาณ ในที่นี้ มี กับ
ดังนั้น k = 2
ถ้าไม่รู้เรื่อง ไปใช้ gnuplot แก้เอาก็ได้ ดูตัวอย่าง ที่นี่