Category: IT Related


Connectify Wi-Fi Hotspot maker

Today I want to share how great Connectify is if you want to make a wi-fi hotspot from your wired internet connected Windows 7 PC.

Recently I just got myself a portable multimedia gadget that need wi-fi for its internet access. So I need someway to share my internet connection from my laptop to that device.

After quick search I found connectify and tried it. At first I ran into some issues, not because the connectify itself but because I never really use my wireless card on my laptop and didn’t know that it had some issues from day one. After re-installing the driver for it from the manufacturer’s support site, the wireless card got detected and it ready to go.

So basically connectify make it really simple for you to share the internet connection.  You just need to provide SSH ID (the name of the wi-fi network you want to create), the password to join, and the internet connection that you want to share from your PC and that’s it, connectify will do the rest for you. (*note: if you are a tech savvy, you could create the batch for this connection without connectify, but if you are just a normal user than go for connectify to make your life easier)

Today when I boot up my laptop I got notification that newer connectify is up. I’m currently on version 2.1 and 2.2 is the newer one. Without hesitation I upgrade the version to 2.2

But ironically it didn’t work. So I reverted back to version 2.1 and everything went OK again. I guess the saying don’t fix it if it ain’t break holds true here. Well for the time being I will use version 2.1 for now.

Thanks to recently held facebook hacker cup, I learnt some new stuff which is Rencontres Numbers.

Here are the few first numbers : 1 0 1 2 9 44 265

The number represent the possibility of different fixed point on sequences’ permutation.
Let’s assume the above numbers as R and N is the fixed point so
for N = 0 -> R = 1
for N = 1 -> R = 0
for N = 2 -> R = 1
for N = 3 -> R = 2
for N = 4-> R = 9

To explain further for different fixed point 0 -> it means all the fixed point are already alligned so there is only 1 possibility.
For N = 1 or different fixed possibility equal to 1, the possibility is 0, why zero you ask ? here is a little example :

ABC -> original position

1 different position means 2 correct position, assume A and B are already in right position, the only left position is C, since A and B already correct, C will ALWAYS be correct, therefore the possibility for only 1 different position is ZERO

for N = 2

AB -> original position
BA -> 1 different fixed position

for N = 3

ABC -> original position
ACB -> A is in correct position therefore it doesn’t satisfied 3 different fixed position
BAC -> C is in correct position therefore it doesn’t satisfied 3 different fixed position
BCA -> Satisfied N =3
CAB -> Satisfied N =3
CBA -> B is in correct position therefore it doesn’t satisfied 3 different fixed position

So after examining the pattern you can see that


Ri = (i-1) * R(i-1) + R(i-2) for R1 = 1 and R2 = 0

Some chinese (I pressume he’s chinese judging from the username) on facebook wall put comment that he found another more difficult formula but work for this Rencontres Number. it went like this

Ri = i! * ( 1/1! - 1/2! + 1/3! .......... 1/i!)

note that the ‘+’ operator has to be done prior to ‘-’ operator.

Okay since we’ve covered the rencontres numbers, let’s go to what it has to do with combination.
You could google the facebook hacker cup wine tasting if you want to see the original problem definition, but let’s make it simple here. For example there are 13 glasses and you need to guess which glass belong to whom and if you at least guess 10 glass correctly, you won. So how many way you could win the game.

Answer :

multiply each combination of the glass with number of different fixed possibility that we covered earlier

=13c13 * (0 different fixed possibility) +13c12  * (1 different fixed possibility)+ 13c11 (2 different fixed possibility)+ 13c10 (3 different fixed possibility)

=13c13 * 1 + 13c12 * 0 + 13c11 * 1 + 13c10 * 2

=1 * 1 + 13 * 0 + 78 * 1 + 286 * 2

=1 + 0 + 78 + 572

=651

note that ncr means n! / r! – (n-r) !   —>  the combination of r number of n object.

Peeking some accepted source code from korean (again judging from his username) on facebook, He solved this problem by using memoization for combination generated by pascal triangle and also memoization of rencontres number itself (using above formula for dynamic programming approach).

