Ryan Bates continuously provide useful Rails tips in this railscasts.com.
I had written a bash script for downloading the videos of the episodes in the past. I do not like streaming much and I'd rather keep the episodes for reference.
One downside of the script is that I had to check the rss feed or the website for new episodes, and run the script manually passing the correct paramters (start and end of episode ids to be downloaded)
Now I decided to get rid of the silly step. so I ported my script to ruby, and it runs down to download whatever episodes are missing using the rss feed and checking what is already present.
The script uses simple-rss gem, so you'll have to get that installed. It also uses wget for downloading. I didn't bother using net/http of ruby, wget is fine for me as a linux user.
The script flow is simple: Check the current files in the download directory (collecting information)Grab the rss of railscasts.comIterate over rss items and download the ones…
Mysql allows exporting query results to csv using the INTO OUTFILE, like the following example:
SELECT a,b,a+b INTO OUTFILE '/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
This, however, will cause the data to be exported to the file system of the database server. Sometimes you do not have access to that server and you are only connected remotely from a different machine using mysql command line.
One way to export the data is to pass a query and redirect the output to a file as follows
$ mysql -u USERNAME -p PASSWORD -h DB_SERVER mydb -e "SELECT a,b,a+b INTO OUTFILE
FROM test_table;" > output.txt
This will do the trick, except that the resulting file is TAB separated instead of CSV.
You can simply download the file and open it using any text editor and replace all tabs with commas. but that's not practical for large data sets. Instead, we can use sed. Sed is…
I couldn't find a clear quick intro on getting siege and bombard in action, so I'm writing one here.
Siege is a load testing and benchmarking utility that has been available for quite a while, It allows you to hit your web application on a specific url (or a set of urls in a file) with specific concurrency and size settings. siege summarizes the measures of the test outcome including:
Transaction rate (requests/sec)Actual concurrency (even if you hit with 200 concurrent connections, your server might be responding with just 80)Average, longest and shortest response time
triggering 200 concurrent users, each hitting the url twice siege -c200 -r2 http://www.modsaid.com/
summary: Transactions: 400 hits Availability: 100.00 % Elapsed time: 38.44 secs Data transferred: 0.26 MB Response time: 10.09 secs Transaction rate: 10.41 trans/sec Throughput: 0.01 MB/sec Concurrency: 104.96 Successful transactions: 400 Failed transactions…