Dump a mysql db to a file
Posted by Vince Wadhwani on Apr 23, 2008 in | gnu/linux
Ok, I'm going to file this under: stuff you don't care about but I want to keep handy just in case I forget. What is it? I'm talking about dumping a mysql db to a .sql file from the command line. Like everything else, it's really simple if you have the correct syntax. For example if your database is called blogapp, then type:
mysqldump --databases --result-file=blogsqlfile.sql blogapp -u mysqluser -p
Substituting the mysqluser user for your mysqluser (root, mysql, whatever)
Quick Tip: Hidden divs in HAML
Posted by Vince Wadhwani on Apr 21, 2008 in | html/css | ruby
I had the chance to play around with haml the other day. Those of you who don't know haml might want to check the above link and come back. For the lazy people, it's basically an alternative markup aiming to make the views more readable or "beautiful". Whether it succeeds or not is not the point of this tip. Rather, if you're using haml, and want to create a hidden div, I'm here to show you how to do it.
Quick TIp: Multiple orders in a conditions statement
Posted by Vince Wadhwani on Apr 17, 2008 in | ruby
I honestly don't know how I went this long without every having to use this, but since googling for it can be a bit of a hassle, I thought I'd share this tip with you. Let's say you're in a situation where you first have to sort by date and then alphabetically. How do you put two :order's in the condition? Simple:
@foo = Foo.find(:all, :order => 'created_at desc, name desc')
The magic comma in the quotes passes it along correctly. Thanks to AndrewO for saving me the hair pulling.
Sid gets Python 2.5.2
Posted by Vince Wadhwani on Apr 16, 2008 in | gnu/linux
It took a long time, but Debian Sid looks like it finally managed to get to version 2.5.2 of Python. Why did it take so long? Because lots of packages could have broken on upgrade. And in fact, my compiz fusion-icon got totally borked because of it.
python-compizconfig: Depends: python (< 2.5) but 2.5.2-0.1 is to be installed
Small price to pay to get v2.5 as the default though -- I'm sure it'll get fixed in short order. But if you're running Debian Sid (or Sidux) consider yourself warned..
Quick Tip - convert a string to variable
Posted by Vince Wadhwani on Apr 09, 2008 in | ruby
Ok, so you already know that you can convert strings to other types of objects using Ruby's powerful tools. "3".to_i will give you an integer (3) while "3".to_f will give you a float. But if you want to convert a string to a variable? For instance if you're sending a call to your model and want to dynamically generate a variable? I wish it were as simple as "myvariable".to_var but it's not...
Ruby Gems 1.1.0 is out
Posted by Vince Wadhwani on Mar 30, 2008 in | ruby
Hey, good news, a new version of Ruby Gems is out. The change list for version 1.1.0 looks pretty cool and I'm psyched to have upgraded on my Debian/Sidux development box. If you wan to play along, simply type:
sudo gem update --system
Obama first to pass Acid 3 test
Posted by Vince Wadhwani on Mar 26, 2008 in | politics | brainbits
I swear after all the Obama news on Digg and Reddit I'm starting to see things. At first I thought this Opera announcement said "Obama the first browser to pass the Acid3 test"*. Time to turn off the laptop and enjoy the day..
The benefits of video sharing
Posted by Vince Wadhwani on Mar 19, 2008 in | politics
Back in 2006, I wrote a post on Net Neutrality that I still encourage people to read. In it, I talk about how the Internet has become somewhat of an equalizer.. allowing equal share of time to ideas from every corner of the country and from every ideal. At no time has that been more evident than during this presidential nomination cycle.
What every laptop needs
Posted by Vince Wadhwani on Feb 15, 2008 in | Mac/BSD | gadgets
For the second time in as many months, I've put my Dell XPS 1330 in a non-usuable condition. The first time it happened, it was due to the power connector coming loose from the MLB (main logic board or motherboard). At first I'd have to wiggle my AC adapter to get a charge, but eventually my laptop refused to accept any juice at all and I was faced with the dreaded 2 hours of battery life. (on a side note, I'm glad everything is backed up w/ rsync!)
A few days ago, after a late night coding on the couch, I got up and accidentally snagged the cord which brought the laptop crashing down about 2 feet from the coffee table to the floor. This time the screen and AC are toast again.
Observe Field and Radio Buttons in Rails
Posted by Vince Wadhwani on Feb 14, 2008 in | ruby
By this stage it should have been easy for me to get an observe field working in Rails but for some reason I just couldn't pull it off. I googled a bunch and still couldn't get an answer I was looking for (that worked). If you're in the same boat, here's a tiny snippet of code that will let you show and hide a div with radio buttons. Handy if you want to show different forms depending on the selection.