Skip to main content

Posts

Showing posts with the label file

Error copying files in Finder of OS X

Problem: I have an SD flash card (8 GB Kingston) and a MacBook Pro 13" (Late 2011 model). I also use external card reader time to time. This problem persisted on all the conditions. The error message was stating: The Finder can’t complete the operation because some data in “” can’t be read or written. (Error code -36) This was happening while copying Photos from my camera (cr2 files). It worked, however, in case of copying files up to 200 MB in total size of batch. It dropped this error message and did stop to copy files upon selecting of lots of RAW files. E.g. all of them and attempting to copy them from a flash drive. Solution: Problem occurred with building miniatures of the CR2 files. Those files are quite heavy photos (25+ MB) and building miniature did take some time. While building those miniatures on both MAC and SD card finder windows it did die. For me it was enough to change the view from icons to list. E.g.: This did solve it for me. Other solution (Suspect...

Raspbery Pi as a home file server

I've wanted more from my PI, besides Time Machine functions, established in my earlier articles. So I've decided to make it a SAMBA server. I have a Mac and a Windows PC. And several iPads/iPhones. So the decision was obvious. To access my storage content I'd need a samba share. Because it is recognized by all this tech. iPad has Oplayer, to watch movies without conversion... GoodReader for docs. One word - SAMBA share. SO this article will be about adding a samba share to your Raspberry Pi. Note I have a Time Machine already set up. But it won't matter much. I only have another drive index letters and so on. I'll try to cover this as much as possible. And macs somewhat easily read NTFS filesystems. So we will be mounting NTFS filesystem volume to a Raspberry Pi with SAMBA network sharing. Let's get on to it. To set up a Raspbery Pi home network Samba server you will need to: - Connect an external drive (USB HDD in my case). - Update fstab for auto-mount...

Django Log Files Viewer documents

Django Log File Viewer. This is a PYPI package django-log-file-viewer  documents. Github repo:  django-log-file-viewer@garmoncheg.github.com Usage: Useful to add log files view functionality to your Django admin web site. Instead of using database log files storage, it gives you ability to store/view log files through GUI. It requires a directory with Django log files to function. E.g. directory structure: $ project_dir / logs / : applog . log applog . log . 2012 - 09 - 22 . . . errors . log applog . log . 2012 - 09 - 22 . . . Screenshots: To parse/display these log files you need: 1. Install an app and add it to your settings.py INSTALLED_APPS section: # settings.py INSTALLED_APPS = ( # ... 'django-log-file-viewer' , # ... ) 2. Set UP 2 django variables in settings.py: # settings.py: LOG_FILES_DIR = '/path/to/your/log/directory' # Relative or static path string o...

SSH Unix/Lunux Recipes for daily usage.

I've decided to create a post with several recipes for commands I need to use daily. I use them from a Mac OS X Lion default console, except for some mac ports installed... Remote is special linux distribution. How do I Compress a Whole Linux or UNIX Directory?  You need to use tar command as follows (syntax of tar command): tar -zcvf archive-name.tar.gz directory-name Where, -z: Compress archive using gzip program -c: Create archive -v: Verbose i.e display progress while creating archive -f: Archive File name For example, you have directory called /home/garmoncheg/data and you would like to compress this directory then you can type tar command as follows: $ tar - zcvf data . tar . gz / home / garmoncheg / data / Above command will create an archive file called data.tar.gz in current directory. If you wish to restore your archive then you need to use following command (it will extract all files in current directory): $ tar - zxvf data . tar . gz Whe...

Delete all '.pyc' files recursively OS X

We often get strange errors with python. When you changing the source and cannot figure out why files are used from past. So if you ever get this dejavu feeling, try using this command: find . -type f -name '*.pyc' -exec rm {} \; It will delete all precompiled python sources. (Because with python you have ability to distribute your files in binaries in fact.) Those errors usually appear if you move/delete *.py files with version control. You usually exclude *.pyc files from list. Old links used this way. Debugger does not suggest wrong imports because your files are in fact there, just precompiled. Anyway I've just put this command to my blog for memorizing. It often helps me. Maybe it can for you.

Django: Creating multi upload form without using Flash

Hi there! Today I want to tell you about my experience of adding Multiple files upload form to my  Django project Photoblog.  I searched google for lots of plugins, but found only Flash usage examples. I dislike Flash technology, as for my personal usage, and want to build some more quickly working UI. Personally I have flash blocker installed on my browser. So that's main ideas pf my jQuery plugin selection. I found IMHO the best for my case plugin by  Sebastian Tschan . It had only one problem - No available Django examples. Let's try to fill the gap here... So my experience on befriending  Sebastian Tschan's jQuery File Upload Plugin  with Django is the topic of this article. Let's finally get started. :) Sebastian has built an important plugin IMHO. I want to thank him for his noble work of helping people with their tasks. It uses only jQuery UI and no flash, making it work more programmers way... So enough with the lyrics. Let's try to adapt his example...

Django: Rotate Image with PIL usage.

Let's assume we have this simple model: from django.db import models class Image(models.Model): image = models.FileField(upload_to="images/")   Task is to take this simple image, rotate it and save instead of original. Let's discover this way to do so: #views.py from PIL import Image as PilImage from models import Image def rotate(request): #getting instance of the model item=Image.objects.get(pk=1) #opening image for PIL to access im = PilImage.open(image.image) #rotating it by built in PIL command rotated_image = im.rotate(270) #saving rotated image instead of original. Overwriting is on. rotated_image.save(item.image.file.name, overwrite=True) return HttpResponse(str(image.image)) This pattern will work in most cases.  Instead of rotate you can use any other PIL editing method, as for e.g. flip or sharpen the image... Have fun coding and please leave me a comment if you'll find this info useful. ...

Django: add image in an ImageField from image url

Today I had experience with django file downloads from an specified url into Django model FileField. I'm writing content grabber from Flickr. I didn't find information about it and decided to write what I've discovered so far in example. Stackoverflow helped me a bit. But answer proposed there had not worked. So this is code example how to workout this issue: because code worth a thousand words :) We have a model with one field: #models.py class Photo ( models . Model ):     image = models . ImageField ( 'Label' , upload_to = 'path/' ) We need to create a photo from image url and save it to the model's FileField. #somewhere in views.py # usually in header imports from urlparse import urlparse import urllib2 from django . core . files import File   #add imprt of content file wrapper from django . core . files . base import ContentFile # somewhere: for e.g. in view handling the file operations photo = Photo () img_url =...