<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3102468434043486639</id><updated>2026-09-18T10:14:51.522-07:00</updated><category term="Java"/><category term="Java SE 6"/><category term="Linux"/><category term="Programming"/><category term="Emacs"/><category term="Algorithms"/><category term="C/C++"/><category term="Python"/><category term="VirtualBox"/><category term="Eclipse"/><category term="Lisp"/><category term="Threading"/><category term="TipsAndTricks"/><category term="Performance Tuning"/><category term="Perl"/><category term="TCP/IP Networking"/><category term="Commons DBCP"/><category term="Firefox"/><category term="JDBC"/><category term="JavaScript"/><category term="Puzzles"/><category term="Security"/><category term="shell scripting"/><category term="Common Knowledge"/><category term="Fantom"/><category term="FreeBSD"/><category term="InfoSec"/><category term="LDAP"/><category term="Solaris"/><category term="Spring"/><category term="TIL"/><category term="Tutorial"/><category term="Ubuntu"/><category term="Unix"/><category term="VMWare"/><category term="Windows"/><category term="bash"/><category term="Best Practices"/><category term="Build your PC"/><category term="C++"/><category term="CPU"/><category term="CVS"/><category term="Cool Tools"/><category term="Debugging"/><category term="Hibernate"/><category term="OpenSSL"/><category term="PC Assembling"/><category term="SLF4J"/><category term="SSL"/><category term="Scala"/><category term="vim"/><category term="xVM"/><category term="3G"/><category term="Cool Hacks"/><category term="Cygwin"/><category term="Django"/><category term="EasyMock"/><category term="Elisp"/><category term="Entrepreneur"/><category term="Ethereal"/><category term="Flask"/><category term="Groovy"/><category term="HTML"/><category term="Intel"/><category term="IntelliJ IDEA"/><category term="JDBC-pool"/><category term="JNA"/><category term="JNI"/><category term="JUnit"/><category term="Java EE"/><category term="Kernel"/><category term="LOGback"/><category term="Logging"/><category term="Lua"/><category term="Matplotlib"/><category term="Oracle"/><category term="PlotKit"/><category term="PuTTY"/><category term="Quartz"/><category term="Reference"/><category term="Regular Expressions"/><category term="SFTP"/><category term="Tomcat"/><category term="Vulnerability"/><category term="WTP"/><category term="WYSIWYG Editor"/><category term="Web Technologies"/><category term="XML"/><category term="XWindows"/><category term="irb"/><category term="jackson"/><category term="java 8"/><category term="json"/><category term="leadership"/><category term="ruby"/><category term="ssh"/><category term="system design"/><category term="xterm"/><title type='text'>Roy&#39;s musings</title><subtitle type='html'>On startups, programming and other bits.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>196</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-6921840182787095974</id><published>2022-08-01T14:35:00.006-07:00</published><updated>2022-09-17T14:43:27.070-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="leadership"/><title type='text'>From engineer to manager</title><content type='html'>&lt;p class=&quot;graf graf--p&quot; name=&quot;6ce5&quot;&gt;In 2015, I co-founded &lt;a class=&quot;markup--anchor markup--p-anchor&quot; data-href=&quot;https://www.zycada.com&quot; href=&quot;https://www.zycada.com&quot; rel=&quot;noopener&quot; target=&quot;_blank&quot;&gt;a company&lt;/a&gt; with my friend. Until then I had been working as an individual contributor. Though I had been a technical lead to many projects, I hadn’t managed teams. Over the past 7+ years I have learned a great deal on project and people management. My experience has taught me the most than the books and articles I have read. In this series, I would like to summarize what has worked for me with the hope that it would be helpful for someone following similar trajectory. If you have any feedback, please leave in comments.&lt;/p&gt;&lt;h3 class=&quot;graf graf--h3&quot; name=&quot;c271&quot;&gt;Project and people management&lt;/h3&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;3fbb&quot;&gt;As a manager, you are managing two things: projects and people. They both require different sets of skills.&amp;nbsp;&lt;/p&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;dc44&quot;&gt;For the most part, managing projects can be learnt from reading books. But managing people is a different skill and it  cannot be learnt from books alone. It requires a lot of  interacting with people. It requires listening and understanding people’s &lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;needs&lt;/strong&gt; so that you can help them succeed. Usually these needs are driven by an instinct of self preservation. If you choose to ignore these needs, you are doomed to fail as a manager and you will end up with an unproductive and unhappy team.&lt;/p&gt;&lt;h3 class=&quot;graf graf--h3&quot; name=&quot;7a91&quot;&gt;Project management &lt;/h3&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;2df3&quot;&gt;&lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;Task&lt;/strong&gt; is the basic unit of project management. Though it may sound trivial, I didn&#39;t have this clarity at the start.&lt;/p&gt;Tasks have &lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;priorities&lt;/strong&gt;. Most of my spectacular failures have been around misplaced priorities. There may be a task to build a cool feature using the latest and greatest GraphQL database with micro services. There may be another task which is a boring bug fix that is blocking a customer. Your developer may be excited and start working on the cool task, while there is a waiting or disgruntled customer. It is my responsibility to prioritize the task and to help the team see &lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;why&lt;/strong&gt; a task is important.&lt;p class=&quot;graf graf--p&quot; name=&quot;ae06&quot;&gt;When I am going through the list of tasks, I ask only one question: have I assigned the right priority to the task? I follow a guideline that the tasks that are blocking a customer from getting something done demand immediate attention. Those are the ones assigned highest priority.&lt;/p&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;4c31&quot;&gt;Depending on the priority, tasks are committed. Every committed task has &lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;deadline&lt;/strong&gt;.&amp;nbsp;&lt;/p&gt;&lt;blockquote class=&quot;graf graf--blockquote&quot; name=&quot;8dd8&quot;&gt;&lt;strong class=&quot;markup--strong markup--blockquote-strong&quot;&gt;How specific the deadline should be?&lt;/strong&gt; You can say a task will be done by 3:30 PM tomorrow. In my experience, this is usually a bad idea. I follow this rule of thumb: if the task will take less than a week of effort, I specify the deadline in days. Else I specify the deadline in weeks. For instance a task that will take three weeks, don’t specify the dead line as Wednesday 4:00 PM of the third week. I say the deadline is third week. It could happen any time during the third week. Why is this important? I have observed that teams generally have high morale when they commit to a deadline and hit it.&lt;/blockquote&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;5335&quot;&gt;Tasks also have &lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;dependencies&lt;/strong&gt;.
 To keep track of dependencies, every project management system provides
 some means. For instance, JIRA has “Blocked By” field where you can 
