In bash, by default, only stdout gets redirected to a file when you use the ">" operator.
To redirect stderr to a file, use the "2>" operator.
To redirect both, use "&>"
Reference:http://www.cyberciti.biz/faq/redirecting-stderr-to-stdout/
My online tech scrapbook where I keep my notes in case I need to look them up later
Sunday, April 7, 2013
Git Undo Staging a File for Commit
If a file has already been staged for commit i.e. via the "git add" command, use the following command to unstage the file:
git reset HEAD <filename>
git reset HEAD <filename>
Tuesday, April 2, 2013
Iterating Through All Loggers & Appenders in LogBack
Most people probably won't need it, but when you do, this will come in handy.
http://stackoverflow.com/questions/7064402/is-it-possible-to-find-logback-log-files-programmatically
http://stackoverflow.com/questions/7064402/is-it-possible-to-find-logback-log-files-programmatically
Monday, April 1, 2013
The "spi" Package in Java Projects
It's quite common to find a package called "spi" in Java projects.
Here's an explanation of what it means and what it's for:
Here's an explanation of what it means and what it's for:
Friday, March 22, 2013
C# Iterate Dictionary
Using "foreach" and "KeyValuePair" as the element. Refer to this: http://stackoverflow.com/questions/141088/what-is-the-best-way-to-iterate-over-a-dictionary-in-c
Monday, March 18, 2013
C# Start New Process
This is how it's done:http://stackoverflow.com/questions/258416/shellexecute-equivalent-in-net
If you need to start multiple processes asynchronously, you'd need to first start multiple threads and then within each thread, each process is started.
Reference for this: http://www.codeproject.com/Articles/25983/How-to-Execute-a-Command-in-C
How to add arguments: http://msdn.microsoft.com/en-sg/library/system.diagnostics.processstartinfo.arguments.aspx
If you need to start multiple processes asynchronously, you'd need to first start multiple threads and then within each thread, each process is started.
Reference for this: http://www.codeproject.com/Articles/25983/How-to-Execute-a-Command-in-C
How to add arguments: http://msdn.microsoft.com/en-sg/library/system.diagnostics.processstartinfo.arguments.aspx
Tuesday, March 12, 2013
C# Getting Time Since Epoch
Many things are simpler in C# than e.g. in Java, but getting the Epoch time is an exception, and this is how it's done.
| TimeSpan timeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1); double currentTime = timeSpan.TotalSeconds; |
Tuesday, February 5, 2013
Ubuntu: Configuring Tomcat
Instead of hacking the startup scripts, some of the common configuration variables can be set in Ubuntu in the file "/etc/default/tomcat7"
Git Log Show File List
To list the files that were involved in each commit:
git log --name-status
References:
git log --name-status
References:
Git Checkout File From Branch
To checkout a file from a specific branch:
git checkout <branchname> <filepath>
References:
git checkout <branchname> <filepath>
References:
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.
Subscribe to:
Posts (Atom)