Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×

Comment Shenanigans (Score 1) 172

This thing cannot work, unless they remove the iPhone's original lens, of which the article makes no mention. You simply cannot stack lenses like that. Compare it to what you see when you look (with your eye, which is a lens) through the rear of a lens. You see a round patch of light, not a whole view of the world. The iPhone would see the same thing. Also, if you _did_ remove the original lens, you'd end up with an enormous crop factor, turning every SLR lens into a very long tele. Try holding that steady with a mount like this. In short, I call shenanigans, get the brooms!

Comment Re:Correlation is not causation (Score 3, Funny) 366

Holland has an infection rate of "eventually 80%" (source: http://www.nvkc.nl/tijdschrift/content/1999/nr%201/p65/1999-1-p65.pdf ), which does eerily correlate with our soon-to-be world cup win. (Disclaimer: there are orange crowds singing outside after "our" win to Uruguay, and to Germany I would like to say, "Schade Deutschland, alles ist vorbei!" ;-)

Comment Use passphrases (Score 4, Interesting) 191

Passwords are the wrong solution. Trying to make people remember a short string with high entropy is hard, so people write them down. The other way around is much better - long passphrases with less of the tedious entropy. Quotations, lyrics, names, whatever. They're much easier to remember and much harder to brute-force. Sprinkle in some punctuation and you're golden.

Comment Well, as long as it's closeted... (Score 0, Flamebait) 1123

Well, as long as it's closeted, I don't care what safety blanket they need to survive the realities of life. Let them believe in Dog. But never, ever let them get away with fusing it into their science. Religion is at best "outside the realm" of science, which is a polite way of saying it's irrelevant to reality, which is a polite way of saying it's a harmful delusion. Fine with me if you live your life that way, but keep it to yourself.

Comment Re:Physics jokes are fun, but... (Score 3, Interesting) 150

Slashdot makes up for it by posting an X-Fry, X-Leela, X-bender or other header with every HTTP response. If you know it or not, you've received thousands of these witticisms (unless you're New Here.) X-Fry: Leela, Bender, we're going grave-robbing. X-Fry: Hooray, we don't have to do anything! X-Fry: I haven't had time off since I was twenty-one through twenty-four. X-Fry: How can I live my life if I can't tell good from evil?

Comment An equation with two unknowns (Score 1) 150

“I believe this ‘paradoxicality’ equation to be unsolvable,” he says, pointing to the equation, E=9.87sin(2B)-7.53cos(B)-1.5sin(B), written on a blackboard. “Ergo, time travel is impossible. But I can’t quite prove it.”

So the humor here is that it's paradoxical to want to solve a single equation with two variables? Or am I being too geeky here? After all, the solution is *trivial*...

Comment Nothing to see here, etc (Score 3, Informative) 148

So you post a form to an iframe by pressing a submit button, and the iframe reloads with new dynamic content? And this is somehow AJAX? The whole interesting thing with AJAX is that you can interact with the web server while staying on the same page. You can type something into a search box, say, and the webserver sends you back some matching words in real time. Sure you could mimic the same thing with a POST and a results page, but that is exactly the paradigm that AJAX was supposed to replace.

Comment Re:Off the top of my head... (Score 1) 411

You can check whether you're outputting to a terminal with test -t. If the output is not going to a terminal (say, to a pipe), you can print a plain vanilla string. You can output colour codes as straight ANSI escapes, or (probably better), use tput.

Example log function:


log() {
    test -t 1 && { tput setf 4; cat; tput setf 7; } || cat
}

dmesg | log

This tests whether stdout is a terminal, and if so, prints the text in red. Otherwise (if stderr is redirected to a pipe or file) it prints the plain string.

Comment Re:Nice example. (Score 3, Informative) 411

Thanks, it's nothing I couldn't show a fella. Learnt a lot from my colleagues and from the O'Reilly 'Unix Power Tools' book. The Advanced Bash Shell-scripting Guide is pretty good (but chaotic) too.

The syntax filter here munged some of the examples, though. The here document example will not work as-is, because there should be two 'less-than' signs in front of the minus sign. The mysql_query function probably also won't work (can't bother to run a test), because the newline after the first bracket mysteriously disappeared. So best to loop up the concepts in some kind of reference manual.

Comment Off the top of my head... (Score 4, Informative) 411

I work as a Linux netadmin and system developer, so I do a lot of shell programming in (ba)sh. Here's some of the niftier things you can do to a shell script:

- Make colored output with shell escape sequences. Works especially well with red type for error messages, makes them really stand out.
- Use inline functions a lot. The great thing about them is that you can pipe to them and use them in all kinds of places. For instance, to do mysql queries:

mysql_query() { /usr/bin/mysql --user=root --pass=topsecret database
}

echo 'SELECT * FROM accounts' | mysql_query

- "Here documents". For long MySQL sequences, something like the following (reusing the mysql_query function from above):

cat - EOF | mysql_query
      SELECT bar
      FROM foo
      WHERE baz ...
EOF

This lets you easily format stdin for scripts and other programs. Also really useful for outputting HTML and stuff like that. Best thing is that variables are expanded inside the block.

- The || and && operators. Check if a file exists, remove if so, else complain:
[ -f /tmp/somefile.txt ] && rm /tmp/somefile.txt || echo "Does not exist!"

Also common in this form:
[ -x /usr/bin/necessaryprogram ] || { echo "aaargh"; exit 1; }

- Making a "multithreaded" shellscript is also one of my favourites. Say, you want to start five virtual machines at the same time. Write a function that starts a vm, and call it a few times in a loop, backgrounding each instance with &, and saving their PIDs. Then have a "wait loop" that waits for the PIDs to exit the system (or for a timeout to occur).

- Proper argument handling with getopt. Have your script take "real" arguments in any order, just like real binaries.

This just scrapes the surface of the surface, of course. I learn new stuff every day.

Slashdot Top Deals

The hardest part of climbing the ladder of success is getting through the crowd at the bottom.

Working...