specify dependent tasks.&lt;/p&gt;&lt;h3 class=&quot;graf graf--h3&quot; name=&quot;d461&quot;&gt;Illusion of infinite&amp;nbsp;time&lt;/h3&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;fd05&quot;&gt;A critical mistake that I kept repeating was &lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;saying yes to every task&lt;/strong&gt; and allowing tasks to be re-prioritized arbitrarily. At the end of the week, I will find myself very frustrated and most of what was planned at the beginning of the week was pushed to the next week. This frustration was contagious. My team also will feel frustrated. When I say yes to everything, I am living under the &lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;illusion of infinite time&lt;/strong&gt;.&amp;nbsp;&lt;/p&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;08f5&quot;&gt;Once a set of tasks are committed, your team’s flow should not be disturbed unless there is a valid reason. I use the same guideline here: is there a &lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;customer blocked&lt;/strong&gt; by some broken functionality? Then it makes sense to stop working on a committed task and unblock the customer. &lt;em class=&quot;markup--em markup--p-em&quot;&gt;A customer being blocked is different from customer asking for a feature&lt;/em&gt;. When a customer is asking for a feature, you can negotiate when it will be delivered. Your doesn’t need to drop everything and start working on the feature.&lt;/p&gt;&lt;h3 class=&quot;graf graf--h3&quot; name=&quot;8422&quot;&gt;&lt;strong class=&quot;markup--strong markup--h3-strong&quot;&gt;Bottlenecks&lt;/strong&gt;&lt;/h3&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;2f84&quot;&gt;The most valuable skill I developed was to identify people and process bottlenecks. You may not even recognize there is a bottleneck in your team that is preventing from scaling. I developed a simple test for identifying people bottlenecks.&lt;/p&gt;&lt;blockquote class=&quot;graf graf--blockquote&quot; name=&quot;53a5&quot;&gt;Every time when someone says only X can do a task, X is a bottleneck.&lt;/blockquote&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;2ff5&quot;&gt;The test is simple and effective. Let me explain. As a manger in a planning meeting, if you find yourself repeating statements like “DNS change can only be done by Joe”, or “bootstrapping a new server can only be done by Kathy”, you know that Joe and Kathy are bottlenecks. Over a period of time, you will find that they will accumulate a set of tasks that can only be done by them. Soon they will be overloaded and worst case burnt out.&amp;nbsp;&lt;/p&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;0ac9&quot;&gt;There a few techniques you can use to address people bottlenecks. &lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;If you have to do a task twice, automate right from first time.&lt;/strong&gt; I have seen people giving an excuse that they will &lt;em class=&quot;markup--em markup--p-em&quot;&gt;automate next time&lt;/em&gt; as they are under time pressure. Guess what, &lt;em class=&quot;markup--em markup--p-em&quot;&gt;next time&lt;/em&gt; to automate never comes. And you will find the person doing the same task manually next time as well. If you are under time pressure, let the person do it manually and then automate. If you don’t have time pressure, automate first.&lt;/p&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;4a36&quot;&gt;If the task cannot be automated, due to whatever be the limitation, convert the task into a &lt;strong class=&quot;markup--strong markup--p-strong&quot;&gt;easy to follow set of steps with an associated check list&lt;/strong&gt;. Documenting the steps will also bring to light what is involved in the task and ask yourself the question why it cannot be automated. Documenting the steps also lets someone else in the team to pick up the task the next time.&lt;/p&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;278b&quot;&gt;Process bottlenecks can be identified only when you have listed down steps involved in a process.&lt;/p&gt;&lt;h3 class=&quot;graf graf--h3&quot; name=&quot;2a66&quot;&gt;Art of asking questions&lt;/h3&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;c5ed&quot;&gt;The best way to encourage your team to participate in a conversation is to ask open questions. If you ask “Isn’t Redis the right back end for this task?”, your developer might say “yes” and go and go and use it.&lt;/p&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;ff68&quot;&gt;Instead if you ask them an open question like “What do you think is the right back end for this task?”, you will hear a totally different answer. They may tell you about a few back ends they have used in the past, what are the pros/cons of each of them, what they read in the Hacker News about this latest back end, etc. You can &lt;b&gt;let your team member be a hero&lt;/b&gt; who came up with the right back end. When people feel that they came up with an idea, they have a strong sense of ownership and feel more accountable. If you see any issues with the solution being proposed, you can ask a follow up question that will guide them to come up with the right solution.&amp;nbsp;&lt;/p&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;5d7d&quot;&gt;Who knows they may propose Redis itself. Except this time they will feel like a hero for coming up with that answer and feel totally committed to it.&amp;nbsp;&lt;/p&gt;&lt;h3 class=&quot;graf graf--h3&quot; name=&quot;7e95&quot;&gt;Summary&lt;/h3&gt;&lt;p class=&quot;graf graf--p&quot; name=&quot;335e&quot;&gt;I can summarize my learning as:&lt;/p&gt;&lt;ol class=&quot;postList&quot;&gt;&lt;li class=&quot;graf graf--li&quot; name=&quot;40c1&quot;&gt;Being a manager involves project and people management.&lt;/li&gt;&lt;li class=&quot;graf graf--li&quot; name=&quot;4cb4&quot;&gt;Don’t fall victim to illusion of infinite time. Learn to say no.&lt;/li&gt;&lt;li class=&quot;graf graf--li&quot; name=&quot;d4fc&quot;&gt;Learn to prioritize. Every task is created with a priority.&lt;/li&gt;&lt;li class=&quot;graf graf--li&quot; name=&quot;a7a6&quot;&gt;To scale, identify and fix people and process bottlenecks.&lt;/li&gt;&lt;li class=&quot;graf graf--li&quot; name=&quot;e135&quot;&gt;Ask open ended questions.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/6921840182787095974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/6921840182787095974' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6921840182787095974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6921840182787095974'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2022/08/from-engineer-to-manager.html' title='From engineer to manager'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-6447879384051241097</id><published>2019-12-03T23:14:00.000-08:00</published><updated>2019-12-03T23:27:20.973-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="system design"/><title type='text'>Service health checks - the right way to build them</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Service health checks are ubiquitous. If you have built any software that relies upon any upstream service, I am sure you would have used some form of health check. Your software could be a stand alone program or it could be a proxy. You may also have built and exposed a service that is used as an upstream service by another software.&lt;br&gt;
&lt;br&gt;
The worst way to perform health check is to pull a resource (like GET /hc.html, if your service is exposed as a HTTP service) or perform a TCP connect check in the &lt;b&gt;same port where data is served&lt;/b&gt;. These are checks I call as &lt;b&gt;&lt;i&gt;in-band health checks&lt;/i&gt;&lt;/b&gt;.&amp;nbsp;&lt;b&gt;Please don&#39;t do these.&lt;/b&gt;&lt;br&gt;
&lt;br&gt;
Based on my experience, the best way to expose health checks is by using an &lt;b&gt;out-of-band&lt;/b&gt; mechanism. This means that you expose another port for performing health check. The client can perform a HTTP check or TCP check in the health check port. As a convenience, if you expose health check as HTTP service in health check port, you can consolidate multiple health checks like: GET /healthcheck/port1, GET /healthcheck/port2, etc.&lt;br&gt;
&lt;br&gt;
One convention that could be used is to use a fixed offset port as control port for any data port. For instance, 80&#39;s control port is 81 and 443&#39;s control port is 444. Or 80&#39;s control port is 8080, and 443&#39;s control port is 8443. So when you need to decide if the service is up/down, you can check the control port.&amp;nbsp;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Now let me explain what is the benefit of the out-of-band health checks. If you would like to take the service down gracefully for maintenance, all that you have to do is to fail health checks for that port (GET /healthcheck/port1 returns a 4xx) or stop listening in the health check port. &lt;b&gt;This will not impact any of the on-going requests.&lt;/b&gt; You can gracefully close the connections after serving the requests or after a period of idle time. This will enable you to perform scheduled maintenance like a champ without impacting any client traffic at all. Having &lt;b&gt;zero impact&lt;/b&gt; to any client traffic should be your number one goal, when performing scheduled maintenance.&lt;br&gt;&lt;br&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/6447879384051241097/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/6447879384051241097' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6447879384051241097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6447879384051241097'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2019/11/service-health-checks-right-way-to.html' title='Service health checks - the right way to build them'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-5238517038482080047</id><published>2018-02-26T20:38:00.000-08:00</published><updated>2018-02-26T20:38:31.574-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="shell scripting"/><category scheme="http://www.blogger.com/atom/ns#" term="TIL"/><title type='text'>TIL: Keeping parent directory structure while copying</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
There had been instances when I wanted to copy &quot;/home/roy&quot; to a target directory &quot;/target&quot; as &quot;/target/home/roy&quot;. I used to do some scripting foo to get this done. A few days back, I learned this cool option called &quot;--parents&quot; in cp command that will preserve the parent directory structure while copying. Made my life a lot easier on one of my backup tasks.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/5238517038482080047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/5238517038482080047' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/5238517038482080047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/5238517038482080047'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2018/02/til-keeping-parent-directory-structure.html' title='TIL: Keeping parent directory structure while copying'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-6873631930035704338</id><published>2017-07-24T14:45:00.002-07:00</published><updated>2017-07-24T14:45:51.036-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TIL"/><title type='text'>Today I Learned (TIL)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Today I Learned (TIL) is a series of posts that contain bit sized information that I learned and found to be worthy of sharing with others and keep as a note to myself.&lt;br /&gt;
&lt;br /&gt;
For the last couple of years, I had been devoting most of my time in building the start-up, &lt;a href=&quot;https://www.zycada.com/&quot;&gt;Zycada Networks&lt;/a&gt;, that I co-founded. It makes me happy to share my knowledge. So I would like to get back to the habit of writing blog posts regularly on interesting stories, tips-and-tricks, new ideas, technology trends, etc. TIL is one part of doing it.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/6873631930035704338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/6873631930035704338' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6873631930035704338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6873631930035704338'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2017/07/today-i-learned-til.html' title='Today I Learned (TIL)'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-5587707385576761397</id><published>2017-07-24T14:00:00.001-07:00</published><updated>2017-07-24T14:00:21.664-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="shell scripting"/><category scheme="http://www.blogger.com/atom/ns#" term="TIL"/><category scheme="http://www.blogger.com/atom/ns#" term="TipsAndTricks"/><title type='text'>TIL: Sort human friendly values</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Sorting numeric values in the input is easy. It just takes &quot;sort -n&quot;. But what if the input contains human friendly units. For intance, &quot;5G&quot;, &quot;3M&quot;, &quot;4K&quot;, etc. There is a flag to recognize and sort based on the human friendly units: &quot;-h&quot;.&lt;br /&gt;
&lt;br /&gt;
Incorrect: du -h | sort -nr&lt;br /&gt;
Correct: du -h | sort -rh&lt;br /&gt;
&lt;br /&gt;
Caveat: &quot;sort -h&quot; works only on upper-case units. &quot;K&quot; will be treated as kilos, but &quot;k&quot; will not be!&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/5587707385576761397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/5587707385576761397' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/5587707385576761397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/5587707385576761397'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2017/07/til-sort-human-friendly-values.html' title='TIL: Sort human friendly values'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-2765740023379268142</id><published>2017-07-19T01:06:00.000-07:00</published><updated>2022-08-28T08:41:16.366-07:00</updated><title type='text'>Aligning text in emacs</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Aligning text like a table is often a useful task. I use this workflow to make the text tidier. For instance when I have two columns of text of varying width, aligning them makes it easier to read.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
1) Select the region you would like to align (C-x h will select the entire buffer)&lt;br /&gt;
2) C-u M-x align &lt;enter&gt;&lt;/enter&gt;&lt;br /&gt;
&lt;br /&gt;
Thats it. The selected region would have been aligned based on the first line of the region.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Before:&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;what? who?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;hello &amp;nbsp; &amp;nbsp; &amp;nbsp;world&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;what? who?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;hello world&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
By default only the space is used as a delimiter. If you would like to perform a little sophisticated alignment, you can make use of the align-regex function.&lt;br /&gt;
city, population&lt;br /&gt;
new york, 8.49M&lt;br /&gt;
san francisco, 0.85M&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/2765740023379268142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/2765740023379268142' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/2765740023379268142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/2765740023379268142'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2017/07/aligning-text-in-emacs.html' title='Aligning text in emacs'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-349431009842428220</id><published>2015-03-11T02:58:00.000-07:00</published><updated>2015-03-11T03:00:36.066-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Bit twiddling in JDK to generate random number</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Some time back a friend asked me an algorithm question:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Given an integer random number generator randomN() that can generate random number in the range [0, N), how will you generate random numbers in the range [0, M) where M&lt;n .=&quot;&quot; p=&quot;&quot;&gt;&lt;/n&gt;&lt;/blockquote&gt;
I used modulo arithmetic to generate the desired random numbers in the range [0, M). And I reasoned out that if N = q*M + r, every number in the range [0, r] has an occurrence probability of (q+1)/N, but the numbers in the range [r+1, M) has an occurrence probability of only q/N. &lt;br /&gt;
&lt;br /&gt;
It is easy to visualize this. See the diagram below:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPvOrMhuml3yKijbBVjsIf8UB-2VdvdDJ9WM3RxvC9p7rV2LUyAaqzMFes2dSQHZ06BlzPbNCwnJXyZyKQteIZCxcwF-2kO4Lcwf6cX06l1cmLXquwENhdpwXj5SX1v818GjmnD5o1AfY/s1600/M-using-N+(1).png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPvOrMhuml3yKijbBVjsIf8UB-2VdvdDJ9WM3RxvC9p7rV2LUyAaqzMFes2dSQHZ06BlzPbNCwnJXyZyKQteIZCxcwF-2kO4Lcwf6cX06l1cmLXquwENhdpwXj5SX1v818GjmnD5o1AfY/s1600/M-using-N+(1).png&quot; height=&quot;54&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
You can see that we can divide line of length N units (given in green) by lines of length M units (given in black). When N is not exactly divisible by M, in the last part alone we have only r units.&lt;br /&gt;
&lt;br /&gt;
So if we choose a random integer in the line represented in green, and then take a modulo M on the value, all the values except the values in the range [r+1, M) (represented in red) will occur q+1 times. But the values in that interval will occur only q times.&lt;br /&gt;
&lt;br /&gt;
So how do we generate uniform random numbers? Solution is very simple: when the generated random number is in the last segment, just discard the number and regenerate another random number. My solution looked like this:&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;maxAllowed = N - (N mod M)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;do {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; randValue = randomN()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;} while (randValue &amp;gt;= maxAllowed)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;return maxAllowed mod M&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Recently I was reading the Java API documentation for &lt;a href=&quot;http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#nextInt(int)&quot;&gt;Random.nextInt(M)&lt;/a&gt;. And I stumbled upon a clever trick that actually does what I did using some bit twiddling. The next(numBits) in Java code generates random numbers of length numBits. Since signed integers are 31 bits, internally nextInt(M) calls next(31). This will return values in the range of [0, MAX_INT + 1). Now using this the code generates a random number in the range of [0, M). What is the clever trick here? Look at how integer overflow is used to detect boundary condition.&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #353833;&quot;&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;do {&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;bits = next(31);&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;val = bits % n;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;} while (&lt;b&gt;bits - val + (n-1) &amp;lt; 0&lt;/b&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This boundary condition is similar to &quot;randValue &amp;gt;= maxAllowed&quot; condition in my code.&lt;br /&gt;
&lt;br /&gt;
Personally I feel that my code is easier to understand and (I guess) performs better. The reason why I guess my code performs better is due to the fact that it does modulo arithmetic exactly two times. But JDK&#39;s code performs modulo arithmetic every time in the loop. Also for checking the condition it performs addition of four values, while my boundary condition is a straight forward comparison.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Yet it was interesting to see this piece of code and spend some time to understand what it is actually doing.&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/349431009842428220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/349431009842428220' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/349431009842428220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/349431009842428220'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2015/03/bit-twiddling-in-jdk-to-generate-random.html' title='Bit twiddling in JDK to generate random number'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPvOrMhuml3yKijbBVjsIf8UB-2VdvdDJ9WM3RxvC9p7rV2LUyAaqzMFes2dSQHZ06BlzPbNCwnJXyZyKQteIZCxcwF-2kO4Lcwf6cX06l1cmLXquwENhdpwXj5SX1v818GjmnD5o1AfY/s72-c/M-using-N+(1).png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-3477722559385113118</id><published>2014-09-08T11:20:00.000-07:00</published><updated>2014-09-08T11:20:46.088-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Best Practices"/><category scheme="http://www.blogger.com/atom/ns#" term="java 8"/><title type='text'>Is accepting Optional as argument a code smell?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I was reviewing some piece of code and came across a function that was taking &lt;a href=&quot;http://docs.oracle.com/javase/8/docs/api/java/util/Optional.html&quot;&gt;Optional&lt;t&gt;&lt;/t&gt;&lt;/a&gt;&amp;nbsp;as argument. In the same class, another function was taking a couple of Optional&lt;t&gt; as arguments.&lt;/t&gt;&lt;br /&gt;
&lt;br /&gt;
When I thought about it, I felt that taking an Optional&lt;t&gt; should be avoided. You can return an Optional&lt;t&gt; from a function, but avoid taking Optional&lt;t&gt; arguments. Before calling a function, you should check for the presence or absence of the values that you are passing. Hence a function taking one or more Optional&lt;t&gt; is a code smell.&lt;/t&gt;&lt;/t&gt;&lt;/t&gt;&lt;/t&gt;&lt;br /&gt;
&lt;br /&gt;
One argument that can possibly presented in favor of taking Optional&lt;t&gt; as argument is every caller checking for the presence of the arguments. Consider the code example below:&lt;/t&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/rosarinjroy/c3483c552d1a3988ee81.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
If you pay attention, the error handling from the caller&#39;s point of view is ugly if the caller wants to report correct error. Much worse, the error check is done after using the values.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;A side effect of product() taking Optional&lt;integer&gt; is that it must return an Optional.&lt;/integer&gt;&lt;/b&gt; Otherwise it has to throw an exception. They both can be avoided if it doesn&#39;t take the Optional argument.&lt;br /&gt;
&lt;br /&gt;
A simplified version will be:&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/rosarinjroy/9102805f5ade102610c6.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/3477722559385113118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/3477722559385113118' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/3477722559385113118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/3477722559385113118'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2014/09/is-accepting-optional-as-argument-code.html' title='Is accepting Optional&lt;T&gt; as argument a code smell?'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-912796436961897005</id><published>2014-07-29T16:40:00.002-07:00</published><updated>2014-07-29T16:40:32.109-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LOGback"/><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><category scheme="http://www.blogger.com/atom/ns#" term="SLF4J"/><title type='text'>A minor annoyance with two argument logging in SLF4J and Scala</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I am using Scala for one of my recent projects. For logging, I am using SLF4J/LOGback. There is one minor annoyance while you are trying to log two argument messages like:&lt;blockquote class=&quot;tr_bq&quot;&gt;
logger.info(&quot;Some log with arg1 [{}] and arg2 [{}].&quot;, arg1, arg2)&lt;/blockquote&gt;
While you compile with sbt you will get the following error:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
[error] both method info in trait Logger of type (x$1: String, x$2: &amp;lt;repeated...&amp;gt;[Object])Unit&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
[error] and &amp;nbsp;method info in trait Logger of type (x$1: String, x$2: Any, x$3: Any)Unit&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
[error] match argument types (String,String,String)&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp;&lt;/blockquote&gt;
If you are getting this error, a small trick that I did to avoid casting to AnyRef or Object was to just add a null argument at the end which will force the Scala compiler to make use of the vararg version. LOGBack just ignores extraneous arguments. Like this:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
logger.info(&quot;Some log with arg1 [{}] and arg2 [{}].&quot;, arg1, arg2, null)&lt;/blockquote&gt;
&lt;br /&gt;
Disclaimer: I am a Scala rookie, hence take my advice with a pinch of salt!&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&amp;nbsp;&lt;/blockquote&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/912796436961897005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/912796436961897005' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/912796436961897005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/912796436961897005'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2014/07/a-minor-annoyance-with-two-argument.html' title='A minor annoyance with two argument logging in SLF4J and Scala'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-812679963850968627</id><published>2014-07-21T23:59:00.001-07:00</published><updated>2014-07-21T23:59:21.587-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="IntelliJ IDEA"/><category scheme="http://www.blogger.com/atom/ns#" term="Scala"/><title type='text'>The most important keyboard shortcut you should know in IntelliJ IDEA</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
TLDR; If you are new to IntelliJ (like me), use &lt;b&gt;&quot;Cmd+Shift+A&quot;&lt;/b&gt; to find your way around.&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Recently I started developing an application in Scala. I am an avid Eclipse user, but unfortunately I felt that the support for Scala is a bit clunky as of today. It was driving me nuts to see some of the Java classes highlighted in red as unknown classes, but restarting the Eclipse or refreshing project was removing those errors.&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Based on my research, I felt that IntelliJ IDEA has better support for Scala. So I wanted to give it a spin. So far I feel so good that I decided to give it a try.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I prefer to get things done using keyboard shortcuts, touching the mouse only for absolutely essential needs. The most important keyboard (and in my opinion the most awesome) shortcut that you should know in IntelliJ is&lt;b&gt; &quot;Cmd+Shift+A&quot;.&lt;/b&gt;&amp;nbsp;This will show you an input box where you can enter a partial string and you will be presented with the list of action or options that is relevant to the search term. For e.g. you can enter &quot;override&quot; and presented with actions relevant to &quot;overriding&quot;.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For Emacs users, this is very similar to &quot;apropos&quot; command. For Eclipse users, this is similar to &quot;Cmd+Shift+L&quot;, but only better.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/812679963850968627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/812679963850968627' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/812679963850968627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/812679963850968627'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2014/07/the-most-important-keyboard-shortcut.html' title='The most important keyboard shortcut you should know in IntelliJ IDEA'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-4996061251085420153</id><published>2014-05-24T20:03:00.000-07:00</published><updated>2014-05-24T20:03:49.200-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Hibernate"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>An absolute essential thing you should know about Hibernate cache</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
You might have used Hibernate for your ORM needs. The most important thing that you should about Hibernate cache is that it is implemented using a Map and a reference every entity that you have read from the database is kept in that Map. The key of that Map is the Entity ID (which could be just a Long or some form of composite primary key you have defined and wrapped in an &lt;a href=&quot;http://docs.jboss.org/hibernate/orm/3.5/javadocs/org/hibernate/engine/EntityKey.html&quot;&gt;EntityKey&lt;/a&gt;). The value stored is the entity itself (proxied).&lt;br /&gt;
&lt;br /&gt;
If you read a 1000 entities (or rows) from the database, a reference to each one of them will be kept in the Map. If those entities have relationships specified (one-to-many or many-to-many) with other entities and those entities should be loaded eagerly, you are asking Hibernate to load a lot more than 1000 entities.&lt;br /&gt;
&lt;br /&gt;
If you venture into processing a large set of rows (say 100,000 rows), a reference to every one those rows is going to be kept in the Map. Sometimes the amount of memory needed could be so large that your process might run out of memory (as mine did).&lt;br /&gt;
&lt;br /&gt;
So what is the life cycle of this Map? This map is part of the &quot;persistence context&quot; that is referenced in Hibernate session. Hence when a Hibernate session is created, this Map contains no elements. As you keep reading or inserting entities, this Map accumulates references to these entities. When you close the session the Map is cleared.&lt;br /&gt;
&lt;br /&gt;
If you would like to deal with a large volume of entities, given below is a strategy that you can follow:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Divide the entire set of entities into smaller batches (like 1000 entities per batch).&lt;/li&gt;
&lt;li&gt;If you have made any updates, &lt;a href=&quot;http://docs.jboss.org/hibernate/orm/3.5/javadocs/org/hibernate/Session.html#flush()&quot;&gt;flush the session once in every batch&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.jboss.org/hibernate/orm/3.5/javadocs/org/hibernate/Session.html#clear()&quot;&gt;Clear the session once in every batch&lt;/a&gt;. This should take care of evicting all the references to the entities and those entities will be GCed.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
The disadvantage of this method is that if there is one or more entities that are referred across that batches, they will be read again once per batch. But the main advantage is that you will keep your memory utilization low.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/4996061251085420153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/4996061251085420153' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/4996061251085420153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/4996061251085420153'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2014/05/an-absolute-essential-thing-you-should.html' title='An absolute essential thing you should know about Hibernate cache'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-8498665798214384997</id><published>2014-04-08T16:05:00.001-07:00</published><updated>2014-05-24T20:04:21.391-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="InfoSec"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenSSL"/><category scheme="http://www.blogger.com/atom/ns#" term="Security"/><title type='text'>Heartbleed bug in OpenSSL </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
There was a serious &lt;a href=&quot;http://www.openssl.org/news/secadv_20140407.txt&quot;&gt;vulnerability&lt;/a&gt; reported in the OpenSSL library that can let the attacker to dump memory contents from the server. Thus the attacker can perform offline analysis of the memory contents and identify sensitive information like private key of the server, key material for SSL sessions, decrypted data that is in memory, etc. This affects any server that uses OpenSSL to implement HTTPS.&lt;br /&gt;
&lt;br /&gt;
I thought I will share some material in one place that will be helpful for people to understand the problem better.&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Description of the problem can be found &lt;a href=&quot;http://heartbleed.com/&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;A simple Python script to test your servers can be found &lt;a href=&quot;https://gist.githubusercontent.com/takeshixx/10107280/raw/8052d8479ad0c6150464748d639b0f5e877e8c37/hb-test.py&quot;&gt;here&lt;/a&gt;&amp;nbsp;or you can use &lt;a href=&quot;http://filippo.io/Heartbleed/&quot;&gt;this site&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;NVD entry for this issue can be found &lt;a href=&quot;https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-0160&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;How some of the companies are responding: &lt;a href=&quot;https://blog.heroku.com/archives/2014/4/8/openssl_heartbleed_security_update&quot;&gt;Heroku&lt;/a&gt;, &lt;a href=&quot;https://aws.amazon.com/security/security-bulletins/aws-services-updated-to-address-openssl-vulnerability/&quot;&gt;AWS&lt;/a&gt;, &lt;a href=&quot;http://blog.lastpass.com/2014/04/lastpass-and-heartbleed-bug.html&quot;&gt;Lastpass&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Hope that helps.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/8498665798214384997/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/8498665798214384997' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/8498665798214384997'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/8498665798214384997'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2014/04/heartbleed-bug-in-openssl.html' title='Heartbleed bug in OpenSSL '/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-6182059764790920111</id><published>2014-04-05T12:13:00.002-07:00</published><updated>2014-05-24T20:20:26.367-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TCP/IP Networking"/><title type='text'>Two important traits of building reliable distributed systems</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Designing a distributed system is hard enough. Even harder to design a distributed system that is reliable. There are many best practices that you can follow to make a reliable distributed system. Based on an issue that I recently troublehooted, there are a couple of them that I think are critical:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Enabling TCP keep-alive between the processes if you are using TCP&lt;/li&gt;
&lt;li&gt;Performing all IO operations with a time out&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
My advise is based on my experience in Linux. But I think it should be applicable to other operating systems as well. When a host goes down with a kernel panic, none of the established connections are closed by sending a FIN or RESET packet. This cauases trouble that the peer process doesn&#39;t know about the other end of the communication being gone. When you enable TCP keep-alive, the kernel sends a zero length packet as per the configuration. Hence if the peer has died due to kernel panic, the zero length packet will not be ACKed. Thus, the peer death is detected. If the peer has died and rebooted, when the zero length packet is sent, the peer responds with RESET packet. Thus the best way to detect peer death is enabling keep-alive.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For Linux, to enable keep-alive, please refer to &lt;a href=&quot;http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/&quot;&gt;this page&lt;/a&gt;. The most important thing is after you open the socket, you should use setsockopt() to set the SO_KEEPALIVE option.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Using timeouts is one way to detect that the service quality is degrading. For e.g. when you try to fetch data from an external system, the external system might be choking due to too many requests and may not be as responsive as it should be. But if you build retry mechanisms based on timeouts, you have to be extra careful. Because sending more requests to an external system might make the situation worse than it should be.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/6182059764790920111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/6182059764790920111' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6182059764790920111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6182059764790920111'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2014/04/two-important-traits-of-reliable.html' title='Two important traits of building reliable distributed systems'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-1353669125423624231</id><published>2013-09-16T17:36:00.001-07:00</published><updated>2022-08-28T08:38:59.746-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jackson"/><category scheme="http://www.blogger.com/atom/ns#" term="json"/><title type='text'>A brief tutorial on using Guava&#39;s Optional with Jackson JSON library</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
One serious limitation of using &lt;a href=&quot;http://wiki.fasterxml.com/JacksonHome&quot;&gt;Jackson&lt;/a&gt; to deserialize the custom defined bean classe is that you cannot differentiate between a value missing in the input JSON or it is present but having null value. Consider the exampel below:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre&gt;class MyBean {
  private String firstName;
  private String lastName;
  // Getters and setters here.
}
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
You cannot differentiate between the JSON inputs {&quot;firstName&quot;: &quot;John&quot;} and {&quot;firstName&quot;: &quot;John&quot;, &quot;lastName&quot;: null}. I.e. the lastName property being present in the input or not.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://code.google.com/p/guava-libraries/&quot;&gt;Guava&lt;/a&gt; library has an excellent tool to express missing values versus null values: &lt;a href=&quot;https://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained&quot;&gt;Optional&lt;/a&gt;. Jackson supports integration with Guava library. The integration library can be accessed from &lt;a href=&quot;https://github.com/FasterXML/jackson-datatype-guava&quot;&gt;jackson-datatype-guava &lt;/a&gt;package. To clearly express the null versus absent values, we can rewrite the bean class above as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre&gt;class MyBean {
  private Optional&amp;lt;String&amp;gt; firstName;
  private Optional&amp;lt;String&amp;gt; lastName;
  // Getters and setters here.
}
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
So before accessing the value, you will be just checking for its presence. I.e. myBean.getFirstName().isPresent().&lt;br /&gt;
&lt;br /&gt;
If you don&#39;t care if the value is present or not, but just want to retrieve the value as null if absent, you can do myBean.fetFirstName().orNull().&lt;br /&gt;
&lt;br /&gt;
BTW, if you are not making use of Guava libraries in your project, you are truly missing something great and makes you productive. Please give it a try.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/1353669125423624231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/1353669125423624231' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/1353669125423624231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/1353669125423624231'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/09/a-brief-tutorial-on-using-guavas.html' title='A brief tutorial on using Guava&#39;s Optional with Jackson JSON library'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-6978127974272456014</id><published>2013-07-15T14:06:00.002-07:00</published><updated>2013-07-15T14:06:40.821-07:00</updated><title type='text'>A Python script to execute Python code like &quot;perl -ne&quot;</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I wrote a small utility script that can be used to run a small snippet of Python code like &quot;perl -ne&quot;. I find it very useful for my needs. Hope it helps you too. Any suggestions welcome.&lt;br /&gt;
You can find the script as a &lt;a href=&quot;https://gist.github.com/rosarinjroy/6003465&quot;&gt;gist here&lt;/a&gt;.
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/rosarinjroy/6003465.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/6978127974272456014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/6978127974272456014' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6978127974272456014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6978127974272456014'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/07/a-python-script-to-execute-python-code.html' title='A Python script to execute Python code like &quot;perl -ne&quot;'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-1870448185801928850</id><published>2013-07-15T13:26:00.000-07:00</published><updated>2013-07-15T13:26:13.268-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bash"/><category scheme="http://www.blogger.com/atom/ns#" term="shell scripting"/><title type='text'>Setting the terminal window title - version 2</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I had earlier written a small snippet about setting the window title from command line. Based on my experience, I felt that I could make it a lot simpler. Here is version of the same function.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
function wtitle {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if [ -z &quot;$ORIG_PS1&quot; ] ; then&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ORIG_PS1=$PS1&lt;br /&gt;&amp;nbsp; &amp;nbsp; fi&lt;br /&gt;&amp;nbsp; &amp;nbsp; export PS1=&quot;\[\033]0;$1 - \u@\h:\w\007\]$ORIG_PS1&quot;&lt;br /&gt;}&lt;/blockquote&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/1870448185801928850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/1870448185801928850' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/1870448185801928850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/1870448185801928850'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/07/setting-terminal-window-title-version-2.html' title='Setting the terminal window title - version 2'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-2280067729956209036</id><published>2013-07-03T11:56:00.001-07:00</published><updated>2013-07-03T12:00:56.053-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="shell scripting"/><category scheme="http://www.blogger.com/atom/ns#" term="Unix"/><title type='text'>A rarely used but very useful option in grep</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I usually do a lot of log analysis. I search for patterns in multiple files in multiple hosts. Then I collate the result and do processing on the result lines. A sample output looks like:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
/tmp/input1.txt: line containing pattern&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
/tmp/input2.txt: another line containing pattern&lt;/blockquote&gt;
&amp;nbsp;As it turns out, I don&#39;t need the file names in the grep result. I always used to remove the file name prefixes using a Perl one-liner. Silly me!&lt;br /&gt;
&lt;br /&gt;
I was pretty sure that this was a common problem and it must have been solved already. When I referred to the &lt;a href=&quot;http://linux.die.net/man/1/grep&quot;&gt;man page of grep&lt;/a&gt;, I came across this gem: &lt;b&gt;-h&lt;/b&gt;. If you specify this option, grep will not prefix each line with a the file name.&lt;br /&gt;
&lt;br /&gt;
There is also&lt;b&gt; -H &lt;/b&gt;option which will prefix each line with a filename even if you are searching in only one file.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/2280067729956209036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/2280067729956209036' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/2280067729956209036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/2280067729956209036'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/07/a-rarely-used-but-very-useful-option-in.html' title='A rarely used but very useful option in grep'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-5116193910768619314</id><published>2013-06-03T14:02:00.000-07:00</published><updated>2013-06-03T14:02:34.746-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Returning to Python</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
After a couple of years or so, I starting making use Python as my main programming language for one of the projects. This time I was making use of the virtualenv to install Python with various modules and just tar it up and copy to different machines. virtualenv saved me tons of time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/5116193910768619314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/5116193910768619314' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/5116193910768619314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/5116193910768619314'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/06/returning-to-python.html' title='Returning to Python'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-1311438093563972819</id><published>2013-04-23T18:37:00.000-07:00</published><updated>2013-04-23T18:37:16.463-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><title type='text'>Zig-zag search</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This is an interesting problem that I ran into. The problem definition goes like this.&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
You are given an array of integers. The array is considerably large (say 5 million elements). You are given two inputs: an index &lt;i&gt;i&lt;/i&gt; in the array and an integer value &lt;i&gt;v&lt;/i&gt;. Start searching the array for value &lt;i&gt;v&lt;/i&gt; from the index &lt;i&gt;i&lt;/i&gt;, and expand your search towards the two edges of the array. Return the index where the value &lt;i&gt;v&lt;/i&gt; occurs closest to index&amp;nbsp;&lt;i&gt;i&lt;/i&gt;. If the value &lt;i&gt;v&lt;/i&gt;&amp;nbsp;occurs on both sides of index &lt;i&gt;i &lt;/i&gt;at an equal distance, return the lower of the two indices. If the value &lt;i&gt;v&lt;/i&gt;&amp;nbsp;does not occur at all, return -1.&lt;/blockquote&gt;
It was very interesting to solve this problem. Give it a shot, you might also like it.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/1311438093563972819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/1311438093563972819' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/1311438093563972819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/1311438093563972819'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/04/zig-zag-search.html' title='Zig-zag search'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-3160949388279292193</id><published>2013-03-23T22:53:00.001-07:00</published><updated>2013-03-23T22:59:56.230-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Emacs"/><title type='text'>Installing Emacs 24.3.1</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Earlier I &lt;a href=&quot;http://royontechnology.blogspot.com/2012/06/installing-emacs-241.html&quot;&gt;blogged&lt;/a&gt; about a little hurdle that I ran into when I was trying to install Emacs 24.1. Since Emacs 24.3.1 was released recently, I thought I would give it a spin.&lt;br /&gt;
&lt;br /&gt;
After downloading &lt;a href=&quot;http://www.gnu.org/software/emacs/#Obtaining&quot;&gt;the source code&lt;/a&gt;, I unzipped the source code and ran configure command. I got a similar error that I was getting before.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiC9WutEk3HOUB8xPRfg3g5u_JxHmPTKLckoXkxBdVDynigC1ynPljBtT1RwCujGbuZ9ulGM3oI3hpcxTtX2cUWXVcD439scBDcmXXhPYX_6We9ZzHkOQQNwfyy-OKaqtTcyPdnAjCXFdK/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; checking for libXaw... configure: error: No X toolkit could be found.  
 If you are sure you want Emacs compiled without an X toolkit, pass  
  --with-x-toolkit=no  
 to configure. Otherwise, install the development libraries for the toolkit  
 that you want to use (e.g. Gtk+) and re-run configure.  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
