Tech Tip and Technology23 Oct 2008 12:40 pm

I just recently started using OpenSolaris on a cloud cluster with Joyent , and quickly realized that I didn’t have the first clue how to install things! But, just like yum, apt-get, aptitude, port, etc,… there’s a package manager for OpenSolaris. The difference, and pain in the butt, is that you have to install it yourself first. The package manager is called Blastwave, and you install packages using the pkg-get command similar to apt-get. Here’s how to get up and running quickly.

Step 1) install blastwave

pkgadd -d http://blastwave.network.com/csw/pkg_get.pkg

Step 2) Update package list

pkg-get -U

Step 3) Install whatever you want, let’s install webalizer to look at log files.

sudo pkg-get install webalizer

If you get any error messages like ** ERROR: cpio … , try switching to root user with ’su root’ instead of using the sudo command. I had a similar problem and root works best for me.

Read more about Blastwave and configuration instructions here.

Uncategorized11 Oct 2008 04:43 pm

I’ve been doing tons of php programming lately and with that usually comes lots of MySQL programming also. An easy way to avoid getting SQL injected is to use this php function mysql_real_escape_string. Here’s a trivial example:

<?php
 
//get user's unsafe string 
$unsafeInput = $_GET["password"];
 
//make users string safe for sql queries and avoid sql injections
$safeInput = mysql_real_escape_string($unsafeInput);
 
//use the safe input in a query
... 
?>
Java and Networking and Programming and Uncategorized30 Sep 2008 06:33 pm

source code - STUNUtility.java
Important Note  - Rename the above download to STUNUtility.java, my blog tool lowercases all files when I  upload them, and java will complain when you compile if uncorrected.

Here’s the long overdue part 2 of the nat traveral post. Crossing NAT’s souds much more difficult than it is in reality. After doing lot’s of research and testing different libraries, I discovered Stun4J. The library works really well, but It’s API was a little difficult for me to just jump straight into. So I did what any programmer should do, I read the source code =) !

I made a small wrapper class that makes using Stun4J Really Really Really Easy. Long story short you can jump a NAT in about 3 lines of code! I wish someone game me this !!!!! The class is called STUNUtility and there is a sample main function that will find your computers NAT mapping. After you find this NAT mapping, computers outside your LAN can connect to the returned public IP and public Port. This library only works on 2 of the 3 major types of NAT’s though. I’ve been unable to figure out how to traverse symmetric NAT’s and would appreciate any ideas for help if you know (other than proxy servers)!

Before you run STUNUtility, make sure you have Stun4J.jar in your java classpath. Unfortunately, Stun4J doesn’t let you download a jar file (please correct me if this is wrong), so in order to get this to work I checked out their cvs code and compiled it with ant.  You can find the Stun4J cvs and compile it yourself or download pre-compiled Stun4J.jar that I created for myself.

Here’s the main function, and the comments should pretty much explain everything.

    /**
     * Demo class to find your NAT routing information.
     */
    public static void main(String[] args) {
 
        try {
 
            //this is apublic stun server. It might go down after posting this, so you should really setup your own.
            String stunServerAddress = new String("stun.xten.net");
 
            //this is the port that most stun services run on
            int stunServerPort = 3478;
 
            //this is the port your program wants to be able to use.
            //The stun program will find the NAT mapping of this port,
            //and find the public IP address and port number that internet users
            //can connect to you with.
            int aLocalPortYouWantToUse = 2525;
 
            //create a stun utility tool (makes stun4j a little easier)
            STUNUtility stun = new STUNUtility(stunServerAddress, stunServerPort, aLocalPortYouWantToUse);
 
            //talk to the stun server and figure out the NAT information
            stun.performSTUNLookup();
 
            //now print out the info that users outside the internet can use to connect to you.
            logger.info("Internet users can connect to my IP address " + stun.getPublicIP() + " and port " + stun.getPublicPort());
 
        } catch (Exception e) {
            logger.severe("Failed to lookup NAT information via STUN: " + e.getMessage());
        }
 
    }
Uncategorized26 Sep 2008 06:18 pm

An essential building block to understanding, breaking, or fixing computers begins by being best friends with the command line. Here’s a great site that’s made a list and description of the best Mac OS X (Hacking?) tools.

A fun and unique Mac OS X program is:

/usr/bin/defaults

Here you can alter Mac OS X system default preferences and reveal many hidden features in the mac os x operating system. For example… here you can get rid of the 3-D 10.5 Dock, and use a 10.4 2-D dock:

<code lang=”shell”>

defaults write com.apple.dock no-glass -boolean YES killall Dock

Defaults also controll’s your Desktop background.. and Much Much More.. check it out!

ps.. many other applications store their data with the defaults program.. you can do cheap hacks by manipulating their info.. have fun!

