I was doing a task and I noticed that I was repeatedly deleting and renaming a folder in windows. I'm running a process that makes a backup of a folder and then do some update on an existing one. Whenever I wanted to restore the original (backed-up) folder, I would delete the existing one and rename the original.

I got a little tired and created a small batch file that would do this for me automatically. Here goes...

 

IF EXIST "SomeFolder-Backup" GOTO DELETEANDRENAME
EXIT
:DELETEANDRENAME
rmdir /S /Q "SomeFolder"
ren "SomeFolder-Backup" "SomeFolder"

"Save this as a .bat file"

What the above code does is it checks if the backup folder exists. If it doesn't then it would just exit the batch script. If it the backup folder exists then it removes the modified folder (SomeFolder) and then restores the backup folder. Hmmm...  I wish I could explain better. Anyway, if you're on the same situation then I'm sure you'll understand. If it does help, please drop a comment below!

 

Disclaimer: I will not be responsible for any damage done to your file system by running this script. Before using this simple script, make sure you understand what it does and what you want to do. Use at your own risk!

Posted by lamia | with no comments
Filed under:

Since I don't have any code to post, I decided to share more of my experiences regarding software development in general. This is base on real world experience. Sometimes, I tend to go on and proceed with solving the problem without doing sufficient analysis. I think my experience doing maintenance work has helped me mature and be more analytic towards solving problems.

 

1. Find out what's the problem - Find out what's the problem first is the fundamental question asked in Math in grade 1. It's like What is asked?

 

2. Find out where the problem lies - Secondly, when you've identified what the problem is try to find out where the problem is. There is a big chance that there is no problem at all and the problem might be the user. I'm just stating that as a possibility but of course there's always and higher chances that there is a problem with the software involved.

 

3. Find out What's causing the problem - In this step, you identify if the problem is being caused by a dead server, typo, logic error, etc.If it's a NullPointerException, where is the offending code and why is it causing a that? It's very tempting to conclude that such problem is caused  by a call to a null reference but it's more often more than that.

 

4. Research how to fix the problem - Once you know what's causing the problem, it's time to propose solutions. There can be many ways to approach a problem so it's good to identify your options. Then from that list of options, identify the best solution. It's always a good idea to ask other people for a second opinion.

 

5. Code the Solution - Finally,  you have decided on a solution it's time to code. However, before writing your first code it's always a good idea to write unit tests against them. Now, I feel a little guilty having discussed this because I tend to go lazy sometimes and just code straight away. It really totally depends on how much time you have but for maintenance work, I would suggest to write unit tests first. You will then know that your solution works such as when you put your changes the unit tests passes and when you take out your changes the unit test fails.

Posted by lamia | with no comments

Do you iterate through long for loops or while loops? Tired of pressing F8 or F5 just until you meet a certain condition while debugging in Visual Studio? I didn't  know that this was possible (haven't tried in Eclipse) until a colleague told me How To Set a Breakpoint Condition in Visual Studio.

How To Set a Breakpoint Condition in Visual Studio

Let's assume that you have the following set of code... The code below does nothing but to print names from an array of string.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System;
using System.Collections.Generic;
using System.Text;

namespace BreakpointIfTest
{
    class Program
    {
        private static string[] names = { "Tim", "Gerald", "Keith", "Cruizer", "Rolvin", "Jared", "Chris", "Jops", "Devpinoy" };

        static void Main(string[] args)
        {
            foreach (string s in names)
            {
                Console.WriteLine(s);
            }
        }
    }
}

 

Suppose we set a break point at the line... Console.WriteLine(s);

 

Visual Studio Debugging - Set a Breakpoint

 

and we want the breakpoint only to HIT when the value of  the variable "s" is "Keith". What you do is right click on the breakpoint (the red circle) and choose "condition".

 

Visual Studio Debugging - Make a Breakpoint Condition

 

A window will pop up prompting for a breakpoint condition, enter s == "Keith"

 

Visual Studio Debugging - Set a Breakpoint Condition

 

Now run and debug your application and you will see that the breakpoint will only hit if the value of "s" is Keith". ;)

 

Visual Studio Debugging - Run and Debug

 