I am trying to install Emacs on Mint 14. So to satisfy all the dependencies, I installed the missing packages.&lt;br /&gt;
&lt;pre  style=&quot;font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiC9WutEk3HOUB8xPRfg3g5u_JxHmPTKLckoXkxBdVDynigC1ynPljBtT1RwCujGbuZ9ulGM3oI3hpcxTtX2cUWXVcD439scBDcmXXhPYX_6We9ZzHkOQQNwfyy-OKaqtTcyPdnAjCXFdK/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;&quot;&gt;&lt;code style=&quot;color:#000000;word-wrap:normal;&quot;&gt;  sudo apt-get update   
  sudo apt-get install libgtk2.0-dev libtiff4-dev libgif-dev libpng12-dev libxpm-dev libncurses-dev libjpeg-dev libjpeg8-dev libjpeg-turbo8-dev   
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
After installing the dependencies, the usual three step process worked fine.&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiC9WutEk3HOUB8xPRfg3g5u_JxHmPTKLckoXkxBdVDynigC1ynPljBtT1RwCujGbuZ9ulGM3oI3hpcxTtX2cUWXVcD439scBDcmXXhPYX_6We9ZzHkOQQNwfyy-OKaqtTcyPdnAjCXFdK/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; ./configure  
 ./make  
 sudo make install  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Hope this helps if you run into the same problem.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/3160949388279292193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/3160949388279292193' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/3160949388279292193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/3160949388279292193'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/03/installing-emacs-2431.html' title='Installing Emacs 24.3.1'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-6354626258200173832</id><published>2013-03-20T14:54:00.000-07:00</published><updated>2013-06-03T14:03:33.546-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Common Knowledge"/><title type='text'>A late realization on embedding the code using gist</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Off late I started using gist to embed source code in my blog entries. I was thinking about the consequences of doing this (or any form of embedding text using an external site). I realized the following:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;First and foremost the search engines don&#39;t get to index the page based on the key words in the embedded source code. For e.g. consider an embedded gist that demonstrates ServerSocket. Unless I mention about ServerSocket in my blog somewhere, the serarch engine will not associate the blog entry with the ServerSocket as that word appears only in the embedded source code.&lt;/li&gt;