Facebook Hacker Cup 2011

Okay now I want to share my experience in joining facebook hacker cup 2011. I only managed to get to semifinal (Round 2) though. But it is a very rewarding learning experience for me.

Background

At early of this year, I saw one of my friend’s profile on facebook sharing the page to facebook hacker cup. Well seriously at that time I thought it is a security breach competition or something similar so I don’t really bother to take a look.

Few days just before the qualification round started, I took a peek at the facebook hacker cup page just for curiosity. To my surprise here, this is not a hacking (in term of security lingo) competition, but this is a programming competition. Now me myself haven’t join this kind of competition since I graduated from college. I did participate in a lot of programming contest during 2002-2005 timeframe where I went to college though. But anyway I see this as a good chance to reboot my programming skill again and decided to enter the competition. Luckily for me it wasn’t too late for me.

Reading the rules and terms of the contest, someone posted that the rules are almost a copy-paste from google code jam. Since I never joined GCJ (but I do know their presence), I googled the gcj to read their terms and yes…. it is like 90% of the rules are copy-paste from GCJ. But here I learned something new for me. All this time I misunderstood between the ACM-ICPC and GCJ, I thought they targeted the same segment. While ACM-ICPC can only be joined if you are currently enrolled in University, but GCJ is free for all. I always thought GCJ is also for University’s student only, which is why I never bother in the first place to participate in GCJ after I graduated.

Learned up to this point : GCJ is free for all

Qualification Round

On qualification round, I chose the 3rd (string manipulation) problem and after I solved it I went to hit the submit. And ow boy here is me, a windows boy… when I downloaded and opened the input file, on notepad I am surprised that the format is not….. formated. So basically I am kinda panicked a little bit and try to format it again myself. but Alas when I tried to run it I got an error, so there is a bug on my code, after tracking and solving the bug, I ran out of time (the timer is only 6 minutes). But actually later on, they lifted the timer restriction on qualification round and my solution for this 3rd problem got accepted.

At that time I thought I was already failed at 3rd problem, which leave 1st and 2nd problem. The first one is math and the second one is map traversing problem. I decided to do the math one and hoping this time I could pass the time limit. and.. Yes I passed it.

Learned up this point : Unix and Windows have different new line character set and notepad on windows couldn’t detect it and shows it as whitespace . But the program will know that it is a new line so you don’t need to reformat. Wordpad on Windows could detect this new line.

Round 1 A

Goes to Round 1A. well actually there is only 1 problem that I have a chance to solve and still I couldn’t derive a solution in time. But since there were a lot of bugs from facebook itself this round got cancelled.

instead they gave Round 1 A Reprise. Well, still it was a tough one to compete, I ended up solving nothing but learned a great experience.

Learned up to this point : Probability theory, Pascal Triangle for Combination, Rencontres Number theory.

Round 1 B

Round 1 B was held on weekday, and in Japan it’s early morning at 6 PM. I got a job, although I could just take a paid day off but I didn’t. After reading the problem after, if only I joined this round I could just might pass because one of the problem is a widely known Josephus problem.

Round 1 C

Decided to do the prime related problems and really make sure my code could pass the time limit, and luckily it did pass. The timer is 6 minutes and my code run for about 4 minutes.

And then move on to the map traversing related problem, I actually solved it but it was too late. if only I had 3  more minutes, I could get this one accepted too. After the contest over, someone posted the right input and output for the problem and I tried in on my program and it passed. So I did solve it but couldn’t solve it fast enough because some stupid bugs.

But I already got 1 problem solved so I move to the next round.

Learned up to this point : Always watch for your global and local var (this is the bug that I didn’t find fast enough), memoization (array storage) could be used for approximately the limit size of int. Dynamic programming for map traversing using recursion is easier than I thought

Round 2

A tough one for me. I couldn’t solve even 1 problem. actually only 150 people that managed to atleast solved 1 problem with 5 people solved all of them perfectly.