Tell me if it helps you. I hope this saves you some time debugging!

Posted by lamia | 3 comment(s)
Filed under: ,

I was working on my video game blog together with a graphic artist and I was trying to integrate the Favicon I asked of him. I had the basic code for the favicon which is


<link href='http://myimagehost/myfavicon.png' rel='shortcut icon'/>
<link href='http://myimagehost/myfavicon.png'' rel='icon'/>

It appeared for a little while and then the old Blogger favicon re-appeared. I tried experimenting by putting my favicon code just before the closing header (i.e. </head>)

 

It worked!

 

I didn't know why until I found this in the HTML source code...

 

<link href='http://www.blogger.com/favicon.ico' rel='icon' type='image/vnd.microsoft.icon'/>


Now I have a nice looking favicon for Game Rumble. :)

Posted by lamia | with no comments
Filed under: ,

Here I list 5 Common IT Outsourcing Mistakes Companies Make and some ideas on how to prevent them. Theoretically, this can be applied on either end whether you're onshore or offshore.  These mistakes commonly result into software projects not being completed, projects being delayed or employees resigning due to misunderstanding. The following list doesn’t necessarily follow any order of importance.

1. Misaligned Expectations

Expectations should be set from the start. The scope of work must be clearly defined such that would the developers on the offshore team be doing design work, is it only coding, would it involve testing or all of them? It is also important to define the corporate hierarchy equivalent of the offshore team members. For example, if the developer is a mid-level on the offshore end is he also expected to be a mid-level developer on the onshore end?

Another thing is to properly layout the employee’s career path. What will he be after he completes a certain project? What will he be after spending 5 years of loyal service?


2. Treating each team (offshore/onshore) as a Separate Team

Both teams should be treated as an extension of each team. If one team feels like they're being looked down upon, or another end feels superior over the other then you have a serious flaw in your system. Why? Because communication happens when both ends feel safe (I forgot where I picked that line from)

3. Irregular Status Meetings

It is important to have a regular status meeting so that outstanding issues can be acknowledged and dealt with at the earliest possible time. Some nationalities have this communication barrier where they tend to keep to themselves the problems they have instead of asking someone else who might know something about the problem.


4. Closed Communication Lines

Make use of the technology that we have today. Skype, e-mail, phones, everything that you could use to bring the message to the other end is important. This assures visibility on both ends and it is important to know what is happening on either end. You might also want to invest on knowledge base tools like Confluence which is a wiki-sort of application and JIRA which is a bug tracking tool. This encourages collaboration across the entire team and could somehow minimize the barrier across time zone differences. Encourage offshore and onshore employees to use not only all the brains that they have, but also all that they can borrow.

5. Very Limited Access to Infrastructure

Last but not the least is limited access to infrastructure. Yes, you want to make your servers as secure as possible. But if it keeps people away, far enough that they could not do their jobs then your servers are not performing their jobs. You might want to consider stuff like temporary access to log files that could at least help a developer determine what went wrong in production if it’s a production issue. If you don’t want the offshore team to have access to production data, you might want to create a mirror that hosts dummy data that closely mimics the one in production… Things like that...

 

If these things are present in your company then they must be addressed as soon as possible. These are keys to make the outsourcing model work for both parties.

Posted by lamia | 1 comment(s)

Once in a while we just discover simple things that fascinates us. Just accidentally discovered this while in the Facebook chat window press SHIFT + ENTER and you'll be able to enter a "new line". Useful if you're trying to make use of your creative side. :)

Posted by lamia | 1 comment(s)
Filed under:

Not sure where the saying "good coders code, great coders reuse" came from but I sure been doing a lot of copy-pasting throughout my 4+ year career. Web apps, mobile, games, blogger code,  etc. All stuff that I've been doing, I've always been doing a lot of copy-pasting code. Yes, copy-pasting is code reuse. In fact, I rarely really encounter code reuse in object oriented programming... Unless I'm using a framework, I rarely even really extended a class and "reused" anything from that class. Well... I've been able to apply the reuse of default behavior more in games than in web projects.

