By default, the to_json method in Rails is probably a lot more verbose than most people want. I’ll share a few tips on how to tame it.
Question: How can I slim down the output of to_json in Rails?
For most types of events, there’s a better way: Event Delegation. At the basic level it involves attaching an event delegation function to a parent element, then catching events which bubble up and passing them off to specific handlers based on the event’s target.
Comet for Web Games
For those not familiar with Comet, you’re either not a front end web developer or you’ve been kept in the dark. To sum it up quickly, Comet is a technology like Ajax. While Ajax basically consists of an asynchronous request by the client to the server, followed by the server’s response, Comet is a bit different. In Comet the client establishes a connection (or makes a request) to the server, and then generally keeps that connection open for the server to send responses back to the client on its own schedule.
I’m a web developer by day and have been programming, in one language or another, most of my life since age 10. But for someone without consistent (or any) programming experience, how do you learn to program? This question was brought on by a friend of mine who had a programming class or two years ago and is now setting his sights on giving it another shot.
The good news is that you don’t have to be a life-long programmer to have some fun with it. Old, young, students, hobbyists, and non-programmer professionals can all learn to program, provided they have some interest and a little time (it doesn’t take much to get started).
If you’re a programmer who has ever had to develop an application dealing with text input (which is most of them), from files, databases, or user input, you might be interested to know that regular expressions can make your job a lot easier.
Unlike most dry regular expressions tutorials out there (Mike’s smart post aside), I intend to provide more than just the “what”; I’ll walk you through the “how” and “why” too. After all, why would you care to learn regular expressions if you don’t get to find out about some of the cool and powerful things you can do with them?
In most programming languages, there exist certain simple and useful functions that people come to rely upon. From my days with Perl, chomp was one of those functions for me.
Given a string, chomp bit off all newline characters at the end of the string (and returned the number of newline characters it removed).
I realize that may not be a common problem, but in my day job I kept running into it while adding hundreds of keywords at MSN’s adCenter (wanting all of them to use all match types).
Hasn’t someone else already solved this problem? Seems very likely, but my searches were only pulling up examples of “check all” functions to use on your own site, so after a bit of coding I present to you my check-all checkboxes function:
On the road to a better to-do list application, I need to start with a solid base and advance one step at a time. That base includes simple ajax functionality so list items can be manipulated without a full page reload.