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
My online tech scrapbook where I keep my notes in case I need to look them up later
Thursday, December 24, 2015
Sunday, December 20, 2015
Postgres Query for Current Running Queries
In short, query the pg_stat_activity table
Reference: http://chrismiles.info/systemsadmin/databases/articles/viewing-current-postgresql-queries/
Reference: http://chrismiles.info/systemsadmin/databases/articles/viewing-current-postgresql-queries/
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
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
Sunday, November 29, 2015
RHEL / CentOS Tomcat Missing Logs
Temporary workaround is to use "journalctl". Still trying to figure out the long-term solution.
References:
References:
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.
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
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
Reference: http://stackoverflow.com/questions/20427689/psql-invalid-command-n-while-restore-sql
Tuesday, September 15, 2015
iOS Test Flight
To enable Test Flight:
- Upload a build to App Store (via XCode)
- Login to iTunes Connect, go to the "Pre-Release" section
- Enable Test Flight for the build
- 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
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:
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:
Wednesday, June 17, 2015
C++: Iterating Through Vector of Pointers
(*iter)->someMethod()
Reference: http://stackoverflow.com/questions/23318875/iterating-through-a-vector-of-pointers
Reference: http://stackoverflow.com/questions/23318875/iterating-through-a-vector-of-pointers
Tuesday, June 16, 2015
Git: Amend Most Recent Commit Message
git commit --amend
Reference: http://stackoverflow.com/questions/179123/edit-an-incorrect-commit-message-in-git
Reference: http://stackoverflow.com/questions/179123/edit-an-incorrect-commit-message-in-git
Wednesday, June 3, 2015
Bash IO Redirection
">" for normal output. "2>" for error output.
Reference: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html
Reference: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html
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
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/
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
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
Reference http://stackoverflow.com/questions/13604137/definition-of-int64-t
Saturday, April 18, 2015
C++ Optional Parameter
You can make an optional parameter by giving it a default value. Important note: you need to do it in the header declaration.
Reference: http://stackoverflow.com/questions/2842928/default-value-of-function-parameter
Reference: http://stackoverflow.com/questions/2842928/default-value-of-function-parameter
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
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, April 14, 2015
PostgreSQL Dump Only One Schema
Use the -n option
Reference: http://dba.stackexchange.com/questions/53185/postgresql-how-to-backup-only-one-schema-from-a-database-and-restore-it-on-anot
Reference: http://dba.stackexchange.com/questions/53185/postgresql-how-to-backup-only-one-schema-from-a-database-and-restore-it-on-anot
PostgreSQL Query Grants
SELECT grantee, privilege_type
FROM information_schema.role_table_grants
WHERE table_name='thetable';
|
Reference: http://stackoverflow.com/questions/7336413/query-grants-for-a-table-in-postgres
Tomcat7 java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory
To solve this, explicitly specify "factory="org.apache.commons.dbcp.BasicDataSourceFactory"" in the "Resource" definition in "context.xml"
References:
References:
Saturday, April 11, 2015
MySQL Dump Schema Only or Data Only
Schema only: "--no-data"
Data only: "--no-create-info"
References:
Data only: "--no-create-info"
References:
Tuesday, March 31, 2015
Tuesday, March 24, 2015
Apache POI List of Supported Spreadsheet Formulas
It's a little outdated (2012) but serves as a good guide for the most part:
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
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
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
|
Friday, February 13, 2015
Android Capturing "Done" Button Event
The recommended way to do this is by setting a "onEditorActionListener"
References:
References:
Android Intercepting Back Button When Keyboard Open
In Android, when the keyboard is open, the back button closes the keyboard and then the key event is swallowed. To capture this key event, override the "onKeyPreIme" method in the EditText class.
Reference:
Reference:
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:
According to this article, some devices may require different flags: http://stackoverflow.com/questions/6281514/android-programmatically-disable-autocomplete-autosuggest-for-edittext-in-emulat
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:
- http://codex.wordpress.org/Common_WordPress_Errors
- http://www.wpbeginner.com/wp-tutorials/how-to-fix-the-wordpress-white-screen-of-death/
To find out the error, enable debug, and the error will be shown in the white screen.
http://codex.wordpress.org/Editing_wp-config.php#Debug
A possible cause is memory, and to give WP more memory: http://www.wpbeginner.com/wp-tutorials/fix-wordpress-memory-exhausted-error-increase-php-memory/
A possible cause is memory, and to give WP more memory: http://www.wpbeginner.com/wp-tutorials/fix-wordpress-memory-exhausted-error-increase-php-memory/
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.
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:
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
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:
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:
Subscribe to:
Posts (Atom)