Listing Directory Sizes [Command Line Edition]
May 3, 2013, 5:45 a.m.
The command to use is:du -hd 1 <directory>
For example, if I wanted to list the size of all directories in my home folder, I would use:$ du -hd 1 ~ 0B /Users/derekkwok/.Trash 83M /Users/derekkwok/.android 56M /Users/derekkwok/.bower 96K /Users/derekkwok/.dbvis 6.8M /Users/derekkwok/.dropbox 0B /Users/derekkwok/.dvdcss 253M /Users/derekkwok/.env ... snipped ... 12K /Users/derekkwok/Pictures 957M /Users/derekkwok/Projects 0B /Users/derekkwok/Public 20G /Users/derekkwokThis command is also convenient in that it lists the total folder size also as the last entry.Remember to close zip in python!
April 16, 2013, 7:50 a.m.
I spent an hour today trying to debug the following code:
I spent a good chunk of time trying to figure out why the zip being saved is invalid. It turns out that I needed to add:if self.zip: self.zip.storage.delete(self.zip.path) temp_zip_file = tempfile.NamedTemporaryFile(mode='w') temp_zip = zipfile.ZipFile(manga_zip_file.name, 'w') # write other files into temp_zip self.zip.save('', File(open(temp_zip_file.name)))
I should have read the [documentations](http://docs.python.org/2/library/zipfile) more closely!temp_zip.close() # this writes the zip file ending records, making this a valid zipfileKeeping Track of CSS Rule and Selector Count
March 11, 2013, 8:37 a.m.
I came across a very useful little snippet of JS today that counts the number of CSS rules and selectors you have.
Usually I place this script inside a <script> tag in my projects, which outputs the results to the browser console. This script is only loaded in development environments. Source: https://gist.github.com/psebborn/1885511function countCSSRules() { var results = '', log = ''; if (!document.styleSheets) { return; } for (var i = 0; i < document.styleSheets.length; i++) { countSheet(document.styleSheets[i]); } function countSheet(sheet) { var count = 0; if (sheet && sheet.cssRules) { for (var j = 0, l = sheet.cssRules.length; j < l; j++) { if (!sheet.cssRules[j].selectorText) continue; count += sheet.cssRules[j].selectorText.split(',').length; } log += '\nFile: ' + (sheet.href ? sheet.href : 'inline <style> tag'); log += '\nRules: ' + sheet.cssRules.length; log += '\nSelectors: ' + count; log += '\n--------------------------'; } } console.log(log); console.log(results); }; countCSSRules();Using FFmpeg to extract MKV subtitles
March 5, 2013, 3:05 p.m.
Source: http://superuser.com/questions/556179/unable-to-extract-mkv-attachments-with-ffmpeg In short, the command you should run is this:ffmpeg -dump_attachment:t "" -i test.mkv
This dumps all the attachment files into your current working directory.List of Image Placeholder Services
March 2, 2013, 2:53 p.m.
Source: http://news.ycombinator.com/item?id=4906942 Below is an organized list of placeholder sites mentioned in the comments section: * [Fake images please?](http://fakeimg.pl/) * [lorempixel](http://lorempixel.com/) * [Placehold.it](http://placehold.it/) * [{placekitten}](http://placekitten.com/) * [pugholder!](http://pugholder.com/) * [Dummy Images](http://www.dummyimages.com/) Leave a comment on any other image placeholder sites you use, and I will add them to this list.