How do you change the desktop picture in cocoa/objective-c? I've tried using defaults but had many errors.
NSArray *args=[NSArray arrayWithObjects:@"write",@"com.apple.desktop", @"Background", @"'{default = {ImageFilePath = \"~/desktop.jpg\";};}'", nil];
NSTask *deskTask=[[NSTask alloc] init];
[deskTask setArguments: args];
[deskTas...
I remember reading an article a while back that had a sentence that stuck in my head. First of all, I don't remember if it was about unix or linux, but it was about an operating system.
The phrase that got stuck in my head was that the license the guy who started the project chose was good because it kept the project intact because the...
I have a folder with files named as
input (1).txt
input (2).txt
input (3).txt
...
input (207).txt
How do I rename them to
input_1.in
input_2.in
input_3.in
...
input_207.in
I am trying this
for f in *.txt ; do mv $f `echo $f | sed -e 's/input\ (\(\d*\))\.txt/input_\1.in/'` ; done
But it gives me
mv: target `(100).txt' is not a d...
$ cat weirdo
Lunch now?
$ cat weirdo | grep Lunch
$ vi weirdo
^@L^@u^@n^@c^@h^@ ^@n^@o^@w^@?^@
I have some files that contain text with some non-printing characters like ^@ which cause my greps to fail (as above).
How can I get my grep work? Is there some way that does not require altering the files?
...
ProcessBuilder pb = new ProcessBuilder("pwd");
pb.directory(new File("/server1/work/uz/rt/adapt/0/"));
Process s = pb.start();
I expected the output to be /server1/work/uz/rt/adapt/0/, but instead it's:
/work/uz/rt/adapt/0/
/work/uz/rt/adapt/0/ and /server1/work/uz/rt/adapt/0/ are equivalent (mounted at the same place,/work/.. is co...
Hi all.
I'm trying to write own jabber bot on c++/gloox. Everything goes fine, but when internet connection is down - bot thinks that it's still connected, and when connection is up again - of course bot doesn't respond to any message.
Each time since bot is successfully connected gloox' recv() returns ConnNoError, even if interface is...
From what I can see Gearman does not support scheduled jobs or delayed jobs. I was thinking that perhaps the scheduled job could be queued in at first and then added to the Gearman queue after the at time period has expired.
at tasks are persistent as they are written as files to a directory in the spool directory of the server. So the ...
hi!
i have one CDR generator. I'm using one default application to generate reports on daily Basis. Application can generate sequence numbers from 0000 to 9999 then again starts with 0000.
In this case,
DAY 1 :
START FILE NO : 0000
END FILE NO : 2999
TOTAL FILES : 3000
DAY 2 :
START FILE NO : 3000
END FILE NO : 5999
TOTAL FILES : 30...
I found the following bash script in order to monitor cp progress.
#!/bin/sh
cp_p()
{
strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
| awk '{
count += $NF
if (count % 10 == 0) {
percent = count / total_size * 100
printf "%3d%% [", percent
for (i=0;i<=percent;i++)
...
Hi,
I have the below program to obtain current date and time.
int main(void)
{
time_t result;
result = time(NULL);
struct tm* brokentime = localtime(&result);
printf("%s", asctime(brokentime));
return(0);
}
And the output of the program is as follows :
Tue Aug 24 01:02:41 2010
How do I retrieve only the ...
I'm running Python 2.6 on a FreeBSD machine, and I would like to do (and I don't know the correct term for this) two-stage authentication against an active directory.
Basically, the process to log in user 'myuserid' is:
Bind to the AD LDAP server using a system account created for this purpose (call it DOMAIN\gatekeeper)
Verify myuser...
Hi,
I am trying to put together a portable set of files/scripts that will enable me to mimic a unix like environment on Windows.
I do not want to install anything. The setup needs to be able to live on a thumbdrive for example. Currently I am using UnxUtils to provide grep, and more. Im adding these to the Windows PATH environment vari...
How to do "sudo apt-get install " on OSX?
...
as an replacement for ksh under cygwin, pdksh might be the only choice. but look like there have a bug for cygwin : pdksh(5.2.14-3) to support backslash path (\).
it will swallow the \ :
$ cd .\access
pdksh: cd: /cygdrive/e/.access - No such file or directory
After search on the internet, the same problem solved for other platform. b...
I've got a webserver that I'm presently benchmarking for CPU usage. What I'm doing is essentially running one process to slam the server with requests, then running the following bash script to determine the CPU usage:
#! /bin/bash
for (( ;; ))
do
echo "`python -c 'import time; print time.time()'`, `ps -p $1 -o '%cpu' | grep -vi ...
I installed postgresql via MacPorts. However, going to /opt/local/lib/postgresql84/bin I am unable to execute any of the pg commands. Does anyone know what I am doing wrong?
Thank you.
...
I have looked at the source code of Apache Commons FileUtils.java class to see how they implement unix like touch functionality. But I wanted to confirm with the community here if my use case would be met by the implementation as it opens and closes a FileOutputStream to provide touch functionality
We have two webservers and one common ...
Currently there exist package like gonzui (example of the implementation here)
for doing source code search.
Is there a similar package that does the same thing except for simple file search.
Basically I have two list of files for file type A and file type B. When the user type a word
in the search box, all files (in "gz" format) wit...
EDIT 1
I'm having problems using the arguments given. Maybe it is the way I'm passing my arguments through NSTask? Any suggestions as to how I can do this?
NSTask *file_Task = [NSTask new];
[file_Task setLaunchPath:@"/usr/sbin/lsof"];
[file_Task setArguments:[NSArray arrayWithObjects:@"+p", the_Pid, nil]];
Good Afternoon Fellow Cod...
Just out of curiosity, what is the preferred way to achieve interprocess synchronization on Linux? The sem*(2) family of system calls seem to have a very clunky and dated interface, while there are three ways to lock files - fcntl(), flock() and lockf().
What are the internal differences (if any) and how would you justify the usage of e...