HELPFUL SVN SCRIPT FOR ADDING ALL UNKNOWN FILES TO REPOSITORY
I use SVN from the command line a lot. I also hate typing things over and over. I wrote this script to add all files to a repository that are not already in there. svn status | awk '{if ($1 == "?") print $2 }' | xargs svn add I have this saved in my ~/bin folder as “addall”, which I’ve added to the $PATH variable, which gets set in ~/.bash_profile
HOW TO USE CURL TO HIT A WEB API USING HTTP BASIC AUTHENTICATION
Curl is a fantastic application. The most basic use of curl is very straightforward, just put in a web site’s url: curl http://twitter.com If you copy and paste the above code, you’ll get the HTML output of twitter’s home page. In order to demo this, I created a twitter account. You can sign up for one on your own. Now, to hit their api and update your status, they require you...
MYSQL DOES NOT SUPPORT VARIABLES WITH LIMIT IN STORED PROCEDURES
After banging my head against a wall for a while, I finally found this thread from June 2005 in the MySQL support forums regarding using variables in the LIMIT clause. They don’t support it yet. There’s no time table that indicates when it will be supported either. It’s very unfortunate, I was looking forward to benchmarking the difference between our ad hoc code and the stored...
'DATABASE TIP: ONLY COUNTING CERTAIN VALUES IN AN AGGREGATE QUERY'
Aggregates are awesome. But sometimes you want to do 2 counts in a query, and have one of them be more restrictive than the other. Lets say our database focuses on pictures, and rating them on a scale from 1-100. We want to know the average rating, the minimum rating, the max, the number of ratings, and the number of ratings over 75. First let’s setup the tables. create table rating (...
MANLY DIAPER BAG
We never get ads that make any sense when developing answerbag, since we’re behind a firewall and the crawler can’t figure out our content. Edit: This is not happening with our live server, the screenshot is from DEV.
PUBLIC / PRIVATE KEY SET UP BUT NOT WORKING?
When you set up public key authentication, make sure your authorized_keys2 file has the permissions set to 600. If you don’t, it’s likely that you will still be prompted for your password. chmod 600 authorized_keys*
HOW TO ROLL BACK COMMITS TO AN EARLIER VERSION OF A REPOSITORY IN SVN
I’ve always wanted to know how to do this, and for some reason I always had a hard time finding out how. I needed to rollback a change I had committed to my SVN repository. The way you rollback to an earlier version of your repository is to do a reverse merge. Here’s the example off the SVN site. It will do a reverse merge, and roll back the commit you made in version 303.
DELETE FROM TABLE USING A JOIN
MySQL won’t let you delete from a table using a subquery that references itself. Fair enough. To get around this, up till now, I’ve used temporary tables. However, I’ve never really liked it, and I’ve always wanted a JOIN delete. Well, apparently it exists. I’m cleaning out some data from some really old database dump. I needed to preserve the data in the article...
AWK DOES NOT WORK AS EXPECTED WITH DOUBLE QUOTES
Of course, I felt like an idiot after being completely confused by this for about half an hour. Consider this: awk "{print $1}" somefile.txt This does not work as I had expected. The reason is because the $1 is evaluated within double quotes, (not single quotes). Yes, it’s a rookie mistake, but I never claimed to be the awk master. So, always write: awk '{print $1}' somefile.txt...
USING A RESULT SET TO CALL STORED PROCEDURES FOR AD HOC QUERIES
Using mysql -e’s feature, combined with awk and xargs, I was able to call an existing stored procedure repeatedly for a resultset. Yes, I could have written another stored procedure to do this, I realize. But I guess I like doing things the hard way. Either that, or this is just less code. Or I wanted the awk and xargs practice. Whatever. mysql database -e "select id from category where...