I notice that even when this is put to practice, there was a struggle trying to maintain different version of jar files or assemblies throughout a distributed development team. Even static methods used for utility classes are duplicated across the entire codebase. The only real thing being reused is the functionality. If I wrote a class method that writes something to a file, chances are I've also only looked that up on the internet and "re-used" somebody else's code.

Posted by lamia | 2 comment(s)

For students who would usually be taught C as their first programming language, a shift to Java could quickly make a confusion as they are crossing the boundaries between procedural and Object Oriented Programming. Both operators can be used in Java, in fact the second one is not called an operator but a method.

 

==

This is called the "Equal to" operator and is used to compare "primitive" types or check if you have equal object references(or do they refer to the same object in the heap). There are 8 primitive types in Java and you can usually identify them

byte, short, int, long, float, double, boolean, char

 

When used with Strings, one might assume that  you are making a comparison with the String values, but no. We mentioned above that "Equal to" operator checks for object references when used with objects.

 

So let's assume the following code:

 

1
2
3
4
5
6
        String s1 = "STRING ME";
        String s2 = "STRING ME";

        System.out.println("s1: " + s1);
        System.out.println("s2: " + s2);
        System.out.println("s1 == s2 is " + (s1 == s2));

This would output:

s1: STRING ME
s2: STRING ME
s1 == s2 is true

 

Why? The JVM does some optimization step with Strings(i.e the Strings get "pooled"). Basically, the JVM makes you point to the same Object reference that is pooled in the heap.

 

Let's make some modification with the Strings

 

1
2
3
4
5
6
        s1 += "2";
        s2 += "2";

        System.out.println("s1: " + s1);
        System.out.println("s2: " + s2);
        System.out.println("s1 == s2 is " + (s1 == s2));

 

The output is now:

s1: STRING ME2
s2: STRING ME2
s1 == s2 is false

 

Why? Because Strings are "immutable", new Object references are actually created. The String was not actually modified, it is a new String object. They are now different object references.

 

Now, what most of us usually want is "OBJECT EQUALITY", and that's what the next thing is for

 

equals()

All objects can use and override the equals() method. Any instance of a class you use or created automatically inherits this method. Without overriding, you use the default implementation of the Object class which is not very helpful. This works differently when used with the java.lang.String class as it does some character comparisons. You cannot override this method in String because String is a final class and cannot be extended.

 

Using a similar set of code, let's try to make modifications with the Equal To operator, for the String references to use the equals() method.

1
2
3
4
5
6
7
8
9
10
11
12
13
        String s1 = "STRING ME";
        String s2 = "STRING ME";

        System.out.println("s1: " + s1);
        System.out.println("s2: " + s2);
        System.out.println("s1 == s2 is " + (s1.equals(s2) ) );

        s1 += "2";
        s2 += "2";

        System.out.println("s1: " + s1);
        System.out.println("s2: " + s2);
        System.out.println("s1 == s2 is " + (s1.equals(s2) ) );

 

This will now both evaluate to true.

 

Again, when using Strings in Java, think of you're after equal object reference or object equality.

 

 

References:

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/opsummary.html

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html

Posted by lamia | 1 comment(s)

Alright. So aside for some video tutorials I agreed to make with Keith, I decided to pickup some beginner, intermidate, or advanced questions I could find in any tech/programming forums and post the solution back here. Well, I'm getting a bit rusty after all...

I'll be focusing mainly, still with Java. But I'm currently gaining interest with android since it's basically available more available to me, looks like Java (or is Java).

Posted by lamia | with no comments
Filed under: , ,

Alright, first off... The whole point of this post is to share how I resolved the "Masking" issue.

I have reserved a domain, everypesocounts.com and had a blogger account. Problem was, I could forward from my .com to my blogger blog by forwarding and masking the URL, but the URL kept being the same even when you click on a hyperlink.  I found it more effective to use the GoDaddy support help since I'm hosted with them. It's probably faster than anything else you could find in google.

 

Now, following the steps mentioned here, just read carefully and you'll be successful.

 

Keys to Success

- Park Your Doman

- Forward (permanently), and use the complete URL(ie. www.everypesocounts.blogspot.com)

- Add CNET entry OR if already existing, edit www entry (www.everypesocounts.com)

