file

How to import modules that are used in both the main code and a module correctly?

Let's assume I have a main script, main.py, that imports another python file with import coolfunctions and another: import chores Now, suppose coolfunctions also uses stuff from chores, hence I declare import chores inside coolfunctions. Since both main.py, and coolfunctions import chores ~ is this redundant? Is there any other way...

iPhone file corruption

Is it possible (on iPhone/iPod Touch) for a file written like this: if (FILE* file = fopen(filename, "wb")) { fwrite(buf, buf_size, 1, file); fclose(file); } to get corrupted, e.g. when app is forced to terminate? From what I know fwrite should be an atomic operation, so when I write whole file with one instruction no corrup...

How to retrieve data from server and save into a file in [Objective-C] iPhone programming?

I've saved the contents of server into a NSData. How do I copy the contents of NSData into a file. ...

Dropping Files onto Dock Icon in Cocoa

How can I drop a file(or select to open it in Finder) of a type specified in the Info.plist onto my dock icon and then calling a method with the full path of the file? ...

How can I log the HTTP response codes in the file in Perl?

I have created HTTP::Request which looks like this: #!/usr/bin/perl require HTTP::Request; require LWP::UserAgent; require HTTP::Cookies; $request = HTTP::Request->new(GET => 'http://www.google.com/'); $ua = LWP::UserAgent->new; $cookie_jar = HTTP::Cookies->new(); $ua->cookie_jar($cookie_jar); $cookie_jar->set_cookie(0,'testCookie','c...

Reading lists from a file in Ruby

Hi, I have a txt file which contains data in the following format: X1 Y1 X2 Y2 etc.. I want to read the data from this file and create two lists in ruby (X containing X1, X2 and Y containing Y1, Y2). How can I do this in Ruby? Thanks. ...

Is there a way to associate an individual file with a specific application

I mean a specific file not a file extension ...

Image File In Text Editor - What Are The Characters? What's the Process?

i'm currently in the process of conceptualizing an art piece for a gallery show next year, so this bizarre question of mine is more than just simple curiosity. if i open up an image file (a .PNG) with Text Edit or Note Pad, the file is presented in textual characters. here's an excerpt: ˇflG¿§vÑ$BaçC$ èœ≥à-ƒ…åGj!mëA»T‰dÚ%ryǬF1¢ƒQ∑P®...

File extensions

I am trying to open a file with file extension '.lib' (open file library) and (.dll) but i dont know what program application to open it with. any advice? Thanks ...

problem writing xml to file with .net mvc - timeout?

Hey, so having an issue with writing out to an xml file. Works fine for single requests via the browser, but when I use something like Charles to perform 5-10 repeated requests concurrently several of them will fail. The trace simply shows a 500 error with no content inside, basically I think they start timing out waiting for write acces...

Writing Strings to files in python

I'm getting the following error when trying to write a string to a file in pythion: Traceback (most recent call last): File "export_off.py", line 264, in execute save_off(self.properties.path, context) File "export_off.py", line 244, in save_off primary.write(file) File "export_off.py", line 181, in write variable.writ...

NodeJS: Write to file

I've been trying to find a way to write to file when using NodeJS, but no success. Can you help me with this. Thanks. ...

read a binary file (python)

Hi, I cant read a file, and I dont understand why: f = open("test/test.pdf", "r") data = list(f.read()) print data Returns : [] I would like to open a PDF, and extract every bytes, and put it in a List. What's wrong with my code ? :( Thanks, ...

Quickest way to find the oldest file in a directory using Delphi

HI We have a large number of remote computers that capture video onto disk drives. Each camera has it's own unique directory and there can be up to 16 directories on any one disk. I'm trying to locate the oldest video file on the disk but using FindFirst/FindNext to compare the File Creation DateTime takes forever. Does anybody know...

Html index page and files in that directory

On my web site, there is an index page, but if I take out that index page, users will see the files in that directory, for instance my site is : XYZ.com and I have a directory called "My_Dir", so when a user typed in "XYZ.com/My_Dir" he will see the index.html if there is one, but if it's not there, he will see a list of all my files ins...

Use terms from text file in SQL WHERE ... IN clause

I'm running SQL query for MySQL server with ... where name in ("term1","term2","term3") I would like to get the list of terms from a text file with one term per line. How can I do this? What about if this list of terms will get large? 10K, for example. Will this be efficient or I should use another approach? May be temporary table an...

safely reading directory contents

Is it safe to read directory entries via readdir() or scandir() while files are being created/deleted in this directory? Should I prefer one over the other? EDIT: When I say "safe" I mean entries returned by these functions are valid and can be operated without crushing the program. Thanks. ...

Jquery: how to call the function again?

I'm making the script for easy upload many files. I've tried fyneworks plugin, but the file name does not appear in a form that uses tiny_mce. This is the code: $("document").ready(function () { var i = 0; //iteration for Inputted File var max = 5; //max file uploaded createStatus(); //generate status container $('.image...

What's the best way to tell if a file exists in a directory?

I'm trying to move a file but I want to ensure that it exists before I do so. What's the simplest way to do this in Perl? My code is like this. I looked up the open command, but I am not sure it is the simplest way or not. if #Parser.exe exist in directory of Debug { move ("bin/Debug/Parser.exe","Parser.exe"); } elsif #Parser.e...

python how to check file empty or not

I have text file, how check whether it's empty or not? ...