Considering more than 120.000 people “like” the facebook hacker cup page so let’s assume they all registered, only around 5000 people passed the qualfication round, after that only around 1600 people passed the 1st round and only 150 people passed the 2nd round.

Congratulations for the first top 25 that will compete for grandprize.

Misc

although this time I used C#, but seeing the available solution that are dominated by C++ I also learned a few things I didn’t know until now.

Learned things regardings to C++: how to use preprocessor directive like to develop custom looping function and other cool stuff (for example #if 0)

New Laptop Dell 1558

Okay so I finally got my new  laptop. Quite early if I might say because the invoice said it will be delivered on 5th August but instead it was delivered on 28th September.

Here is the main Spec of my new Dell Studio 1558

  • CPU Intel I7-740
  • Memory 4 GB RAM
  • Graphic Card ATI 5470 1 GB
  • LCD 15.6 inch Full HD
  • HDD Sata 500GB 5400 RPM
  • OS Windows 7 64 Bit Home Premium

Price paid : almost 90.000 yen

Optional Package :

  • Advanced Warranty 3 years

Total price paid : 101.000 yen

I got special company discount and special online store discount when I bought this so it was cheaper than buying it at computer retail stores.

Since this is my first windows 7 experience, and also my first 64 bit OS experience, I had a lot of things to catch up. For example, I found my favorite uinstaller utility didn’t work well in windows 7 64 bit and my audio editor software also has some bugs in 64 bit. But most of the stuff ran good.

The 500 GB HDD came with only 1 partition so I made it into 2 partitions (OS and Data) with almost the same size each. I used windows 7 internal tools to the partition itself and it was pretty easy to do (Kudos to microsoft for this one).

I also made several recovery disks (including USB key), both by Dell utilities and also windows 7 utilities. Since I don’t like OEM bloatware, after I use Dell Utilities that I need (in this case, the local backup utilities) I disabled almost all Dell Service on my laptop.

The Windows Experience Index scored 5.0 in the first test (with all factory default setting and without optimization applied). With Aero in the lowest sub score. Yes indeed I found Aero effects kinda make my new laptop a little bit sluggish, but after I do some optimization here and there, especially services.msc and msconfig file, I saw some improvement.

I also tested the machine with Call of Duty Modern Warfare 2, which is one of the reason I want to buy this mainstream gaming laptop. The auto graphic detect from the game set all the texture level at highest point which is very good since I don’t really expect my machine could handle the extra (very high) setting. But the Anti Aliasing is only at 2X and full frame synchronization is off (which is very reasonable and infact quite good considering it’s only a mainstream laptop). Considering the machine couldn’t handle Aero in full performance, I’m quite surprised and impressed that it ran Cod MW2 quite fine.

The only problem I have is there is some fan screeching sound randomly at the left part of the touch pad which I believe is where the HDD located. Kinda worried about it at first but since it’s not click of death (I have experience of click of death so I knew what it sound and I also have experience of recovering click of death HDD) so it was probably by bad design. I searched the internet and several people complain almost the same problems. It looks like the fan and heat sink design at the left part of the touchpad is not really well considered. But this is also my first SATA HDD personal laptop. So it might be normal for it to make sound like that, up until know I only familiar with IDE based HDD sound.

*updated

It turned out that the problem is with my electric plug. Probably because I’m using the extension plugging device and the voltages didn’t went through well. After changing the configuration of my external power outlet. The strange sound disappeared. So basically the machine is beautiful and powerful without problems.

Ok so there was my first impression of having my new laptop for this 3 days. I hope you enjoy it.

Automation part II

This time my boss wanted to make an automation program to copy files. Since some of the legacy code still written in VBA based on ms access. Everytime they want to distribute the new version they need to manually copy it to the target machine.

So he designed a scratch plan to do the automation. He give me a paper which basically tell me to

  1. ping the target computer
  2. if the ping got a reply copy the file
  3. if the ping failed. retry

After a few brainstorming, trial and error and also not to forget the internet search. We made this approach :

  1. create a database consists of PC information. eg: IP, update status, etc
  2. read the database from 1st record till the last record
  3. ping the target
  4. if the target reply, create the temporary drive letter (after make sure it’s available) and run a script file to copy the files to target’s pc. mark the status update as done and after that go to next record.
  5. if target doesn’t reply just abandon it and go to next record.
  6. check for the status update for all the records, if there is at least 1 record still not updated, repeat the step 2.

using .net framework 2.0 to do this made the job easier. I used a single thread to do the looping process and ping through the synchronous call (asynchronous might be faster but if more than 1 target’s pc on the record have the same drive letter than it would failed). beside , I need to make sure that the ping process only executed one at the time. that’s why I need the synchronous. The reason to use thread is to avoid the freezing UI.

Automation ? Just AutoIt

So last month my boss want to have some automation program for early installation setup for new pc.   Luckily he give me freedom to choose my weapon to acquire the target. Since it would be too cumbersome to do this in .net (new pc shipped in windows xp and by default windows xp’s framework still 1.1 and I already used both 2.0 and 3.5 right now) so developing using .net is not an option for me.

Next I would consider the script like vbs or even js but it didn’t do any good. And while searching the internet I found the perfect gem for this (I was looking for silent install automation I think).

And that gem is here

AUTOIT

it took a while to learn all the new syntax but it’s quite powerful. indeed for a freeware it’s awesomely powerful.

I do found some problem though because I’m in japan so I need to deal with japanese characters. Autoit seemed couldn’t handle the japanese characters well so my temporary workaround now is to save the japanese character inside some txt file and use autoit to open the file , copy, close the file, paste it on some text that I want to.

Automation is still new world for me. And by learning Autoit I feel I’ve added more arsenal to my weaponry to deal with the target :-P

Lenovo X200 Impression

On my current line of work, sometimes I get the chance to taste the cutting edge newly released laptop. So far I’ve tried these laptops :

  • Dell Inspiron Mini (a small netbook from Dell)
  • Dell Latitude (currently the highest end of business series from Dell, up to 19 hours long battery life)
  • Lenovo Thinkpad X200 (ultra portable notebook that keep the balance between price and features)
  • Sony Vaio G series (stylish ultra portable notebook from sony)

in this post I will try to give my impression of Lenovo X200. The reason is because they let me to set the notebook from the fresh start, so I spent more time to operate this one rather than the other 3.

Pro

  • No sound at all. Just like Mac Air from apple. you wouldn’t notice the sound.
  • I got the SSD version so I experienced the fast response from SSD. windows shuts down in less than 3 seconds. (the experience might be differ if it’s not the SSD version)
  • very light
  • very thin
  • Keyboard is comfortable
  • Filled in with the latest technology in current generations (it just came out)

Con

  • no optical drive, just like MacAir. which is a big no for some people
  • the screen is not that good. I’m kinda feel that my 4 years old Toshiba Satellite’s screen is better
  • full of bloatware by lenovo (no big deal since you can opt to remove it, but still it’s the default settings)
  • only trackpoint with no touchpad. the trackpoint itself is awesome but it gets dirty only after couple hours of touching. And I knew that most of the people still prefer touchpad over trackpoint
  • the F1-F10 button on the keyboard look and feel cheap. but the rests are okay though

some interesting fact that I got when downgrading the Vista to Xp with the Lenovo downgrade CD

  • the downgrade process from Vista to Xp took approximately 2 hours
  • on Vista, the empty space is only 29 Gb, after downgrade to Xp I got empty space around 49 Gb. Mind you this Lenovo X200 is SSD 64 Gb version
  • I only tried Vista for about an hour. after downgrade to xp and do the setting etc. I found that the system was more stable in Vista.

Fighting malwares

Last week I did some mistake on my own that let some malwares get in to my notebook. This notebook almost became a brick, but luckily it survived. This is the second time in my life that a virus could actually get in to my system. The first time was like 4-5 years ago. And that is the virus that I get from university lab LoL. This time I got the virus because I accidentally hit the button ignore when my antivirus sent a notification of some malwares trying to get into my system.

Okay. so as soon as I noticed the malwares has infected my system. I put a memo on all the suspicious program that was recorded on both my avast (antivirus) and teatimer (spybot). After hours of cleaning up the file both in secret folder and registry and after several restart. I thought I have done. so I restart once again to make sure everythings fine.

But ALAS, this time I can’t login. Something struck in my head, oow I just realized that I delete a vital registry entry and now my system is dead. I deleted an entry in registry related to LSA which is related to autologon that I used on my system.

After shocking in awe. I went to my friend’s room to borrow pc so I could browse the internet on how to recover from this problem. I found out that with recovery console from windows xp’s cd, one could rebirth a registry structure. so using the recovery console from xp’s cd, I moved the file from repair folder the current system32′s folder. after restart, my pc is reborn. well…. not actually reborn, the whole file, data and program are still there, but the profile is gone. And the program that was installed under my old profile can’t run unless I reinstall them again in my current profile.

For a while it seems fine until I realized. My usb can’t work. after googling a little bit I found out that I’m actually in prefactory setting mode, so again I enter the regedit to edit the registry’s involved.

Ok so right now my pc survived from a near death.

refferences that I use to fix my pc :

http://forums.windrivers.com/printthread.php?t=65537

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q307545&ID=KB;EN-US;Q307545

Background

The last time I put an entry in IT related categories is about asynchronous callback. This time I also trying to cover this things a little bit further. You can read my previous entry about this here

In my last post, the method only support 1 action, means if you have several button to activate different type of callback inside 1 page, it can’t be done with my previous way. This post will show you how to send different kind of parameter to enrich the callback

Code

.cs file

string cbref = Page.ClientScript.GetCallbackEventReference(this,”arg”,”result”,”",true);
string callbackscript = “function callserver(arg){“+cbref+”;}”;
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),”callback”,callbackscript,true);