Uncategorized09 Sep 2008 07:00 pm

The “Large Hadron Collider” experiment kicks off tomorrow ( Sept. 10 2008) at 4:30 pm (eastern time zone)! Click here to watch the Large Hadron Collider Experiments Live when the first particles begin to collide. Cross your fingers that the universe doesn’t get sucked into a black hole! haha… I’m pretty excited to see what’s to come from the this billion dollar experiment.

Java and Programming and Uncategorized31 Aug 2008 11:56 am

I’ve been working on a java program for some time now called “Blackout Media Player” and recently discovered a very frustrating problem that java can’t large values for the -Xms or the -Xmx flags. The problem isn’t with java, but that the underlying operating system (specifically windows xp for me) has a limit on how much memory a process may allocate. From my testing you can safely set the heap min/max to 1G but anything over that and windows will pop up a message that says “Cannot create the Java Virtual Machine”.

However on Solaris I’ve heard that users can asked java to allocate around 3G. I haven’t seen the problem at all yet on Mac OS X, however I also haven’t tried a value greater than 1G.

If your program live in 1GB of memory, then you need to seriously consider trimming the fat off your application, or create a multiprocess approach to beat the single process memory cap.

Here is an interesting article related to this topic:
Why can’t I allocate 2GB of heap to the JVM on Windows, Part 2

Uncategorized26 Jul 2008 12:14 pm

Here are the steps to update your iPod Touch to firmware 2.0 for FREE so you can use the app store.

1) Download a torrent for the iPod touch firmware, try this link to find the torrent (should be a good starting point to find the torrent).

2.) Connect ipod and wait for itunes to open.

3.) Select your ipod from the iTunes sidebar (on left)

4.) Hold Shift and Alt (Option on Mac) and click on Update (inside the iPod touch information). Select the new firmware you just downloaded via torrent. The extension is .ipsw

5.) That’s it… just give your ipod and itunes some time to re-sync and install the firmware.

Java and Programming25 Jul 2008 08:12 pm

Download The Class Here: BreadthFirstSearcher.java

Here’s a Java class that performs a Breadth-First search and returns a Vector of File object’s that match the extensions you provide to the constructor. This allows you to easily search a file system for specific types of files in about 2 lines of code. The class has a main function that demo’s how it works.. you just need to change the variable named ’startingVariable’ to a valid folder on your computer.

    /**
     * Test the finder and print out the files it finds.
     * @param args
     */
    public static void main(String[] args){
 
        //the folder to start searching from
        String startingFolder = "###### PUT YOUR START FOLDER HERE ########";
 
        //The supported files to find
        String[] extensionsToFind = {".mp3"};
 
        LocalMediaFinder finder = new LocalMediaFinder(startingFolder, extensionsToFind);
        finder.search();
 
        //Print status
        logger.log(Level.INFO,
                "Completed Search: " +
                finder.getFiles().size() +
                " Files, " +
                "inside" + finder.numberOfProcessedFolders() + " folders.");
 
    }
Apple and Entertainment20 Jul 2008 03:18 pm

Having trouble playing video or audio files on your mac? Yes, mac can play those files with strange extensions also… all you need is to download Perian. It’s a FREE plugin that give your Macintosh based computer the ability to understand hundreds of file types and codec’s it previously couldn’t. After you install the plugin you’ll find you can open almost anything inside Quicktime hassle free! This plugin can also fix audio timing problems in video files… by using a more accurate codec’s than mac os x’s default bundle. Check it out… and install it to save headache’s later.. now that 10GB season of Battlestar Gallactica will actually look and sound right!

Blogged with the Flock Browser

Tags: ,

Java and Networking and Programming10 Jul 2008 07:55 pm


PART 1 ( Of a continuing series )

First, What is NAT traversal?

Wikipedia Definition: Here

Quick summary:
NAT traversal allows you to make a connection between 2 computer’s where at least 1 computer is behind a NAT. Since most home’s these days have wireless internet, the wireless router acts as a NAT creating a private LAN with private ip addresses. In order to create internet connected applications, you need to use NAT traversal to find the correct IP address and Port number to use to connect to hosts behind the NAT router.

The Solution (Overview):
1.) Client #1, who is behind a NAT sends datagram to STUN server.
2.) STUN server determines an IP address and port number that can be used to connect to Client #1
3.) Client #2 uses the IP address and port info (from step 2) to connect directly to Client #1

I’ll explain specific java libraries and exactly how to perform the above steps in upcoming blog posts. Stay tuned, or email me if you need information asap.

Part 2 - A Java class that get’s you over NAT’s REALLY REALLY EASILY!

Blogged with the Flock Browser

Tags: , , ,

Next Page »