In the current version as at this posting, it is output into the server log and retrived via the "View System Log" feature in the AWS console.
Reference: https://bitnami.com/stack/wordpress/cloud/amazon
My online tech scrapbook where I keep my notes in case I need to look them up later
Monday, January 26, 2015
AWS HVM vs PV
HVM: Hardware Virtual Machine
PV: Paravirtual machine
HVM is newer (feature of new CPUs). Some of the newer instance types only support HVM.
References:
PV: Paravirtual machine
HVM is newer (feature of new CPUs). Some of the newer instance types only support HVM.
References:
- http://palakonda.org/2012/10/30/aws-virtualization-hvm-vs-paravirtualization/
- http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html
Saturday, January 24, 2015
Ant SCP Error com.jcraft.jsch.JSchException: reject HostKey
This happens when the target server is not a "known host". Just do a normal SSH to the server and say yes to adding the server to known hosts, and after that SCP from Ant should be fine.
http://anahorny.blogspot.sg/2013/05/solution-for-comjcraftjschjschexception.html
http://anahorny.blogspot.sg/2013/05/solution-for-comjcraftjschjschexception.html
Wednesday, January 21, 2015
REST: When to Use GET, PUT, POST, DELETE in Non-CRUD Situations
In normal CRUD situations, the answer is obvious. In non-CRUD situations, this gets a bit more tricky.
I think the best way to approach this is based on the following quoted from REST Wikipedia page
"The PUT and DELETE methods are referred to as idempotent, meaning that the operation will produce the same result no matter how many times it is repeated. The GET method is a safe method (or nullipotent), meaning that calling it produces no side-effects. In other words, retrieving or accessing a record doesn't change it."
I think the best way to approach this is based on the following quoted from REST Wikipedia page
"The PUT and DELETE methods are referred to as idempotent, meaning that the operation will produce the same result no matter how many times it is repeated. The GET method is a safe method (or nullipotent), meaning that calling it produces no side-effects. In other words, retrieving or accessing a record doesn't change it."
- If the REST end-point has no side effect (e.g. search), use GET.
- If it is idempotent, it is possible to use PUT or DELETE depending on the nature of the request
- If not idempotent and has side effect, use POST
Monday, January 12, 2015
Java Calling Another Constructor of the Same Class
This is similar to "super()" but much less used. This is done with "this()"
Reference: http://stackoverflow.com/questions/285177/how-do-i-call-one-constructor-from-another-in-java
Reference: http://stackoverflow.com/questions/285177/how-do-i-call-one-constructor-from-another-in-java
Saturday, January 3, 2015
SimpleDateFormat Strange Results / Thread Safety
SimpleDateFormat can give strange results when running on a server when multiple threads share the same instance. This is because it is not thread-safe due to intermediate results being stored in instance variables. To avoid this problem always instantiate a new SimpleDateFormat object when needed or find a way to ensure there is one instance per thread (e.g. using ThreadLocal).
References:
References:
Monday, December 15, 2014
Cocos2D-X: Saving User Data
Example in this post (i.e. the one with UserDefault): http://discuss.cocos2d-x.org/t/save-userdefault-data-on-android/15272/4
Thursday, December 11, 2014
C++ Necessary to Call Base Destructor?
The answer is no, it is automatically called, but it is also somehow important that the destructor is virtual if the class will be inherited.
Reference: http://stackoverflow.com/questions/677620/do-i-need-to-explicitly-call-the-base-virtual-destructor
Reference: http://stackoverflow.com/questions/677620/do-i-need-to-explicitly-call-the-base-virtual-destructor
Cocos2D-X: Convert String to Integer and Testing For Numeric Value
These can be done quite simply by converting the String to a Cocos2D-X String object and then calling the "intValue()" function on the String. If it is a numeric value, the function will return the value which you can use, or if it is not a numeric value, it will return 0 so it also serves for a test for numeric value, unless of course the value is "0" and you should test for that first.
int val;
String* str = String::create(“123”);
// test for 0
if(str->compare(“0”) == 0){
val = 0;
}
else {
val = str->intValue();
if(val == 0){
// String is not numeric, handle the error here
}
else{
// String is numeric and its value is saved in the “val” variable
}
}
|
Wednesday, December 10, 2014
Cocos2D-X: EventListenerTouchOneByOne no viable overloaded '='
In Cocos2D-X version 3.0 and newer, there is a new way of handling touches (see example code below).
However the first time I used this, I encountered a compile error with message "EventListenerTouchOneByOne no viable overloaded '='" in lines 4-6 below. When this compile error happens, one reason is because of a wrong return type on their callbacks.
The "onTouchBegan" callback has return type "bool". The rest need to have return type "void". Otherwise you will get the compile error above (I had all of them with return type "bool").
However the first time I used this, I encountered a compile error with message "EventListenerTouchOneByOne no viable overloaded '='" in lines 4-6 below. When this compile error happens, one reason is because of a wrong return type on their callbacks.
EventListenerTouchOneByOne* touchListener = EventListenerTouchOneByOne::create();
touchListener->setSwallowTouches(true);
touchListener->onTouchBegan = CC_CALLBACK_2(MyLayer::touchBegan,this);
touchListener->onTouchEnded = CC_CALLBACK_2(MyLayer::touchEnded,this);
touchListener->onTouchCancelled = CC_CALLBACK_2(MyLayer::touchCancelled,this);
touchListener->onTouchMoved = CC_CALLBACK_2(MyLayer::touchMoved,this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
|
The "onTouchBegan" callback has return type "bool". The rest need to have return type "void". Otherwise you will get the compile error above (I had all of them with return type "bool").
bool MyLayer::touchBegan(Touch *touch, Event *event) {
return true;
}
void MyLayer::touchEnded(Touch *touch, Event *event) {
}
void MyLayer::touchCancelled(Touch *touch, Event *event) {
}
void MyLayer::touchMoved(Touch *touch, Event *event) {
}
|
Monday, December 8, 2014
Cocos2D-X Dynamic Label Height
Setting height to 0 seems to do the trick here.
Cocos2D-X Display Long Text
When displaying long text in Cocos2D-X, it doesn't seem possible to use a single Label when the text is quite long (e.g. 2000+ characters), as the Label goes completely blank instead of displaying text. Maybe it is because Cocos2D-X uses a texture for this and this somehow blew the texture size limit. To display long text in Cocos2D-X, use multiple labels e.g. one for each paragraph.
Note: to get the height of each label so as to know where to position the next one, call "getBoundingBox()" on the label.
Note: to get the height of each label so as to know where to position the next one, call "getBoundingBox()" on the label.
Thursday, December 4, 2014
Cocos2D-X: Substring
It seems like the best way is to convert to a std::string first and use its substr function, so e.g. from a Cocos2D-X String object:
Note: for Cocos2D-X 3.0 and above
Reference: http://www.cplusplus.com/reference/string/string/substr/
cocos2dxString->_string.substr(pos,len);
|
Note: for Cocos2D-X 3.0 and above
Reference: http://www.cplusplus.com/reference/string/string/substr/
Git Push Specific Branch
E.g. to push master branch only:
Reference: http://stackoverflow.com/questions/1947972/how-can-i-push-a-specific-branch-of-git-to-my-server
git push origin master
|
Reference: http://stackoverflow.com/questions/1947972/how-can-i-push-a-specific-branch-of-git-to-my-server
Wednesday, December 3, 2014
Cocos2D-X: Conversion Between String, std::string, and C String (i.e. char*)
"String" refers to the String class (previously CCString and analogous to the NSString in Objective-C). This is for Cocos2D-X 3.0 and above.
From C String to String, it's actually the standard constructor
From String to C String
From C String to String, it's actually the standard constructor
String* cocos2dxString = String::create(“xxxxx”);
|
From String to C String
cocos2dxString->getCString();
|
From String to std::string
From std::string to String (this requires an indirect conversion it seems)
From std::string to C String
cocos2dxString->_string;
|
From std::string to String (this requires an indirect conversion it seems)
String::create(cocos2dxString->_string.c_str());
|
From std::string to C String
stdString.c_str();
|
Tuesday, December 2, 2014
Cocos2D-X Formatting Number to Two Decimal Places
Format with "%.2f" assuming the number is a floating point type.
Reference: http://stackoverflow.com/questions/4784336/two-decimal-places-using-printf
Reference: http://stackoverflow.com/questions/4784336/two-decimal-places-using-printf
Cocos2D-X Wrapping Text
To do that, call the "setDimensions" function on the Label. The wrapping will be done automatically. Just ensure that there is sufficient height for the additional lines.
Gimp MacOS "Embedded Color Profile"
In summary, if you don't know otherwise, convert it.
Reference: http://docs.gimp.org/en/gimp-imaging-color-management.html
Reference: http://docs.gimp.org/en/gimp-imaging-color-management.html
Error Unzipping File on MacOS: "Error 2 - No such file or directory"
Not sure why this happens but this means the ZIP file is corrupted.
To fix it:
Reference: http://apple.stackexchange.com/questions/135853/error-opening-a-zip-file-no-such-file-or-directory
To fix it:
zip -FF zipfile.zip --out repairedcopy.zip
|
Reference: http://apple.stackexchange.com/questions/135853/error-opening-a-zip-file-no-such-file-or-directory
Tuesday, November 18, 2014
Yum Update Security Requirements Only
It's done with the following command:
Reference: https://access.redhat.com/solutions/10021
- yum update --security
Reference: https://access.redhat.com/solutions/10021
Subscribe to:
Posts (Atom)