- configure blogger to use your custom domain, remember that www is a subdomain that must be specified. You can't just use everypesocounts.com

Posted by lamia | with no comments

Just discovered this trick today...

1. Say, you launched the command line by typing cmd in run

2. Try moving to the C:\Program Files directory, that would point you now to...

C:\Program Files>

3. Now type,

exporer .

C:\Program Files>Explorer .

This will launch Windows Explorer in the current directory you are in, in the command line.

Might get useful to some people. :)

Posted by lamia | with no comments
Filed under:

Or show Content when there is only one post. I've been fiddling with Blogger for a while now and studying how to code using the bloger tags. This took me a few weeks to figure out but finally, I guess I'm getting more comfortable with it.

<b:if cond='data:numPosts == 1'>

<!-- PUT CONTENT HERE -->

</b:if>

 

How is this used? This is used for example, you want to show a facebook "share this" content and only want to show that particular link or button when inside a blog post

 

To do that, you do it like this... Put this inside the

      <!--Share of Facebook-->
      <b:if cond='data:numPosts == 1'>

      <div>
&lt;a name=&quot;fb_share&quot; type=&quot;button_count&quot; expr:href=&quot;http://www.facebook.com/sharer.php?u=data:post.url&amp;t=testtitle&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
      </div>

      </b:if>
      <!--Share of Facebook-->

 

The <script> tags were actually converted so they would fit into blogger.

 

See it in action here (the facebook share button):  http://game-rumble.blogspot.com/2010/04/transformers-online-game.html

Posted by lamia | with no comments

This is for those who are dying to put google ads on their blog here (like myself). This is not a hack and I think Keith would agree that this is legitimate. Hopefully, this would allow you to focus on your blogging. :)

 

Let's start...

 

(Drums Roll)

 

1. Go to this URL, click "Add to your webpage" and fill up the

Client id - Also known as pubid, it looks like pub-123456789014327

Slot # - The ad slot, each ad you create has a unique ad slot , looks like #1234567890

 

2. Choose the ad format, specify the height and width and click Get the Code

3. Copy the code that is shown on the textbox below the screen

 

4. Now go to you blog and click on the control panel, navigate through your themes and the part where you can add a component. Choose "Google Component", click add then copy and paste the code  you got from google gadgets there. Save your template and... Voila!

 

 

**Note: I'm not sure about the security of this gadget. All I know is that it works.


I was tempted to make my own version but figured it would take a while to study how the code is made. You can view source in the gadget page to see how it's made. I hope I get enthusiastic enough to create one just for the community.

 

By the way, thanks to Joner Cyrre Worm, the author of the component.

 

HTH!

Posted by lamia | with no comments

I wanted to disconnect a folder I've checked out from SVN using Tortoise SVN. I could vaguely remember, but I knew I was able to do this before through the context menu in windows explorer. What I wasn't sure about is whether I did it in SVN or in Sourcesafe.

So I did a quick google. One of the most obvious choice is to manually delete the .svn folders which I already knew, but that would be cumbersome if you have a lot of folders and subfolders. Another way is to use export (see screenshot below) which seemed readily available for me.

 

Note: Technically, this is NOT a disconnect but a COPY without all the .SVN files

 

Steps:

1. Right click on the folder you want to disconnect

2. Choose TortoiseSVN -> Export

3. Select the folder you want to export to

 

 

That did the job for me and I guess I will be using it until I find a more comfortable way of using it. Safe and Simple.

 

Resource: http://vidmar.net/weblog/archive/2007/12/11/subversion-and-tortoisesvn-tips-and-tricks.aspx

Posted by lamia | with no comments
Filed under: ,

I'm looking into going back to game development this year and I'm really keen on learning java 3D and I've scouted for a few Java 3d API that I could possibly use.

I can't make any recommendations since I haven't used any of them. My brother plans on  using JMonkey, and I hope he gets better with it so I could also save time by just asking questions to him. I think the future of 3D in Java is still bleak, but that is actually more of an opportunity to create something great out of something not so popular in the gaming industry.

Posted by lamia | with no comments
Filed under: , ,
More Posts Next page »