//to assign it to a button
Button1.Attributes["onClick"] += “javascript:callserver(‘set your argument here’)”;
Button1.Attributes["onClick"] += “;return false;”;

//Callback function
public void RaiseCallbackEvent (String eventArgument)
{
//arg is a variable which you need to define yourself
arg = eventArgument;
}

public String GetCallbackResult ()
{
return arg;
}

.aspx file (javascript part)

function result (arg)
{
if (arg == “1″) // you decide your logic here based on passed arguments

}

Basically all that can be done in client side can be done in the result function, since you can control the passed argument based on the clicked button or whatever control you decided. This method proves more robust and versatile approach better than my previous method. This way you are free to control everything that’s going on on callback session based on your defined arguments.

Reference :

http://www.themastech.net/Tutorials/ClientCallbacks/Default.aspx?fn=Part%202

Background

Yes I know the .net 2008 is out with built in ajax designed for this client callback purpose. The heck, even many people used ajax in .net 2005 as a separate plug in. But in my development environment, I only have this standard .net 2005 and have no rights whatsoever to make changes like installing ajax. So in order to achieve this feature, I need to use the client callback provided in standard .net 2005.

Study case

This is my real life case. The goal is when you click the listbox and select some items, it fired an event which then decide whether a checkbox should be checked or not. This could be easily done by using the postback. That’s the way I did it before. And now I want to change it into client callback in order to avoid the client’s loading screen on postback

Code

.cs file

// define interface
public partial class ClassName : System.Web.UI.Page, ICallbackEventHandler

// code in page load

string script = Page.ClientScript.GetCallbackEventReference (this,”document.all['ListBox1'].options[document.all['ListBox1'].selectedindex].value”,
“JSfunction”,”null”);

ListBox1.Atrributes["onClick"] = script;

//Callback function
public void RaiseCallbackEvent (String eventArgument)
{
//arg is a variable which you need to define yourself
arg = eventArgument;
}

public String GetCallbackResult ()
{
return arg;
}

.aspx file (javascript part)

function JSfunction (arg, context)
{
if (arg == “1″)
document.forms[0].elements['cb'].checked = true;
}

Not many explanations here since the purpose of this entry is for my future reference

Follow

Get every new post delivered to your Inbox.