&lt;li&gt;When peopele search for a specific key word in the embedded source code, they will be taken directly to the gist page, instead of the blog entry. This is bad because the user will not get the context and explanation around the source code.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
To understand the depth of the problem, please search for&amp;nbsp;&lt;span style=&quot;background-color: ghostwhite; color: teal; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 16px; line-height: 17.600000381469727px; white-space: pre;&quot;&gt;alias-to-jumphosts-alist &lt;/span&gt;in Google. You will find that the gist is shown first and then the blog entry. Even in this case the blog entry is shown only because it mentions the function in it.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In future I should try to embed the source code in the blog itself and make use of a source code formatter like &lt;a href=&quot;http://alexgorbatchev.com/SyntaxHighlighter/&quot;&gt;SyntaxHighligher&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/6354626258200173832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/6354626258200173832' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6354626258200173832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/6354626258200173832'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/03/a-late-realization-on-embedding-code.html' title='A late realization on embedding the code using gist'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-7538786965100414766</id><published>2013-03-14T13:25:00.000-07:00</published><updated>2013-03-14T13:26:37.095-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Emacs"/><title type='text'>Using dirtrack-mode inside shell mode</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I usually try to automate the things that I repeatedly perform. One the things that I recently automated was:

&lt;br /&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Create a directory with a prefix and today&#39;s date or time as suffix.&lt;/li&gt;
&lt;li&gt;Chdir to the most recently created directory.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
The source code for these utility functions is given below:&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/rosarinjroy/8343d95552d5a3e0b8ed.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
When I use these utility functions inside the Emacs&#39; shell-mode, the shell-mode was unable to keep track of the current directory. The issue is that I am changing directories without making use of the cd command.&lt;br /&gt;
&lt;br /&gt;
Then came the &lt;b&gt;&lt;a href=&quot;http://www.emacswiki.org/emacs/ShellDirtrackByPrompt&quot;&gt;dirtrack-mode&lt;/a&gt;&lt;/b&gt; for the rescue. The idea is very simple: you specify the regular expression where the path appears in your shell prompt. The dirtrack-mode figures out the rest of the stuff.&lt;br /&gt;
&lt;br /&gt;
Now my .emacs file contains the following two lines:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/rosarinjroy/569dfdf6801efe5f0f9c.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
&lt;div&gt; Thats it. Works like a charm. Please note that you might have to modify the regular expression to match where the full path appears in your prompt. &lt;/div&gt;

