Posts Tagged ‘javascript’

Shared MySQL

Wednesday, May 17th, 2006 at 9:19 pm

Dear LazyWeb:

I want to share a MySQL database between two installations of PHP and MySQL on two different machines running at different times. Basically, I want a Wiki on a stick that I can run on Windows and my iBook. This is easy on Windows - just follow the instructions on the page linked there. Running a wiki on a Mac is unbelievably easy with MAMP.

The problem is pointing the both of them at the same MySQL data so I can update the info in either place. I can change the datadir in the MySQL config in MAMP, but it does me no good - MAMP has to be installed in /Applications/MAMP, or it just doesn’t work (it won’t even copy into other directories).

So I need to find another solution on the Mac, or a way to point the MAMP install of MySQL at an arbitrary directory. Anyone managed to do this?

Also, a couple notes:

  • This isn’t a real LazyWeb request, since I’ve spent about 8 hours dicking around with this over the past few weeks. That’s not too lazy….right?
  • I know about Tiddlywiki, but it’s not going to scale the way I want it to. This is going to be a big wiki and I don’t want it relying on having lots and lots of JavaScript in memory (their homepage made Firefox complain about running too long). I’d be open to other wiki systems (file based DB, maybe?) if they have the features of MediaWiki (revision history, mostly).
  • I know I could just run this on the PC desktop and connect to it like any other website, but I’d like to keep it on the thumb drive if I can.

Any ideas are welcome.

JavaScript, JSON, and PHP

Thursday, January 26th, 2006 at 9:24 pm

John first mentioned JSON about a month ago, but at the time I had no inclination to look into it and find out if it was something I could use. It came across my radar again today thanks to a Particle Tree article that I never finished reading, but that’s not important. The long and short of it is that JSON is really just a fancy name for eval-ing JavaScript objects - one of those “why didn’t I think of that” kinds of things.

The few times I’ve tried using Ajax, I’ve spent most of my time fighting with XML parsing (or convincing IE that it was XML I was trying to parse), so the allure of native JavaScript objects was enticing. I talked with one of the guys at work about writing a function in PHP that would take an array and generate the appropriate code, until I came across the (seemingly de facto) “official” JSON page. He’s got references there for pretty much every language you’d expect to do web development in (and a few you wouldn’t) - including JSON-PHP, which does exactly what I was going to. Couple that with Prototype’s quick-and-dirty Ajax.Request, and you’ve got a Web 2.0 application quicker than you can say “What the hell is a Web 2.0 application?”

QuirksBlog has a pretty good post comparing JSON, XML, and HTML snippets, if you’d like to further consider your Ajaxing options.

Prototype

Saturday, January 14th, 2006 at 1:39 pm

Anyone who does any JavaScript development should give the Prototype framework a try. It provides a lot of helper functions that replace a lot of code. For example, there’s a $() that effectively calls document.getElementById(), but allows for several arguments and will return an array of elements matching those IDs. A few functions handle form access and processing, and there are a handful of AJAX functions I haven’t tried yet. It’s nothing that I couldn’t do on my own, but it makes things much easier. I just started playing with it at work yesterday, so I haven’t found out what it can really do, but I think I’ll be using it for other projects.

Unfortunately, the official site has next to no documentation. The code is simple and clean enought that reading it is enough in many cases, but it’s not all too clear. Thankfully, plenty of people have come before me, so there’s some decent information out there. The two I found most useful were Particletree’s introduction and Sergio Pereira’s guide.

Life is Good

Wednesday, August 17th, 2005 at 1:30 am

Things have been going pretty well lately. Financially, I’m doing OK. I’m buying Becker’s Saturn next week, and I’ve got plenty of money set aside to buy, insure, and register it. The Apple loan is paid off, so I can put a decent chunk of my last couple paychecks to the credit card bill.

I’m working on a new project at work for the big plasma screen in the college lobby. One of the secretaries in the Dean’s office makes slides to show on it, but the system is pretty crappy, so we’re re-writing it to just show a web site we’re designing. I’ve been working on the client side, to make use of templates and styles that we’ll define so she can build slides. It’s been a lot of PHP and JavaScript, so I’m happy.

