browse by category or date

Ahh.. the joy of not doing anything. Just to watch the world slip and pass by. Everyday my brain is bombarded by hundreds of not-necessarily related information from HackerNews, Kompas, Detik and ChannelNewsAsia. So it’s very convenient to just consume the information without producing any output. Which means my brain will automatically discarded the information the next day. And yes, at the end of the week, I will vaguely remember what was happen in that particular week.

Then I read this article I found in HackerNews. Basically it encourages us to write every day. Yes, EVERY SINGLE FREAKING DAY! Not just every day, but also at least one thousand words.
By doing so, sooner or later you will hit your “masterpiece”. By masterpiece I mean a writing that is not crap 🙂 At least, your brain will mark the information you consumed as “important”. Trust me; you’ll remember more by writing what’s in your brain now.

Sow how to cultivate this habit? In short, they are:

  • Use activation energy: In short, if you reduce the amount of energy to do something, you’ll increase the likeliness of you actually doing that something. One example that Srinivas give is: writing one sentence before you go to bed, go to sleep and let your brain dwell on it. Then expand that one sentence into a complete writing the next day. (Frankly, I haven’t tried this. I have one worry that I might end up thinking too much, resulting in insomnia.)
  • Dealing with writer’s block: Srinivas suggests that the only way to beat this block is just to keep on writing whatever you have in your brain. (Ha, even writing this post I took more than three days. I simply surrender to my procrastinating urge. I need to have stronger will to overcome my procrastinate-self.)
  • The willingness to create crap: Just do it. Just write one thousand words every day. Some of it (well, in my case, most of it) will be crap. Just march on. Pretend that you are inside a dark tunnel. You already see that small dot of light at the end of the tunnel. Dance your finger away to get closer to the exit.

So there you are, I hope you get inspired as I am.
(PS: This post is not even hit 500 words, but I am already running out of words. It’s alright, I still have tomorrow to catch)

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

Harian Kompas hari ini memberitakan mengenai peresmian jembatan Kelok 9 di Sumatra Barat. Sungguh berita ini membuat saya ikut bangga atas prestasi kita di dunia konstruksi.

kelok.9

Namun setelah mengamati gambar di atas beberapa lama. Saya kok jadi ragu apakah ini suatu prestasi, atau malah suatu pemborosan uang. Saya malah terpikir kenapa mereka tidak membuat jalan seperti di bawah ini?

kelok.9.1

Mohon maklum saya tidak tahu situasi geografis dari jembatan Kelok 9 ini. Mungkin para pembaca dari Sumatra Barat bisa memberi pencerahan?

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

Recently I created a program which one of its task is to filter files based on their last update date.

My initial code was something like this:

var procFolder = new DirectoryInfo(ConfigurationManager.AppSettings["ProcessFolder"]);
var mdnFolder = new DirectoryInfo(procFolder.FullName + "\\mdn");
var lastWriteTime = DateTime.Parse(ConfigurationManager.AppSettings["ModifiedDate"]);
var dTarget = new DirectoryInfo(ConfigurationManager.AppSettings["targetFolder"]);

var qMdn = from c in mdnFolder.GetFiles().AsQueryable()
		   where c.LastWriteTime == lastWriteTime
		   select c;
		   
if (qMdn.Count() == 0)
	qMdn = from c in mdnFolder.GetFiles().AsQueryable()
		   where c.LastWriteTime >= lastWriteTime.AddSeconds(-1) 
				&& c.LastWriteTime <= lastWriteTime.AddSeconds(1)
		   select c;
		   
foreach (FileInfo f in qMdn)
{
	f.CopyTo(dTarget.FullName + "\\" + f.Name, true);
}

As I expected, it was slow. It is iterating the files in sequential manner. To make it faster, we need to iterate the files in parallel manner. This is where Parallel LINQ kicks ass. I’ve heard about Parallel LINQ (PLINQ) before, but I never actually tried it.

So I visited PLINQ’s webpage to find out more. Over there, the page states that PLINQ only runs on .NET 4 and above. This is sad, as I’m still stuck with Visual Studio 2008.

Is there a way to run PLINQ in .NET 3.5? With that question, Google led me to a discussion at StackOverflow. From there, I know that Reactive.NET has backported the Task Parallel Library to .NET 3.5, as Jon Skeet mentioned. To make life even easier, Omer Mor has created a nuget called TaskParallelLibrary for easy integration. This nuget contains System.Threading.dll which can be easily included in your project reference.

Once you’ve referenced it in your project, we can use .AsParallel() in our code:

var procFolder = new DirectoryInfo(ConfigurationManager.AppSettings["ProcessFolder"]);
var mdnFolder = new DirectoryInfo(procFolder.FullName + "\\mdn");
var lastWriteTime = DateTime.Parse(ConfigurationManager.AppSettings["ModifiedDate"]);
var dTarget = new DirectoryInfo(ConfigurationManager.AppSettings["targetFolder"]);

var qMdn = from c in mdnFolder.GetFiles().AsQueryable().AsParallel()
		   where c.LastWriteTime == lastWriteTime
		   select c;
		   
if (qMdn.Count() == 0)
	qMdn = from c in mdnFolder.GetFiles().AsQueryable().AsParallel()
		   where c.LastWriteTime >= lastWriteTime.AddSeconds(-1) 
				&& c.LastWriteTime <= lastWriteTime.AddSeconds(1)
		   select c;
		   
foreach (FileInfo f in qMdn)
{
	f.CopyTo(dTarget.FullName + "\\" + f.Name, true);
}

There you go. It’s easy to make Parallel LINQ available to .NET 3.5. But be warned that this method is not suported by Microsoft. If you plan to deploy this in production, Jon Skeet advises us to upgrade to .Net 4.

I hope it helps, cheers!

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant: