Thursday, December 24, 2015

Columnar Databases Performance Characteristics Discussions

A discussion detailing performance characteristics of columnar databases, and what situations they are better and what situations they are not.

https://news.ycombinator.com/item?id=3524437

Tuesday, December 15, 2015

JSch Error "com.jcraft.jsch.JSchException: reject HostKey" Even After Host Key Has Been Added

Usually when this error happens, all you need to do is to add the host key in a normal SSH session. However, this can also happen when the host key is in a format that JSch does not recognise or support e.g. I had a problem with a "ecdsa-sha2-nistp256" encoded host key.

To fix this I had to use the "ssh-keyscan -t rsa <hostname>" command (on the server) to obtain the host key in rsa format and then I manually added that to the "known_hosts" file.

Reference: http://anahorny.blogspot.sg/2013/05/solution-for-comjcraftjschjschexception.html

Monday, November 16, 2015

Amazon Making EBS Volume Available for Use

Instructions here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html

Linux List Attached Drives

After adding a drive, it will not be visible to the OS until it is mounted and attached. To view it, use the "lsblk" command.

To check the filesystem status of the drive, use the "file -s /dev/<device>" command. If the response is "data". It means the drive is unformatted.

Thursday, October 29, 2015

SCP Stalling

In some situations, SCP can stall after just around 5-10 seconds, and it happens consistently. This can sometimes be solved by limiting the bandwidth SCP asks for.

Reference: http://askubuntu.com/questions/82984/why-does-scp-get-stalled-how-do-i-resolve-it

Postgres: "invalid command \N" During Restore

This is sometimes a red herring, where the actual error is higher up on the restore script.

Reference: http://stackoverflow.com/questions/20427689/psql-invalid-command-n-while-restore-sql

Tuesday, September 15, 2015

iOS Test Flight

To enable Test Flight:

  1. Upload a build to App Store (via XCode)
  2. Login to iTunes Connect, go to the "Pre-Release" section
  3. Enable Test Flight for the build
  4. Add users
References:

Tuesday, August 25, 2015

Installing AWS CLI Tools

Not all of AWS features are available in the web console. AWS CLI tools is necessary for calling some of the APIs.

Instructions here: https://github.com/aws/aws-cli

AWS S3 Static Website HTTPS

While it is possible to host static websites on AWS S3, additional steps are necessary to enable SSL with your own custom domain.

In order to do that, you will need to create a CloudFront distribution (CloudFront is a CDN service).

The toughest part is uploading the SSL cert, which has to be done by command line API. Guide here: http://knightlab.northwestern.edu/2015/05/21/implementing-ssl-on-amazon-s3-static-websites/

More details on uploading SSL cert: http://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingServerCerts.html

Commands for uploading cert: http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_server-certs_manage.html#UploadSignedCert

Note: remember to specify path

References:

Tuesday, May 5, 2015

Mac App Store Connection Failed

When trying to connect to the Mac App Store, there is the error message "Cannot connect to the app store. An internet connection is required."

There are many documented solutions for this, all of which will probably work for one person or another. However, the only method that worked for me was resetting my keychain: https://support.apple.com/en-sg/HT203192

Other solutions

Wednesday, April 22, 2015

C++: Find string within a string

There is a string::find function that is pretty straightforward to use. The key thing to note here is that when it's not found the return value is "string::npos".

Reference: http://www.cplusplus.com/reference/string/string/find/

C++: Constructing a std::string from std::vector

std::vector<char> is actually a vector of the characters that make up the string.

There is a constructor for std::string that can be used for this i.e. std::string s(v.begin(),v.end());

Reference: http://stackoverflow.com/questions/5115166/how-to-construct-a-stdstring-from-a-stdvectorchar

Monday, April 20, 2015

Coco2D-X: long Values on iOS

"long" isn't guaranteed to be 64 bits on iOS. To be sure that there won't be overflow, use int64_t.

Reference http://stackoverflow.com/questions/13604137/definition-of-int64-t

Friday, April 17, 2015

Cocos2D-X List of Actions

Quick reference here: http://www.cocos2d-x.org/wiki/Actions

Cocos2D-X FadeIn and FadeOut Not Applying to Children of a Sprite

The default behaviour for Cocos2D-X during a FadeIn / FadeOut action is that the only the Sprite will fade in/out, and if it has children, they will be unaffected.

In order for a FadeIn / FadeOut action to apply to the children of a Sprite, call "setCascadeOpacityEnabled(true)" on the parent Sprite.

Reference: http://discuss.cocos2d-x.org/t/fadein-and-fadeout-does-not-apply-to-children-even-in-3-3-final/19079

Tuesday, March 24, 2015

Monday, March 9, 2015

Git Undo Uncommitted Fast Forward Merges

This can only happen when there are conflicts. Fast forward merges are otherwise auto-committed.

git merge --abort

Reference: http://stackoverflow.com/questions/5741407/how-to-undo-a-git-merge-with-conflicts

Monday, February 16, 2015

Java Enum Assign Values

For Java Enums, the values are normally auto-assigned starting from 0.

To assign specific value, see the example here: http://stackoverflow.com/questions/8811815/is-it-possible-to-assign-numeric-value-to-an-enum-in-java

Git: Reverting Back Multiple Commits

Let's say you want to roll back the Git repository back to a specific commit e.g. by getting rid of the last 8 commits. This is how it's done:
git revert HEAD~8..HEAD

Wednesday, February 11, 2015

Wordpress Pagination Multiple Loops

Wordpress pagination can be tricky when you have multiple loops. The trick is obtaining the "paged" variable "get_query_var('paged')" before the first loop starts.

Thursday, February 5, 2015

Cocos2D-X: Disable Keyboard Autocomplete for Android

As at Cocos2D-X 3.2, it is not possible to disable autocomplete in the keyboard and this can prove to be a critical issue e.g. when user is keying in password.

A simple solution (which will disable autocomplete throughout the app) is to edit the "org.cocos2dx.lib.Cocos2dxActivity" file in the Cocos2D-X Android Java library. In the "init()" method, add the following line:

edittext.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | TYPE_TEXT_VARIATION_PASSWORD);

According to this article, some devices may require different flags: http://stackoverflow.com/questions/6281514/android-programmatically-disable-autocomplete-autosuggest-for-edittext-in-emulat

Tuesday, February 3, 2015

Common Causes of Wordpress "White Screen of Death"

Links:



To find out the error, enable debug, and the error will be shown in the white screen.

APC Performance

APC: Alternate PHP Cache

Here is a study about potential performance gains: http://www.webperformance.com/library/reports/SugarAPC/

Conclusion in this test was that it gave 180% performance improvement meaning 2.8 times original performance.

TypeError: $ is not a function when calling jQuery function

I got this error with one of the plugins in Wordpress. The solution was to edit the JS source file of the WP plugin, and replacing references of "$" with "jQuery".

More info:

Monday, January 26, 2015

AWS Bitnami Default Passwords

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

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:



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

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."
  • 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

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: