browse by category or date

1. Practice your math for 10 seconds

Here’s a website where you can train or test your Math brain power. It’s a Math game which you can configure how difficult the game would be. The lifeline starts at 10 seconds, counting down. Every time you get a correct answer, extra seconds will be added to the clock. If you make error, a few seconds deducted from the clock. The game is over when the clock reaches 0.

2. Lockless Programming

Raymond Chen, the Chuck Norris of Microsoft, shares a number of links about Lockless Programming. In programming world, the subject of locks only surfaces once we talk about multi-threading/concurrency/parallel programming. The lock is there to guarantee that only one thread can enter the “Critical Section” of a program. In another word, lock is there to maintain the data integrity across multiple threads. So you’re saying we can achieve data integrity without locks? *third-world-kid-meme*

3. Harddisk Hacking

This hacker shows us how he hacked a hard-disk by flashing malicious code into the disk’s firmware. In the end, he can gain root access with arbitrary password. I’m not really into hardware, but I learned something. His persistence in continuously probing the disk until achieving his goal, it’s an inspiration to never give up.

4. Functional Programming, why you should master it

My progress with F# is like a boy waling behind his pretty crush. Too afraid to get closer, too afraid to look her straight in the eye, and too afraid to break the ice. It’s time to pickup where I left it behind.

5. Few considerations before quitting your day job for your start-up

Another article that could save you from making harsh decision. As we are all now, start-up life is not easy. You might strike a gold, or more likely, failed and buried in the trenches 🙂 Remember this few things before jumping the bandwagon:

  1. What problem are you trying to solve?
  2. Once you able to answer question 1, don’t procrastinate. Just do it
  3. Your chance of success is slim. FYI, 90% of tech startups failed!
  4. Start small, and slowly make progress

6. Color, Branding and Marketing

Gregory Ciotti pulling all the red-threads between color, brand, and conversion. My take out:

  1. Yellow projects optimism, clarity, and warmth.
  2. Orange translates as friendly, cheerful and confidence
  3. Red means excitement, youthful and bold
  4. Purple translates as creative, imaginative and wise
  5. Blue radiates trust, dependable and strength
  6. Green projects peaceful, growth and health
  7. Gray means balance, neutral and calm
  8. Conversion increased if you have the right contrasts

7. How to design HTTP API

For future consideration in case I need to open up HTTP API.

Enjoy your weekend, 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:

I’ve came across a number of compression libraries in .NET world. At first, I used DotNetZip. DotNetZip supports only Zip format. But it was sufficient. Later, I found SharpZipLib. SharpZipLib supports more format such as Gzip, Tar and Bzip2.

SharpCompress supersedes both of them. As of now, it able to extract these formats:

  1. RAR
  2. 7Zip
  3. Zip
  4. Tar
  5. BZip2
  6. GZip

Currently it able to write archive in these formats:

  1. Zip
  2. Tar
  3. BZip2
  4. GZip

The following are not yet supported, and it’s in To-Do list:

  1. RAR 5
  2. Write 7Zip
  3. Zip64
  4. Multi-volume Zip

To install SharpCompress, you can manually fork the repository from GitHub. Or you can use NuGet:

     PM > Install-Package SharpCompress

Import the reference:

using SharpCompress.Archive;
using SharpCompress.Common;

Opening archive:

//f is FileInfo object     
var archive = ArchiveFactory.Open(f);

Extracting archive content:

//Sort the entries before extracting
//This will help especially when the archive contain folders
var sortedEntries = archive.Entries.OrderBy(x=>x.FilePath.Length);
foreach (var entry in sortedEntries)
{
   if (entry.IsDirectory) {
      //Create subdirectory
   }
   else {
      //extract file
      entry.WriteToFile(File_Path_Destination, Extracting_Option);
   }
}

Here’s the complete example that I made recently. This program will iterate a directory, and all of its sub-directories, then extract any .RAR or .ZIP found.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SharpCompress.Archive;
using SharpCompress.Common;

