Friday, January 07, 2011

Bash: Find the Max in a list of Integers

Max is a little shells script that will find the maximum value and returns that value and the line it was found at.

while read line; do
ELE=$[ $ELE + 1 ]
if [ "$line" -gt "$MAX" ]; then
echo "$MAX $POS"

Usage Example
-bash-3.2$ cat ttt
-bash-3.2$ ./max < ttt
1000000000033 4

Hackers Find New Way To Cheat On Wall Street

From Slashdot:

"The high-speed trading exchanges that conduct the business of buying and selling stocks and mutual funds are so fast that hackers can introduce delays of a few microseconds completely unnoticed by today's network monitoring technology — and manipulate prices in the process to reap millions of dollars to the detriment of everyone else, InfoWorld's Bill Snyder reports. This kind of activity creates new reason to distrust Wall Street and shows how the computer networks we all rely on for conducting business and moving information are ripe for undetectable hacking."

Preserving Great Tech For Posterity — the 6502

From Slashdot:

"For great old hardware products like the MOS 6502 (used in the Apple II, the C64, the Nintendo NES), the details of the designs have been lost or forgotten. While there have been great efforts to reverse engineer the 6502 from the outside, there has not been the hardware equivalent of the source code — until now. As Russell Cox states: 'A team of three people accumulated a bunch of 6502 chips, applied sulfuric acid to them to strip the casing and expose the actual chips, used a high-resolution photomicroscope to scan the chips, applied computer graphics techniques to build a vector representation of the chip, and finally derived from the vector form what amounts to the circuit diagram of the chip: a list of all 3,510 transistors with inputs, outputs, and what they're connected to. Combining that with a fairly generic (and, as these things go, trivial) "transistor circuit" simulator written in JavaScript and some HTML5 goodness, they created an animated 6502 web page that lets you watch the voltages race around the chip as it executes. For more, see their web site'"

Monday, January 03, 2011

Update All Scripts in One Swoop

First this is old hat for most admins, so they will sigh a collective yawn.

Now, let's say, like me you have a couple of dozen scripts written in wish8.4 and you want to update all the scripts at once to wish8.5.

sed -i 's/wish8.4/wish8.5' *

  • sed - the classic stream editor in Unix (yes even linux and windows have it)
  • -i - option, edit "in-place", meaning don't output the result, just change silently
  • s /x/y/ - substitute y for x
  • * - command line glob
NOTE the last was for LINUX on BSD use -i .bak 's/....
(added 2011-01-30)