Clear .TXT Files with a Windows Batch Command

Posted on

Powershell Use this batch command or batch script in the command prompt to clear a text file blank in Windows using the command line. The function ERROR_FUNC does not exist and this throws a blank output towards the file in the parameter below. This should work for any kind of output format.

SET XML ="%CD%\Pathtofile"
SET @ERROR_FUNC. > "%XML%"

The code is best used for clearing log files without the need for VBScript or CScript. Here’s sample code below clearing an XML log file:

@ECHO OFF
SET XML=%CD%\Project\Contents\Main\components.vxml
@ECHO Clearing %XML%\
CRASH_TEST > "%XML%"

@ECHO Writing file %XML%
(
    @ECHO ^<?xml version=^"1.0^" encoding=^"utf-16^"?^>
    @ECHO ^<components xmlns:xsi=^"http://www.w3.org/2001/XMLSchema-instance^" xmlns:xsd=^"http://www.w3.org/2001/XMLSchema^"^>
    @ECHO ^</components^>
) >>"%XML%"

@ECHO Done
PAUSE

Workaround Fix For NSData Crash or Exception During Release in Objective-C

Posted on

I have been moonlighting as an iPhone Developer recently and I can truly say that you will probably spend more time fixing memory leaks in your code than programming for your App in XCode. I was working on a custom (RSS) feed reader and I was determined to keep the memory footprint to less than 30kb because it was a very simple App. I got stuck when I tried to release my feed data inside the NSData class in Cocoa. It crashed even though I tried different methods such as declaring NSURLConnection as an object. This object is probably the largest data stored in memory (can reach about 4MB) in my App because it contains the feed in XML (and not JSON), so it really needs to be released.

 

Here’s how I released the NSData class pointing to a response from NSURLConnection:


NSData *feedData;
feedData = [[NSData alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error]];
feedData = NULL;
[feedData release];

 

You just have to assign NULL to NSData before releasing it. It does work and it minimized my memory use when I checked it in the Leaks Performance Tool in XCode. Even though it works, I am not sure of is why NSData crashes with NSURLConnection explicitly declared as an owned object.

Improve RAID Performance on Intel Based Motherboards by Storage Driver Update

Posted on

Here’s a good tip: My 160 GB Seagate hard disk started to fail so I decided to try RAID 0 on my old Intel DG965WH motherboard. I purchased two 320 GB Western Digital Caviar Blue (WD3200AAJS) drives. I mounted the drives on the system and installed Intel Matrix Storage drivers in Windows 7. I ran a benchmark on HDTach and was satisfied. I checked for a newer version of this driver but found nothing. After 2 months I learned that the new version of this driver is called Intel Rapid Storage. I was not expecting any performance boost at all but when I ran the benchmark again it showed a 28% increase on sustained rates! Check out the videos below (best viewed in 480p):

This is the HDTach result while using Intel Matrix Storage Technology

This is the HDTach result while using Intel Rapid Storage Technology, see the huge difference on both sustained and burst rates of the drive

How to Spot a Good Motherboard

Posted on

I was recently browsing the web to check the price of my motherboard, when I found something surprising. I purchased my Intel DG965WHMKR motherboard for Php 6,500.00 back in May 2005, and as I was checking the prices I found out that the average price for this motherboard is currently and possibly for the year 2009 would be at Php 6,100.00 and that price is for outside the Philippines. How much more would that be if the board is to be purchased here it probably would cost at least Php 8,000.00. Anyway, here are some tips to picking a good board.

 

intel dG965wh motherboard

Here’s the first tip: Good motherboards will always be hard to find. No matter how much publicity you see for a motherboard it is always best to check the net for forums that have user opinions on the boards. Be careful though some companies use SEO tactics and do shameless self promotion with their products. A good tip would be to check the forum poster’s number of posts, the higher the posts the better.

 

Second Tip: If you are a computer enthusiast, a good motherboard for you would be one that is fully customizable. I can’t give out any suggestions on what motherboard brands to purchase but look for one that has good warranty coverage. This is so that you can relax easy while overclocking or concocting a new super computer that can rival Google’s servers.

 