namespace ArchiveExtractor
{
    //Extension to allow us to filter files in a folder using multiple extensions
    static class MyExtension
    {
        public static IEnumerable<FileInfo> GetFilesByExtensions(this DirectoryInfo dir, params string[] extensions)
        {
            if (extensions == null)
                throw new ArgumentNullException("extensions");
            IEnumerable<FileInfo> files = dir.EnumerateFiles();
            return files.Where(f => extensions.Contains(f.Extension));
        }
    }
    class Program
    {
        //Dictionary to keep track which files already processed
        private static Dictionary<String, List<String>> _processDict;
        
        static void Main(string[] args)
        {
            _processDict = new Dictionary<string, List<string>>();
            //repeat until user decide to call quit
            while (true)
            {
                Console.Write("Directory to Process (x to Exit, Enter to process current directory): ");
                var cmd = Console.ReadLine();
                
                //Setup the initial directory
                DirectoryInfo curDir = null;
                if (String.IsNullOrEmpty(cmd))
                {
                    curDir = new DirectoryInfo(Directory.GetCurrentDirectory());
                }
                else if (cmd.ToLower() == "x")
                    return;
                else
                {
                    curDir = new DirectoryInfo(cmd);
                    if (!curDir.Exists)
                    {
                        Console.WriteLine("Invalid directory");
                        continue;
                    }
                }
                //Process the directory
                ProcessDirectory(curDir, "");
            }
        }

        private static void ProcessDirectory(DirectoryInfo dir, String prefix)
        {
            Console.WriteLine("{0}[{1}]", prefix, dir.FullName);
            _processDict.Add(dir.FullName, new List<string>());

            var subdirs = dir.GetDirectories();
            foreach (var subdir in subdirs)
            {
                //Recursively process the sub-directories
                ProcessDirectory(subdir,"   ");
            }
            //In case the .ZIP extracts to .RAR,
            //process the files twice
            ProcessFiles(dir,prefix);
            ProcessFiles(dir, prefix);
        }

        private static void ProcessFiles(DirectoryInfo dir, String prefix)
        {
            foreach (var f in dir.GetFilesByExtensions(".zip", ".rar"))
            {
                //have we processed this file before?
                if (!_processDict[dir.FullName].Contains(f.Name))
                {
                    Console.WriteLine("{0}  {1}",prefix, f.Name);
                    //nope, mark it as processed
                    _processDict[dir.FullName].Add(f.Name);

                    //open Archive
                    var archive = ArchiveFactory.Open(f);
                    //sort the entries
                    var sortedEntries = archive.Entries.OrderBy(x => x.FilePath.Length);
                    foreach (var entry in sortedEntries)
                    {
                        if (entry.IsDirectory && !Directory.Exists(dir.FullName + "\\" + entry.FilePath))
                        {
                            //create sub-directory 
                            dir.CreateSubdirectory(entry.FilePath);
                        }
                        else if  (!File.Exists(dir.FullName + "\\" + entry.FilePath))
                        {
                            //extract the file
                            entry.WriteToFile(dir.FullName + "\\" + entry.FilePath, ExtractOptions.Overwrite);
                        }
                    }
                }
            }
        }
    }
}

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:

A few days back, I stumbled into a superb screen capture program called ShareX. You can download it here: http://getsharex.com/. If you are curious with its source code, you can view/contribute at GitHub.

ShareX main window

ShareX has so many capture mode:
Share X capture mode

Select actions to do after capture the image:

sharex-after-capture action

Change output folder

Application Settings -> Paths:
sharex-after-capture-folder

Change Watermark

Task Settings -> Image -> Effects
sharex-image-effect
sharex-image-effect-overview

To me, what makes ShareX really stand-out is it’s upload capability. So many destinations available for uploading
sharex-upload

What I haven’t figure out is how to make ShareX upload to WordPress blog. That would save me a few minutes every time I blog. I shall investigate it in another blog post. 😀

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: