Fragmented Development

Server Administration for Dummies

jacob | 08 January, 2010 19:07

I finally got Postfix configured correctly (if not completely) on my VPS. It took a lot of poking, but now I can send and receive mail in SquirrelMail. While this is only the beginning of the configuration, it's a nice feeling to have something "click" and start functioning. I owe it all to the fantastic Postfix documentation - quality stuff they've got there.

As a nice side-effect, PHP is also able to send mail out - and that was a BIG stumbling block to getting sites migrated over. Those PHP mailer scripts sounded like such a good idea when I was embedding them in each site...

It's been loads of fun getting this running, but it has also shown me how immensely small my sys admin knowledge really is. I administer Windows servers at work, but Linux is a whole different ballgame. I felt quite lost in the beginning, but in the months I've been working on this server, I feel like I've learned tons more about the software involved and how it all interacts. Each time I go back into a config file, I see mistakes I've made and correct them, and the server runs a little smoother.

Okay, next adventure is going to be getting Postfix configured for virtual domains, and allowing authenticated users to relay mail with their mail clients. SquirrelMail is good stuff, but I'm not going to force it on clients!

jQuery, wrap(), and IE

jacob | 29 December, 2009 15:32

I decided to create a collapsible/expandable navigation script as one of my first forays into jQuery, and ran into an interesting issue with the way I was using the wrap() function, and the way Internet Explorer interpreted it.

I was adding some anchor tags via wrap(), like so:

$('#selector').wrap('<a href="#">');

This worked fine in every browser I tested in, as long as it wasn't made in Redmond. The code ran fine, without any errors, but wrap() never added the anchors. This really stumped me for a while, since it not only broke in IE6, but 7 & 8 as well.

A quick change to the code, however, had everything working everywhere:

$('#selector').wrap('<a href="#"></a>');

Who knew IE was a stickler for properly formatted code? I'm not sure why this happens, but hopefully my discovery will save you some time in the future.

Where's Windigo?

jacob | 07 December, 2009 20:16

At one of our LUG meetings, NYbill noted that I had more or less been a no-show lately on the forums, IRC and everywhere else. I even missed a LUG meeting! So, I wanted to give everybody a little sneak peek on something that I've been working on...

