I'm currently writing a small script for use on one of our servers using Python. The server only has Python 2.4.4 installed.
I didn't start using Python until 2.5 was out, so I'm used to the form:
with open('file.txt', 'r') as f:
# do stuff with f
However, there is no with statement before 2.5, and I'm having trouble finding ex...
Hi,
I have built a win application with C# framework 3.5 sp1
When I publish the project and install it on other machine (with framework 3.5 sp1)
I get "application attempted to perform an operation not allowed by the security policy..."
After learning about this a bit I found two leads:
"Administrative tools-->microsoft
.net configu...
Hello stackoverflow,
I have a data file of almost 9 million lines (soon to be more than 500 million lines) and I'm looking for the fastest way to read it in. The five aligned columns are padded and separated by spaces, so I know where on each line to look for the two fields that I want.
My Python routine takes 45 secs:
import sys,time
...
So, that's it. How can I write to a text file using AppleScript?
I've tried googling around, but answers seem to be years old and I'm not really sure what should be the preferred idiom this days.
...
I have two functions:
lowerString :: [Char] -> [Char]
lowerString = filter (/='_')
upperString :: [Char] -> [Char]
upperString [] = []
upperString (x:xs)
| x == '_' = x : upperString (tail xs)
| otherwise = ' ' : upperString(xs)
If I apply them on "_A_B_CDEF":
upperString "_A_B_CDEF" would return ___
lowerString "_A_B_CDEF...
Is there a common interface for cin and file input?
I want to make a program that has an optional parameter
prog [input-file]
If an input file is specified, then it should read from the file, and if not, it should read from cin.
From what I can tell, they both implement istream. How would you set up it so that I could do something l...
How can I seek (change the position) of a ByteArrayInputStream (java.io)? It is something so obvious, but I can't seem to find a method for this anywhere (mark/reset is not enough, I need to set the position to anywhere on the InputStream).
If it can't be done using java.io and I must switch to java.nio and use a ByteBuffer, how can I g...
I am writing a terminal emulator in ruby using the PTY library. /dev/tty0 is a device file connected to a keyboard. I am spawning the shell like this:
shell = PTY.spawn 'env TERM=ansi COLUMNS=63 LINES=21 sh -i < /dev/tty0'
It mostly works, but when a subprocess is started in the shell, shell[0] is not outputting the keyboard input to ...
In our application, we expect user input within a Thread as follows :
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
I want to pass that part in my unit test so that I can resume the thread to execute the rest of the code. How can I write something into System.in from junit?
...
How to get list of files that a program is working with?
For example, if a program is downloading something, how can I know what and where that file is while downloading?
...
var fsw = new FileSystemWatcher(sPath, "*.PPF");
fsw.NotifyFilter = NotifyFilters.FileName;
fsw.IncludeSubdirectories = true;
fsw.Created += FswCreated;
fsw.EnableRaisingEvents = true;
static void FswCreated(object sender, FileSystemEventArgs e)
{
string sFile = e.FullPath;
string[] arrLines = File.ReadAllLines(sFile);
}
this fail...
I have a file that contains about 200,000 long values that I want to read as fast as possible into a long[]. It's for an Android app; function calls are slow (so anything involving reading a long at a time with a "for" loop will be super slow) and I need loading to be fast. What can I use? Everything I look at seems to read only bytes fa...
Most of the IO operation requires try catch block or throws . Why is try catch or throws not required for System.out.print or println. If there is any exception inside these methods how would i know whats the exception and how to catch it.
...
Hello!
I am working on a personal project involving sending simple signals from my computer to a circuit via USB. Basically I am using the USB signal as the gate signal for a MOSFET which will in turn activate a relay to turn on/off various AC peripherals. For example if I want to turn on a light bulb for 5 seconds every minute I would ...
Since side-effects break referential transparency, don't they go against the point of functional languages?
...
hello guyz i have been trying to create a directory in sdcard programatically but it always showing me directory not created.
my code is this.
boolean success = (new File("/sdcard/map")).mkdir();
if (!success)
{
// Directory creation failed }
Log.i("directory not created", "directory not created");
...
I created an Android app that serves the touch screen sensor data to a java client that is listening on Debian Lenny machine.
The client maps this data to locations on the screen just like a wacom pad does. I would like to out put the x_loc and y_loc to a file and have the file recognized as a device.(I foggily believe this is how it is...
If I open a a file as os.open( '/dev/ttyS2', O_RDWR | O_NDELAY ), is there any way that I can check when my 'write()' commands have finished? Or, can I open a file for non-blocking read but blocking write?
...
How to read and write to binary files in D language? In C would be:
FILE *fp = fopen("/home/peu/Desktop/bla.bin", "wb");
char x[4] = "RIFF";
fwrite(x, sizeof(char), 4, fp);
I found rawWrite at D docs, but I don't know the usage, nor if does what I think. fread is from C:
T[] rawRead(T)(T[] buffer);
If the f...
I'm writing a Java server which uses plain sockets to accept connections from clients. I'm using the fairly simple model where each connection has its own thread reading from it in blocking mode. Pseudo code:
handshake();
while(!closed) {
length = readHeader(); // this usually blocks a few seconds
readMessage(length);
}
cleanup();...