Classes are starting soon, which means people will be coming back from break in a week or two. I have never seen our parking lot so empty; apparently, most people go home for this break. It’s the calm before the storm; RJ showed up yesterday, and I hear the RA’s are starting to come back for their training. Another week or two and everyone will be back.

I’ve gotten over the whole graduation thing. Usually, I only get stressed about money, when I realize I’ve got $1.64 in the bank and a $50 bill due in four days. I freak out for about 10 minutes before I convince myself that everything has worked out in the past, so it’s sure to do so again. And it has - worrying about it has never fixed the problem, so I don’t bother. My anxiety about leaving for the real world was a little more profound than that, but I’m over it. Things are going too well to worry much about what will happen a few months down the road.

I Love Co-op

Wednesday, March 16th, 2005 at 12:07 am

Being on co-op is totally sweet. With nothing to do on Saturday, I reverted to my natural state - a lazy ass. I spent the entire day sitting in bed, watching the Simpsons and reading blogs. I was actually productive on Sunday, reading through a lot of stuff I had posted on del.icio.us with every intention of reading later on. I wanted to read up on XMLHttpRequest more so I would have a better understanding of what I was doing when I started working with it. As it turns out, there wasn’t much else to learn. The one thing that would have come in handy before I made the crappy little test page is the Content-type: text/xml header that I forgot. Aside from that, I didn’t find anything new.

I also took a look at SAJAX, to see if it would be worth using. I haven’t played with it at all, but after looking at the code, I don’t think I’ll bother. From what I’ve seen, it only passes a single variable at a time. It looks really simple to use, but I’d rather be able to retrieve full XML documents from the server so I can get more info at once.

Last night, I started working on my Ta-da list ripoff. I spent about an hour trying to debug a transfer error only to find that when I copied the code from my original XMLHttpRequest test page, I neglected to change the URL for the requests to the server, so they were pulling the XML from the wrong PHP script. I had a lot of incentive to find the problem quickly, though - Niraj posted a Flash cartoon last week over at TLG Media. It’s been pretty popular and at least one copy is in his CSH web space, so the House web server has been getting blasted for the past couple of days. I’m really hoping it dies out quick, because a static HTML page takes a good 5-10 seconds to load (waiting for the MT admin interface reminded me of the good old days on AOL). Every time I made a change in the code, it would take a good 30 seconds to save it over SFTP and reload the page to test it again.

Tonight, I’ve been working locally. My JavaScript skills - or, more specifically, my DOM skills - needed some brushing up. I’ve spent the past hour or so just working on making the page functional and a little prettier. I figure, I’ll do all that stuff first and finish off the PHP and XMLHttpRequest side of it later on. If I’m lucky, some new fad will hit the net and Niraj’s thing will fade away so I can get some work done. Or maybe it will finally give me the push I need to get Apache, MySQL, and PHP running on my desktop so I can run my site from my apartment.

XMLHttpRequest is Sexy

Monday, March 7th, 2005 at 1:12 am

So, after complaining a bit about XMLHttpRequest, I did some looking around today to see how big of a pain in the ass it would be.

Turns out, not very.

I spent a couple hours fighting with a test page, until Resig pointed out that I needed to specify text/xml as the content type for the XML document (thanks again, John). From there, I just needed to touch up the JavaScript a bit to get it working the way I wanted it to.

I’m pretty psyched about the prospects of this whole Ajax business. It’s a lot easier to do than I expected it to be; the most difficult parts come in with DHTML, for the most part. My JavaScript skills could use polishing anyway, so I’m planning to re-write the segfault editor (members only, sorry) I did last year in PHP. To begin with, I might clone Ta-da List, just to get some practice before throwing myself at the bigger project.

I never liked the idea of relying on the client to provide processing. PHP always seemed safer because it runs server-side, so you don’t have to worry about the user disabling JavaScript or running an ancient browser that doesn’t support it. By now, most users have upgraded to at least IE 6 or (hopefully) Mozilla Firefox, so this is where the web is headed. If some really cool sites hadn’t already shown off the capabilities of the technology, I probably would have dismissed the idea entirely. Thankfully, some talented people got to it before I did and convinced me it’s worth tinkering with.