Third Tip: If you are not a computer enthusiast and want a motherboard that is budget wise and will last for a long time, go for Intel motherboards, not motherboards with Intel chip sets but motherboards that are manufactured by Intel. I can assure you Intel boards, with regular maintenance (anti-virus, defragmenter) can last to more than 6 years based on personal experience. This is backed up by the fact that Intel has been producing server motherboards for IBM mainframes for a long, long, long time already.

 

Lastly: Picking the motherboard should be the task that will take you the most time when building a system. Keep in mind that the motherboard is the glue that will bind every component of the PC and so it is very important to choose carefully. I have always noticed since computers were sold as packages at stores here in Davao, store owners will not put the motherboard brand on the package list. They usually think that the system is good to sell as long as the CPU is fast, the hard drive is spacious, the monitor has a large and clear screen, the memory is high and the video card. I always end up asking “What’s the motherboard of this package?”

 

pc 005

* I have owned this computer since May 2005, even though I have been quite abusive to the computer such as turning off the CPU by holding the power button and even pulling the plug immediately, I still have the original installation of Windows XP running on the machine from the day I purchased the system. (“Original Install Date: 5/7/2005, 11:24:05 PM” – You can check for your installation date by executing the “systeminfo” program in the command line of Windows XP.)

 

PS: Lastly, the motherboard that I would not recommend you purchasing would be ASUS motherboards. Even though ASUS has good marketing, IMHO, I don’t think they produce high quality motherboards. I am saying this because I have a lot of friends who own ASUS motherboards and they always keep asking me for help on something such as unexpected restarts and BSOD which I will not be able to fix because I have traced the problem as part of the hardware. As a systems administrator, web developer and programmer I have used and fixed a lot of comptuers that run on ASUS motherboards one such example that would be easy enough is when I am updating the BIOS, I distinctly remember two units with ASUS motherboards failing the update and rebooting to the old BIOS. Another problem I have with ASUS motherboards is that when you try to check their website for drivers, most of the drivers are dated back when the motherboard was released. I would not even bother installing the auto updater that comes with the CD for the motherboard in the office because it would only be a waste of memory.

 

And if any ASUS motherboard fans are reading this here are two things to think about. ASUS produces about 15 to 30 new motherboards per year (this is due to the fact that they also produce motherboards for AMD) while on the other end, Intel produces about 5 to 9 new motherboards per year. Another thing, with that much marketing and publicity how much do you think they will have left for funding research and development?

MagicJack Installation, Firewall Setup and Port Settings

Posted on

UPDATED ON APRIL 7, 2011 Magic Jack, this amazing usb device will allow you to make unlimited calls to the US and Canda for $20.00 per year and better yet, you get a registered landline number that allows you to receive calls. I’ve found a lot of sites on how to set up routers, firewalls and access points to allow Magic Jack to pass through. None of them worked. It was agitating so I had to do some tests on my own. Read on for the complete port lists.

 

magic jack dongle

 

Magic Jack is very easy to install in the first place. Just plug it in and then plug your phone to it. The executable or installer should run automatically, if not open the flash drive, find it and then run it. The next part will deal with firewalls and port settings.

 

I used Active Ports to find out what ports MagicJack was using and it turns out that it uses a lot of UDP ports and two TCP ports. Their website specifically states that the device only uses UDP ports 5060-5070 (reference: LINK (removed) – GOOGLE’S WEB CACHE OF THE PAGE UPDATE April 7, 2011:The knowledge base has been down for a while but I managed to retrieve Google’s cache of the site.) which I found out was clearly not true. I found this out by performing calls to a random list of phone numbers (except 911 numbers ^_^). I dialed at least 40 phone numbers repeatedly. After this, I was able to conclude that MagicJack uses random UDP ports in the high range. UDP ports might seem a bit less important than TCP ports but as a Systems Administrator this will create a highly unsecured and exposed network. I was only able to achieve 100% connectivity with the 40 phone numbers after opening a range of UDP ports.

 

magicjack ethernet dongle

 

I also stumbled upon a lot of sites and forum posts that tell magic jack users to setup port forwarding, this is NOT true!

 

Below is the exact list of the TCP and UDP Ports that I had to open in my firewall and router (NOT port forward) to achieve 100% connectivity:

 

TCP Ports List: 80 (HTTP), 443 (HTTPS)

UDP Ports List: 5060, 5070, 10000-65535

 

It is really strange why the device was designed like this. My guess is that the device is intended solely for home use and not commercial use.