My online tech scrapbook where I keep my notes in case I need to look them up later
Friday, January 25, 2013
iOS How to Close an App
With multi-tasking, apps no longer really close when you press the home button. It stays in the background and the OS automatically closes them when the device is low on memory and when it thinks the app is unlikely to be used in the near future. To force it to close for e.g. development testing purpose, follow the instructions on this page: http://support.apple.com/kb/ht5137
Thursday, January 24, 2013
AWS DynamoDB Java API Gotcha
If you don't set the end-point, it will default to the US East Virginia region, resulting in an error saying the table can't be found.
The error message you'll get varies. If you have IAM setup to limit access for the user account to this specific DynamoDB table, then you'll get an "AccessDeniedException". Otherwise, you'll get a "ResourceNotFoundException".
If your DynamoDB is configured in the other regions, you'll have to set the End Point after creating the client e.g:
The error message you'll get varies. If you have IAM setup to limit access for the user account to this specific DynamoDB table, then you'll get an "AccessDeniedException". Otherwise, you'll get a "ResourceNotFoundException".
If your DynamoDB is configured in the other regions, you'll have to set the End Point after creating the client e.g:
| client = new AmazonDynamoDBClient(awsCredentials); client.setEndpoint("https://dynamodb.ap-southeast-1.amazonaws.com"); |
AWS DynamoDB ARN for IAM
To give access via IAM to a specific DynamoDB resource, define the ARN as follows:
| arn:aws:dynamodb:<region>:<accountID>:table/<tablename> |
AWS IAM Account ID
The account ID is needed to construct the ARN for IAM entries. AWS isn't being very clear about how to retrieve the account ID. It's actually the Account Number (with the hypens removed) that you see under your name in the "Manage Your Account" page (accessed via the "My Account" link in a drop down menu under your name on the top-right of the console).
Thursday, January 17, 2013
Mac Show Hidden Files in Finder
I usually don't need this feature, as I can use the Terminal to work with hidden files, but when I needed to restore some hidden files from Time Machine, I needed to get Finder to show hidden files.
Here's a couple of links showing how it's done:
Here's a couple of links showing how it's done:
Monday, January 7, 2013
iOS Simulator: View Files
If you ever need to look into the filesystem of an iOS Simulator to e.g. test file download features, here are some information as to how it's done:
Monday, December 24, 2012
Jersey Server Binary File
To serve a binary file such as a ZIP file with a REST service in Jersey, use the following:
| @GET @Produces("application/zip") @Path("{itemId}") public Response downloadItem(@PathParam("itemId") int itemId){ String fileName = "item" + itemId + ".zip"; StreamingOutput streamingOutput = new StreamingOutput(){ public void write(OutputStream output) throws IOException, WebApplicationException { // write data to output stream here } }; return Response.ok(streamingOutput, "application/zip").header("content-disposition","attachment; filename = "+fileName).build(); } |
Sunday, December 23, 2012
Uploading Files to S3 With Ant
This is becoming more and more relevant as S3 is increasingly being used for deployment of software in the cloud.
This is the one I'm currently using.
https://github.com/corley/aws-ant-task
Apparently it's still being actively maintained.
Question on StackOverflow about this: http://stackoverflow.com/questions/3782157/ant-tasks-for-amazon-ec2-s3
This is the one I'm currently using.
https://github.com/corley/aws-ant-task
Apparently it's still being actively maintained.
Question on StackOverflow about this: http://stackoverflow.com/questions/3782157/ant-tasks-for-amazon-ec2-s3
Wednesday, December 12, 2012
Using Hibernate Query Cache in Spring
The steps for configuring the EHCache query cache is the same as when not using Spring. The main difference is how queries is being indicated as cacheable. In Spring, queries are made via the a subclass DAO of the HibernateDaoSupport class, which provides a method to indicate whether all queries in the DAO should use the query cache.
This should be called in the initDao method.
Note that this is for the query cache, not the second-level cache, the latter which is used for "get" operations.
This should be called in the initDao method.
| @Override protected void initDao() throws Exception { super.initDao(); // this enables the usage of query cache for all queries in this DAO this.getHibernateTemplate().setCacheQueries(true); // the cache region name that should be used for this entity this.getHibernateTemplate().setQueryCacheRegion(“XXXXXXX”); // optional, for enabling statistics collection for profiling this.getHibernateTemplate().getSessionFactory().getStatistics().setStatisticsEnabled(true); } |
Note that this is for the query cache, not the second-level cache, the latter which is used for "get" operations.
Tuesday, December 4, 2012
Cocos2D: Z Order
The higher the number, the closer the object is to the viewer.
The lower the number, the further the object is to the viewer.
Jackson Pretty Print
Some of the solutions posted online is deprecated.
Here's the way to do it with a recent version of Jackson.
Here's the way to do it with a recent version of Jackson.
| ObjectWriter jsonWriter = (new ObjectMapper()).writerWithDefaultPrettyPrinter(); String result = jsonWriter.writeValueAsString(obj); |
Processing JSON Response in JMeter
This is a simple and somewhat limited way to do this. You will be able to extract individual values pretty easily but if you want a comprehensive data model of the JSON data structure, this isn't the way to go. If the same property name is used in multiple objects within a JSON data structure, this won't work as well.
Basically this method uses Regular Expressions (using JMeter's Regular Express Extractor) to extract individual values that you're looking for specifically.
Link: http://alexandru-ersenie.com/2009/09/14/json-and-jmeter-extract-json-response/
For more complex requirements, someone has posted about using the BSF PostProcessor and Javascript.
Link: http://www.havecomputerwillcode.com/blog/?p=500
Basically this method uses Regular Expressions (using JMeter's Regular Express Extractor) to extract individual values that you're looking for specifically.
Link: http://alexandru-ersenie.com/2009/09/14/json-and-jmeter-extract-json-response/
For more complex requirements, someone has posted about using the BSF PostProcessor and Javascript.
Link: http://www.havecomputerwillcode.com/blog/?p=500
Tuesday, November 20, 2012
Article on Facebook and Corona
Link: http://gigaom.com/data/facebook-open-sources-corona-a-better-way-to-do-webscale-hadoop/
Corona is for scheduling and managing Hadoop jobs. Interesting part about the article is where it talks about the size and scale of the kind of data Facebook has to analyze and the infrastructure used to host it.
Corona is for scheduling and managing Hadoop jobs. Interesting part about the article is where it talks about the size and scale of the kind of data Facebook has to analyze and the infrastructure used to host it.
Friday, November 16, 2012
AWS S3: IAM Policy for Accessing S3 Bucket
In AWS S3, if you want to have a user account that is able to read/write to an S3 bucket and nothing else, use the following policy statements.
The ListAllMyBuckets permission isn't always needed. But some tools e.g. Cyberduck will have permission problems without it.
| { "Statement": [ { "Sid": "Stmtxxxxxxxxxxxxx", "Action": [ "s3:ListAllMyBuckets" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::*" ] }, { "Sid": "Stmtxxxxxxxxxxxxx", "Action": [ "s3:GetBucketLocation", "s3:ListBucket", "s3:ListMultipartUploadParts" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::bucketname" ] }, { "Sid": "Stmtxxxxxxxxxxxxx", "Action": [ "s3:AbortMultipartUpload", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:GetObject", "s3:GetObjectAcl", "s3:GetObjectVersion", "s3:GetObjectVersionAcl", "s3:PutObject", "s3:PutObjectAcl", "s3:PutObjectVersionAcl" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::bucketname/*" ] } ] } |
Friday, November 9, 2012
Article: Big data to be normal by 2020
Article Link: http://www.theregister.co.uk/2012/10/22/gartner_it_spending_big_data_projections/
Highlights:
Highlights:
- Big data to be as mainstream as ERP and supply chain management
- Social network and clickstream analysis will be the largest portion of big data spending this year
- Shortage of "data scientists" expected
Tuesday, November 6, 2012
iOS: String Format for Numbers With Leading Zeros
To obtain a formatted String with a fixed number or digits, and any shortfall padding by leading zeroes, use the following function call
This will return a String containing the integer "i" and will always be 4 digit long. If i is 1, then the String will be "0001". If it is 12, then the String will be "0012".
| [NSString stringWithFormat:@"%04d", i]; |
This will return a String containing the integer "i" and will always be 4 digit long. If i is 1, then the String will be "0001". If it is 12, then the String will be "0012".
Saturday, November 3, 2012
iOS: Singletons
Recommended way as described in following links, if thread safety is a potential issue:
iOS Dev: Files to Ignore For Version Control
This article provides an example .gitignore file:
http://www.makebetterthings.com/iphone/gitignore-for-ios-projects/
http://www.makebetterthings.com/iphone/gitignore-for-ios-projects/
Friday, November 2, 2012
iOS: Differentiate Between iPhone and iPad
Use the function "UI_USER_INTERFACE_IDIOM()".
If what it returns is equals to "UIUserInterfaceIdiomPad", it's an iPad.
If what it returns is equals to "UIUserInterfaceIdiomPhone", it's an iPhone.
Reference: http://stackoverflow.com/questions/3905603/is-it-safe-to-check-for-ui-user-interface-idiom-to-determine-if-its-an-iphone
If what it returns is equals to "UIUserInterfaceIdiomPad", it's an iPad.
If what it returns is equals to "UIUserInterfaceIdiomPhone", it's an iPhone.
Reference: http://stackoverflow.com/questions/3905603/is-it-safe-to-check-for-ui-user-interface-idiom-to-determine-if-its-an-iphone
iOS Cocos2D Old Splash Screen Still Showing
Somehow, iOS simulators caches the loading image (e.g. Default.png), so even after you've deleted it, it still shows. In order to remove it, you'll need to do a clean operation in XCode, and also reset the simulator.
Reference: http://stackoverflow.com/questions/4768960/cant-get-rid-of-splash-screen-in-xcode
Reference: http://stackoverflow.com/questions/4768960/cant-get-rid-of-splash-screen-in-xcode
Subscribe to:
Posts (Atom)