Browers that depend on Mac OS keystore such as Chrome will be affected by this. It will tell you one of the intermediate certificates has expired and therefor the SSL cert for the site is no longer secure.
The solution is to delete the locally cached copy from Keychain Access.
Instructions here: https://blog.digicert.com/expired-intermediate-certificate/
My online tech scrapbook where I keep my notes in case I need to look them up later
Monday, July 28, 2014
Sunday, July 27, 2014
Building Cocos2D-X on Android
Instructions here: http://www.cocos2d-x.org/wiki/How_to_Build_an_Android_Project_with_Eclipse
64 Bit Devices for Android by End of Year
Link: http://www.pcworld.com/article/2391020/google-paves-way-for-64bit-android-l-devices-by-year-end.html
Following Apple releasing iPhone 5S on 64-bit platform.
Unclear what the impact will be on app development, especially via NDK.
What's New in Cocos2d-x 3.0?
Link: http://www.cocos2d-x.org/news/216
- A lot of major radical changes
- Massive performance enhancements
- More in line with C++ coding style, moving away from just being a literal direct port of Cocos2D objective C
- Easier to setup projects
- Many many more
Friday, July 25, 2014
Android Multi-line Toast
To do that, simply add "\n" into the text strings as required.
Reference: https://groups.google.com/forum/#!topic/android-developers/LbxGUD_CVGw
Reference: https://groups.google.com/forum/#!topic/android-developers/LbxGUD_CVGw
Tuesday, July 22, 2014
Android Disable ListView Select Highlighting
android:listSelector="@color/Transparent"
References:
Monday, July 21, 2014
Difference Between "description" and "og:description" in meta
Example of "description"
Example of "og:description"
"description" is for search engines which "og:description" if for Facebook's Open Graph. The generally accepted recommendation is to use both.
References:
<meta name="description" content="description content">
|
Example of "og:description"
<meta property="og:description" content="description content">
|
"description" is for search engines which "og:description" if for Facebook's Open Graph. The generally accepted recommendation is to use both.
References:
SEO Basics
A couple of articles that server as a good reference:
Monday, July 14, 2014
TechCrunch Article on Importance of Mobile for Startups
Article: http://techcrunch.com/2014/07/12/software-entrepreneurs-must-go-mobile-first-or-die/
Key quote:
Key points:
Key quote:
Now they’re the default method of computing for most people. As of late last year, Americans spent 34 hours a month on their mobile devices, compared with just 27 hours accessing the web via a computer, according to Nielsen.
|
Key points:
- Keep it simple, don't overbuild
- Users like native apps far more than mobile web browser
- If necessary, figure out workflow and what works best on mobile and what works best on desktop
Low-Level JSON Parsing With Jackson
Jackson is primary used for mapping Java classes to JSON objects. However, there are times where you need to retrieve the raw text content of a specific JSON node rather than to map the entire document to a class.
This can be done with the following code:
References:
This can be done with the following code:
ObjectMapper mapper = new ObjectMapper();
JsonFactory factory = mapper.getJsonFactory();
JsonParser jp = factory.createJsonParser(jsonString);
JsonNode node = mapper.readTree(jp);
JsonNode node1 = node.get(“key1”);
JsonNode node2 = node2.get("key2");
String node2Content = node2.asText();
|
References:
Java sendRedirect https becomes http
This can happen when your Servlet contain is behind a load-balancer and when your load-balancer is handling SSL, and when you are redirecting using a relative URL.
In such a situation, you can't use relative URL. You will instead have to specify the absolute URL to redirect to i.e. the URL starting from "https://".
In such a situation, you can't use relative URL. You will instead have to specify the absolute URL to redirect to i.e. the URL starting from "https://".
MongoDB Limiting Fields Returned With Java API
Use the "public DBCursor find(DBObject ref, DBObject keys)" in the DBCollection class:
- For the "keys", add a key value pair like the following to include a field e.g. "name":
- key: name
- value: 1
- _id is always included by default
- But if _id is all you want, you should include it in keys, otherwise with an empty "keys" object all fields will be returned
Using Temporary Branches in Git
When you're working on something experimental or when you are interrupted and need to switch branch to work on something else and you don't feel that your code is ready to commit to a branch shared with other developers yet, you can create a temporary branch for your commits. Once you're done, you may merge the changes back into your original branch, or discard the changes when you subsequently delete the temporary branch.
Supposing you're currently working on something experimental on branch "dev" that you are not sure about, you may perform your commits on another branch:
Steps:
Supposing you're currently working on something experimental on branch "dev" that you are not sure about, you may perform your commits on another branch:
Steps:
- Create a new branch "dev-temp"
- Checkout the new branch
- Commit your code to "dev-temp"and continue to do so until you're done
- After you are done, and if you want to merge your changes:
- Switch to "dev"
- Merge your changes from "dev-temp" to "dev"
- Delete temporary branch "dev-temp" with "git branch -d dev-temp"
- And if you've never pushed "dev-temp", then you don't have to worry about having to do it. It's your local temporary branch after all.
Javascript getMonth January is 0
It's easy to make this mistake, but for Javascript when you call Date.getMonth(), January is 0 and February is 1 and December is 11.
Sunday, July 13, 2014
JSON Date Representation
When Javascript serialises an Date object in JSON, it will be represented in the following format:
This means that when the user keys in a date on a web-form, and it gets submitted to the server, the exact time saved on the server contains time-zone information. In some applications, this may result in the date being off by 1 days when this date is subsequently used for processing, specifically in situations where you only really needed the date and not the time.
In the above example, it is actually 2014-03-01 in time-zone +0800. If the time is truncated, the processing will use 2014-02-28 instead.
If you want the date to be time-zone neutral, consider submitting the data to the server as a formatted date string of your choice.
2014-02-28T16:00:00.000Z
|
This means that when the user keys in a date on a web-form, and it gets submitted to the server, the exact time saved on the server contains time-zone information. In some applications, this may result in the date being off by 1 days when this date is subsequently used for processing, specifically in situations where you only really needed the date and not the time.
In the above example, it is actually 2014-03-01 in time-zone +0800. If the time is truncated, the processing will use 2014-02-28 instead.
If you want the date to be time-zone neutral, consider submitting the data to the server as a formatted date string of your choice.
Saturday, July 12, 2014
Git Merge Up to a Commit of Another Branch
For branches that have diverged from a certain point, this is done by going to the receiving branch and issuing the command:
git merge <commit-id>
Reference:
git merge <commit-id>
Reference:
Jackson Uses Getter Instead of Variable
Here's a tricky gotcha in Jackson. You have defined an object with private variables and created their respective getters and setters, and that all works well, then you add a convenience method named something like "getXXXX()" and then suddenly there is an extra property "XXXX" in your JSON document. This is because Jackson uses getters rather than variable to decide what properties to write to JSON.
This is demonstrated by the output of this class:
Output:
Notice that "str3", which is defined as a member variable but doesn't have a getter, is missing from the document. Instead, "str4", which has a getter but not a member variable, that is added to the JSON output.
When adding convenience methods to these objects, it is therefore important to not start them with "get".
This is demonstrated by the output of this class:
public class JacsksonTest {
private String str1 = "str1";
private String str2 = "str2";
private String str3 = "str3";
public String getStr1(){return str1;}
public String getStr2(){return str2;}
public String getStr4(){return "str4";}
public static void main(String[] args) throws Exception {
JacsksonTest testObj = new JacsksonTest();
ObjectWriter jsonWriter = (new ObjectMapper()).writerWithDefaultPrettyPrinter();
System.out.println(jsonWriter.writeValueAsString(testObj));
}
}
|
Output:
{
"str1" : "str1",
"str2" : "str2",
"str4" : "str4"
}
|
Notice that "str3", which is defined as a member variable but doesn't have a getter, is missing from the document. Instead, "str4", which has a getter but not a member variable, that is added to the JSON output.
When adding convenience methods to these objects, it is therefore important to not start them with "get".
Wednesday, July 2, 2014
Java HTTP Client: SSL Self-Signed Certificates & IP Address Hostnames
By default, a Java based HTTP client will not allow connection to a "https" endpoint when the server-side certificate is self-signed, and also in the situation where the server uses an IP address rather than a hostname.
They will require separate solutions. For the self-signed certificate, we can use this code to tell Java to trust all certificates.
For the IP address issue, which will throw an error (CertificateException: No subject alternative names present), we can use the following code:
Note: this solution has been tested to work with the Jersey REST client.
References:
They will require separate solutions. For the self-signed certificate, we can use this code to tell Java to trust all certificates.
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager(){
public X509Certificate[] getAcceptedIssuers(){return null;}
public void checkClientTrusted(X509Certificate[] certs, String authType){}
public void checkServerTrusted(X509Certificate[] certs, String authType){}
}};
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustAllCerts, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {}
|
For the IP address issue, which will throw an error (CertificateException: No subject alternative names present), we can use the following code:
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(){
public boolean verify(String hostname, SSLSession session){
// you may choose to return true all the time here or return true for certain IPs
}
});
|
Note: this solution has been tested to work with the Jersey REST client.
References:
Java Hide Command Line Input
If you are asking the user to key in a password and wish to hide it while the user is typing it, the usual approach would not be able to support that.
The solution is to use the java.io.Console class. Other than the "readLine" method for the normal reading of input, it also has a "readPassword" method where nothing is shown as it is typed.
The only downside is that this cannot be used inside an IDE environment.
The solution is to use the java.io.Console class. Other than the "readLine" method for the normal reading of input, it also has a "readPassword" method where nothing is shown as it is typed.
The only downside is that this cannot be used inside an IDE environment.
Git Apply & Revert Changes from Specific Commit
Applying is as simple as using the "cherry-pick" command:
git cherry-pick <commit-id>
This will automatically commit the change. If you do not wish to automatically commit the change:
git cherry-pick -n <commit-id>
It is also possible revert i.e. undo the changes from a specific commit:
git revert <commit-id>
Again, this will automatically commit the change. Use "-n" not to.
git cherry-pick <commit-id>
This will automatically commit the change. If you do not wish to automatically commit the change:
git cherry-pick -n <commit-id>
It is also possible revert i.e. undo the changes from a specific commit:
git revert <commit-id>
Again, this will automatically commit the change. Use "-n" not to.
Subscribe to:
Posts (Atom)