Showing posts with label snippets. Show all posts
Showing posts with label snippets. Show all posts

Dajngo app unicode JSON repsonse

If your django application has unicode data, and your view uses jquery and JSON response, do not forget to specify the encoding for the mimetype:

return HttpResponse(simplejson.dumps(your_data),
mimetype='application/json; charset=utf-8')

Resize files using one command

Using ImageMagick it is easy to resize multiple images by the following command:

for i in `ls *.JPG`; do convert -resize 1024 $i $i; done


A bit detailed version of this script can be found in my bitbucket repository: resizer.sh

Find duplicated files in a directory subtree

Md5deep is able to recursive examine an entire directory tree. That is, compute the MD5 for every file in a directory and for every file in every subdirectory, so you can easily use it to find your duplicated files by combining with uniq.

md5deep -r * . | uniq -w 32 -D

Unpack compressed files into separate directories

Here is a little script to unpack all compressed files such as *.rar and put them into a separate directory:


for f in *.rar;do n=${f%.rar};mkdir "$n"; unrar x "$f" "$n/";done