Take a look at the teaser for Hike ADK (and please don't mind the graphics!)

I live in the Adirondack Mountains of upstate New York, and as a result of that, I enjoy hiking. I also enjoy web technology and Free software, so the logical thing to do was to make a web site about hiking. So, I've been working on that a little bit (in addition to a busy time at work).

Not only have I been working on the web site, but I've been working on the Linode that it will be running on, which is a large piece of unknown landscape that I need to cover. It's been a long time since I used Apache seriously (last time it was Apache 1.3, not the 2.2 branch), and the first time I've tried my hand at Linux server administration. Very cool stuff, but definitely very tedious to some extent.

The web site itself is really pushing my experience with things like SVG, Javascript & Jquery, and some of the PHP libraries I don't get to use too much. I'm having loads of fun doing it, but it's also very time consuming. With the other side work I do - smaller organizational web sites and such, light helpdesk stuff - I've had trouble keeping up with the forums and everything.

December should be another busy month, but I have high hopes that some saved vacation time will let me pop up more often in the LO community. It's easy to forget how awesome everybody is, but it's even easier to dive right back in. Hopefully I'll stop by more frequently!

PHP or die?

jacob | 18 November, 2009 15:51

In several low-level, beginner PHP tutorials you'll see this:

mysql_connect() or die('Cannot connect to the database');

First of all, if you're doing this, knock it off. It's a terrible practice, which leaves whoever is using your page completely in the dark. In fact, if you have the die() function AT ALL through ANY production code, stop reading this. Fire up your text editor, and find every line with this function in it. These are bugs in your code. This is why people make fun of PHP.

Now, since that is a terrible way to program, I've never used that line of code before. However, I have used this in functions plenty of times with my database class:

if(!$db->Connect())
{
	return false;
}

From there, my code displays a message to the user and logs an error so that I can address it later. While coding up something similar to the previous code, I had a thought: could I substitute a one-liner that does the same thing?

$db->Connect() or return false;

To see if this would work, I tried looking up in the PHP Documentation. If ever there was a search-proof term, "or" is it, so I ended up manually digging around the documentation. I couldn't find any documentation of this kind of syntax, and I quickly realized why: I should have been looking under Logical Operators.

It turns out, this coding technique was simply using the properties of a short-circuit to make some very elegant code. If the first statement is true, PHP realizes that the whole expression will return true, and therefore doesn't bother executing the second statement.

So, my question is... is it safe? Should this "or" technique be used in important code? The only time I've ever seen this employed is in a piece of code that isn't good. Does that mean the technique itself is a bad idea? It smells to me like using a break statement in the middle of a for loop, but I really think this could be useful. What do you think, internet?

Wine Gaming: Osmos

jacob | 09 October, 2009 10:39

I picked up a copy of Osmos, an independent game from Hemisphere Games, a couple weeks ago. As is usually the case with independent games, Osmos takes a bit of a diversion from your classic 3D-Shooter or RPG genre restrictions, and invents it's own game type.

Osmos is a combination physics sandbox and strategic cell simulation game... I think. I like to think of them as cells, although the game refers to you as a "mote". The basic gist is that bigger motes absorb smaller motes, and you need to become the biggest by absorbing just about everybody. You move around by ejecting some of your mote-matter in one direction, which propels you in the opposite direction (hence, physics sandbox). This also makes you a bit smaller, however, which can put you at the wrong end of the bigger-eats-smaller equation. All of this is accented with soothing ambient music, which does very little to calm you down when a larger mote is trying to gobble you up.

This game really started to grow on me, which became a problem. I originally bought it through Steam and played through it on my Windows partition, but I'm never quite satisfied while I'm there. I wanted to see if I could bring it over to the side of righteousness.

After backing up all of my games from my Windows partition and re-installing them in Wine, I tried out Osmos - and it worked like a charm. I enabled a virtual 1024x768 desktop through my Wine Configuration, and that was it. Instant gaming, no slow down, no fiddling necessary. It does require OpenGL, so heads-up to those of you without hardware acceleration - I haven't tried it without.

Osmos, running under Wine

After quickly checking on the web site, I found out that even the simple Wine intermediary won't be necessary for long; if you buy the game from their web site, you will be able to download the Linux version (or Mac version) as soon as it's available. Also, the game itself is 100% DRM free, which should be a welcome revelation for the beardistas among us.

For only $10 US, Osmos seems like a sensible addition to any Linux gamer's collection. Download the demo, and give it a whirl if you'd like to see for yourself - just make sure to buy it direct from them if you're interested in the eventual Linux port. I'm really excited to see what else these guys put out!

Archived

jacob | 06 October, 2009 09:51

Recently, tioduke inquired about how my Arch adventure was going, so get ready for a follow-up post!

Installing Arch was not as simple as other distros I've tried; however, I was able to get through it and found my netbook to be in a useable - if bare-bone - state. Arch does not come with a lot of extra fluff when it's first installed, so I was left with my console and the highly developed Arch wiki.

The wiki (and some folks in the #linuxoutlaws IRC) had things like my wireless card up and running, but I never quite got up to an X session. I believe I stumbled into problems when I tried to set up HAL, but couldn't really get anywhere from there. I even took it to my LUG, to partake of their wisdom, but we weren't able to get X started.

Well, that's only half accurate; I was able to get X started once or twice, but it appeared to freeze after that. I later on learned that I may have needed to install some sort of X input package... why wouldn't that be included with X itself?!?

So, after the LUG meeting, I ended up installing CrunchBang - and that's what I'm using as I type this. Someday I'll revisit Arch, but I think I went about it the wrong way this time around. First, I installed an unfamiliar drive as the primary OS on my netbook. I don't use my netbook a tremendous amount, but I do use it. Not having it available made a N810 my primary machine at the LUG meeting, which didn't really cut it. If I was going to try it again, I would install Arch on an SD card and dual-boot.

I may revisit Arch again someday. The idea of starting with a absolutely bare-bones system and building from there is an attractive one, and the rolling release idea makes a lot of sense to me. But for now, I consider this experiment... Archived.

(Any complaints about the pun can be sent directly to my parents. It's all their fault.)

Arch Nemesis

jacob | 05 September, 2009 08:29

I recently had that feeling, the "distro-hopping" inkling that you get when you're too comfortable with familiarity and everything working. After a session in the #linuxoutlaws, I decided that I was going to install Arch Linux on my Dell Mini 9.

So, if you're in the Linux Outlaws channel, stay away from grnmtn. He's nothing but trouble. ;)

I kid, I kid. So I've been working on getting Arch running on my netbook, and I have a couple tips so far:

  • Install "base-devel" too. It just makes things easier.
  • Arch Wiki it is your friend. I'm still looking for the meaning of life page, but I'm pretty sure it's in there somewhere.
  • Use a wired network connection, or use a wireless card with free drivers. I had a heck of a time getting my wireless going.
  • #linuxoutlaws is a great help. I've heard that #archlinux is good as well, but haven't been there myself.

I'm going to try getting X and a window manager up and running this weekend; I'll post an update when I get a bit further. I think I'll wait before I pass judgement on Arch, until I've had some further experience with it.

Linux Outlaw Gaming

jacob | 14 August, 2009 05:50

Fancy yourself a gamer? Fancy you'd like to be? Play a game once and a while? Well, we're looking for you!

Today, August 14th, we're trying to get some Linux gaming going under the Linux Outlaw banner. If you're interested, there's a simple way to join in: throw a LO in front of your name, and you're set!

I'm LO|Windigo, so if you run into me, introduce yourself. I'm always interested in meeting people who enjoy both Linux and gaming.

So, if you're interested in joining up with other outlaws, check out the "Linux Outlaws gaming" forum thread or meet us in IRC. The more the merrier!

Troubleshooting: Scheduling Batch Scripts in Server 2003

jacob | 16 July, 2009 10:22

For all of us stuck in a Windows Server environment, hopefully this will help a bit.

I encountered a problem running batch scripts as scheduled tasks in Windows Server 2003 under alternate credentials. I kept getting errors like the following:

Unable to start task.
The specific error is:
0x80070005: Access is denied.

It turns out that the reason this occurs isn't necessarily because of permission problems with the script itself, but with the Windows shell, cmd.exe. You see, the task scheduler isn't really running your batch script: it's running cmd.exe, with your script as an argument. So, you need to give read (maybe more?) permissions to the account that the service is running under, or else your script can't execute.

Yet another reason Linux is better as a server operating system...

Rest and Relaxation

jacob | 24 June, 2009 18:14

My Father's been lucky enough to secure some time at a small log cabin in the Adirondacks. If you need me, I'll be on Balfour Lake with most of the family.

Hopefully I'll have pictures when I get back!

OutlawPla.net

jacob | 19 June, 2009 05:47

Looks like the Linux Outlaws have started up their own Planet: OutlawPla.net.

I'm a bit worried that some of my posts on this blog are a little off-topic, even for the Outlaws (folks coming from the Forums will know what I mean). I'll be digging through the LifeType documentation to see if I can filter my RSS feed a bit, to prevent the FragDev-related news from hitting the planet site. If that isn't possible, I'll probably switch to manually updating the news and keep it off the blog. We'll see...

Lena's Adult Day Service

jacob | 30 May, 2009 11:12

The first site hosted on the new server is up: make sure to take a look at Lena's Adult Day Services!

If all goes well, I'm going to start moving the rest of the sites on there one by one. This should drop everyone's hosting costs by about 40% - 50%!

Arduino: Arrival

jacob | 30 May, 2009 09:46

The Arduino, as described by the Arduino Homepage, is "an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software." What that means to you may differ with your experience, but to me the Arduino is a little chunk of Italian-made circuit board that can make LEDs blink, can tell how bright the ambient light is, can run motors and mechanisms, and otherwise make electronic components do cool stuff.

There seems to be no limit to what people are capable of doing with one of these, with the addition of the right components. Just search YouTube for Arduino and you'll see what I mean. LED cubes dancing to music, robots that seek out the light – one of the guys from our LUG used his to have his dehumidifier tweet whenever it's full, and again to thank him for emptying it. If you would like to follow his dehumidifier, you can do so: Mark's Dehumidifier.

So, as a step towards building my Linux-powered robot to satisfy a New Years resolution, I picked one up. I also bought a couple wires, LEDs and other random components to test with. It arrived yesterday, and pictures will follow (once I get my camera some batteries).

So far I haven't gotten too much accomplished. I've caused a single LED to blink on a schedule, and to react to the light level of the room using a photoresistor. I've also realized that I don't remember anything from Digital in high school – big suprise. Most of last night was spent looking up resistor color codes and re-learning the basics of electronics.

All things considered, I'm very optimistic about how it's going. I'll keep posting progress here for anyone that's interested!

Issues with SQL Server 2005 and PHP - Part 1

jacob | 08 May, 2009 09:25

This maddening issue took quite a while to figure out, so I sincerely hope I can save somebody the time by documenting it here.

First of all, here's the environment - at work, we're using the following:

  • Windows Server 2003 w. IIS 6
  • PHP 5.2.9-1
  • MS SQL Server 2005 Express
  • Connection made using ODBC functions

Yes, that's right, I have no control over most of the environment. Whatever. Moving on - we were having a problem with one of our new pages. Specifically, getting the information from the database and displaying it on the page.

Whenever I tried to run the query to get the database results, the script would consume all available memory immediately and halt the page execution. We're not talking the normal 8MB of RAM allocated to each page, either: we have our memory allocation bumped up to 128MB. Somehow this script consumed all 128MB and asked for more with just five result rows, each well under a couple kilobytes.

We were able to (somehow) deduce that the problem was in the table itself: apparently PHP's ODBC driver has a fit if there is a 'text' or 'ntext' field involved. It simply consumed all the memory and then quit.

Not a problem, though - MS recommends you stay away from those fields anyways, and instead use nvarchar(MAX) or varchar(MAX). A quick little switch, and we were on our way...

...to an even worse problem. Now, the same field that we had just modified was displaying - but not the text that field contained. Instead, it almost looked as if PHP was dumping memory into that field instead of the text itself. Inside of all the binary symbol garbage I saw things like function names, string values, and more. Extremely upsetting.

After a day and a half I figured out that the new nvarchar(MAX) data type seemed to be the cause, and switched it to the more bland (and not as scalable) nvarchar(1000). Still, if this had happened to one of our live pages, we could have had a serious security problem.

In conclusion, I will stay away from the following SQL Server data types as a sort of "preventative best practice":

  • text or ntext
  • varchar(MAX) or nvarchar(MAX)

If you have the option, I would recommend staying away from MS SQL Server all together. We have had no limit to the amount of problems this sub-par database has caused. Just use MySQL, PostgreSQL or one of the superior Free alternatives.

Inserting Files as Binary Data in MS SQL 2005

jacob | 08 April, 2009 14:55

I recently came upon an extremely quick, simple, and brutal to insert a file into a MS SQL database using only the query editor and a hex editor:

  1. Open the file in your hex editor
  2. Select all the hex, and copy it
  3. Open up the query editor
  4. Type up your insert statement: INSERT INTO table (binary_field) VALUES (0x!!!)
  5. Replace the three exclamation points (!!!) by pasting the data you copied from your hex editor

Now, this is far from recommended practice. In fact, this is a damn ugly way to do things. However, I didn't want to muck around in a scripting language, and the other SQL methods I found had too much SQL to them. SQL is not my strong suit, so voila – there you have it.

«Previous   1 2 3 4 5 6 7  Next»

All content, graphics and, design © 2005 - 2008 Fragmented Development. All rights reserved, may contain peanuts. Powered by LifeType.

Admin