&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/7538786965100414766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/7538786965100414766' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/7538786965100414766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/7538786965100414766'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/03/using-dirtrack-mode-inside-shell-mode.html' title='Using dirtrack-mode inside shell mode'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-8327327183127400642</id><published>2013-02-11T15:57:00.001-08:00</published><updated>2013-02-11T16:00:36.991-08:00</updated><title type='text'>One sequence per table or one sequence per database </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Let us assume that you are implementing RESTful APIs for your service. Your service has the following two models: users and tweets. While inserting new entities, you should genertate IDs. The IDs for each of these models can be generated in two ways:&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;You can use a sequence (if you are using Oracle) or autoincrement feature (if you are using MySQL) to have per model IDs.&lt;/li&gt;
&lt;li&gt;You can use a global sequence for all the models.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
If you are following the first strategy, you will have user IDs 1, 2, 3, 4, etc. and tweet IDs 1, 2, 3, 4, etc. If you are following the second strategy, you will have user IDs 1, 3, 4, 8, etc. and the tweet IDs 2, 5, 6, 7, etc.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Thinking about it, I felt that using the first strategy will leak information. Consider some one doing a tweet every day at 10:00 AM and get the tweet ID. If first day the tweet ID is 100, and the second day the tweet ID is 200, etc. That person can infer that your system is receiving 100 tweets/day. I don&#39;t know how sensitive this information can be.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I would appreciate your thoughts. Please share them in comments.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/8327327183127400642/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/8327327183127400642' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/8327327183127400642'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/8327327183127400642'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/02/one-sequence-per-table-or-one-sequence.html' title='One sequence per table or one sequence per database '/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-217583365306284976</id><published>2013-02-02T19:06:00.001-08:00</published><updated>2013-02-02T19:06:16.071-08:00</updated><title type='text'>The issue with Emacs &quot;cd&quot; function and CDPATH</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Recently I wasted sometime trying to figure out an issue with &quot;cd&quot; function and autocompletion in Emacs, while I had a value set for CDPATH environment variable. I hope it saves some time for someone who might bump into the same issue.&lt;br /&gt;
&lt;br /&gt;
I had CDPATH environment variable set and it didn&#39;t have &quot;.&quot; (current directory) as one of the components. When I tried autocompletion while running &quot;cd&quot; function, it didn&#39;t show any of the subdirectories under the current directory. The directories it showed for completion were from somewhere else. As soon as I added &quot;.&quot;, I was able to see all the subdirectories of current directory in the autocompletion list.&lt;br /&gt;
&lt;br /&gt;
Hope this saves some time for you as well.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/217583365306284976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/217583365306284976' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/217583365306284976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/217583365306284976'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/02/the-issue-with-emacs-cd-function-and.html' title='The issue with Emacs &quot;cd&quot; function and CDPATH'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3102468434043486639.post-5386982099338548735</id><published>2013-01-23T15:53:00.001-08:00</published><updated>2013-01-23T15:53:50.124-08:00</updated><title type='text'>Enabling multiple cores in VirtualBox</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This post is a follow up to my earlier post&amp;nbsp;&lt;a href=&quot;http://royontechnology.blogspot.com/2013/01/moving-from-vmware-player-to-virtualbox.html&quot;&gt;Moving from VMWare Player to VirtualBox&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Once you have set up your VirtualBox instance, the first challenge you will face is that the guest OS may possibly be very slow due to the fact that the number of cores allowed is only one. Hence you will have to increase the number of cores that your guest OS can make use of. Open the VirtualBox manager, click on your VM, then click on the Settings button. In the Settings window, click on the System on the left pane and select the Processor tab on the right.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGr5BNjET2DU1Heds_KDt1q_wMciNSn8z3m3XSeaS2bLXvQaKHoVlwCveLbUv-H-zfw1pQRYumttCTkf5n5FVnrU_wOOaItNfPpypn8hofzKHZL2N6o0jO1d9F6-Z5pxqWo_OaTe8X4Vs/s1600/virtualbox-processor.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;265&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGr5BNjET2DU1Heds_KDt1q_wMciNSn8z3m3XSeaS2bLXvQaKHoVlwCveLbUv-H-zfw1pQRYumttCTkf5n5FVnrU_wOOaItNfPpypn8hofzKHZL2N6o0jO1d9F6-Z5pxqWo_OaTe8X4Vs/s320/virtualbox-processor.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
In this page, you can increase the number of processors. If you haven&#39;t already enabled the virtualization in your processor, you are likely to get an error when you click on OK. The error message will look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Failed to open a session for the virtual machine Lubuntu.&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;VD: error VERR_NOT_SUPPORTED opening image file &#39;C:\VMs\Lubuntu.vmdk&#39; (VERR_NOT_SUPPORTED).&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Result Code: E_FAIL (0x80004005)&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Component: Console&lt;/span&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;Interface: IConsole {db7ab4ca-2a3f-4183-9243-c1208da92392}&lt;/span&gt;&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you see this error, you haven&#39;t possibly enabled the virtualization in the processor. Virtualization can be enabled only from the BIOS. Please refer to your computer&#39;s manufacturer web site to find out how to enable this. For your reference, I am giving a&lt;a href=&quot;http://forums.lenovo.com/t5/W-Series-ThinkPad-Laptops/Lenovo-Thinkpad-w520-Virtualization-Technology-How-to-enable/ta-p/520017&quot;&gt; link to how to enable it in ThinkPad W520&lt;/a&gt; (which I own).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Once the virtualization is enabled, you can restart your computer and try to increase the number of cores dedicated your guest OS again. Hopefully, you will not get the same error again.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Thats it. Boot your guest OS and enjoy!&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://royontechnology.blogspot.com/feeds/5386982099338548735/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3102468434043486639/5386982099338548735' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/5386982099338548735'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3102468434043486639/posts/default/5386982099338548735'/><link rel='alternate' type='text/html' href='http://royontechnology.blogspot.com/2013/01/enabling-multiple-cores-in-virtualbox.html' title='Enabling multiple cores in VirtualBox'/><author><name>Roy</name><uri>http://www.blogger.com/profile/00633074227808113222</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGr5BNjET2DU1Heds_KDt1q_wMciNSn8z3m3XSeaS2bLXvQaKHoVlwCveLbUv-H-zfw1pQRYumttCTkf5n5FVnrU_wOOaItNfPpypn8hofzKHZL2N6o0jO1d9F6-Z5pxqWo_OaTe8X4Vs/s72-c/virtualbox-processor.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>