Words Myte Bite

Funny can be whatever you want it to be. The Words and Musings of Paul O'Malley. Sort of a Blog!

Archive for April 5th, 2011

05 April
Comments Off

Fun bits of Bash / Awk Shell Fun

Without going into the why’s I thought I would publish these few lines to amuse some of the people I know get the odd ping from this blog.

There are a long list of numbers in Subt, I want to get a running total (that is the awk bit).

Not only that but then I padded all the lines using printf  so that if they were not nine digits long they were padded in front of them.

cat Subt | awk ‘{s+=$1} {print s}’ | xargs  printf “%09d\n” > RunningT

Had I wanted a total then this would have worked:

cat Subt | awk ‘{s+=$1} END {print s}’ > FileContainingTotal

How to select a variable from a long list using a simple gui command.

(the file RunningT is several hundred lines long)

kdialog –menu “select your amount” $(cat RunningT) –geometry 700×400

(no I don’t know how to do that with zenity, or even if it can be done {yay for kludge})

Now if that is not enough fun, get a giggle at this one:

cat RunningT | awk ‘{ print FNR “\t” $0 }’ > foo

Yes folks we can add an  line number to the file RunningT and create a new file called foo for no good reason.

The ways you can do this are many.

Cut lines off top of file three of them and park them somewhere.
head -n3 SourceForComputation > HeaderPrep

tail does the other end of the file

One of the problems I had with this little adventure was to insure that specific content was always placed in the the file but it could be scattered around the place (I would be splitting the file later)

You can use sort, however that might put your data in a strange place.

So grep for that special_data to extract it  and redirect it to a holding file.

Fine how do you remove specific data from a file so you don’t duplicate your processing of it?

grep -Ev What\ I\ Want\ Removed  File-to-remove-data-from > Result

 

(woops I had first published this as Ve)

and we get a Result

Anyway that was just a few notes on the fun parts of processing data using bash and awk

05 April
Comments Off

Improv

Went back to improv classes for the first time in a long time last night. Great craic.

It is a little like riding a bike, you remember when you get back to it how it went.

Enjoyed it!

 

05 April
Comments Off

The Strange Adventures Of A Pixel

(Just because someone wanted to know!)

 

What is a pixel?

It is a single spot which can represent any colour within the bounds of physics for the device.

How can we understand pixels?

Firstly let us think of some units of measurement:

kilo K 1 000

mega M 1 000 000

However in Computers:

1024 is a kilobyte (kB), 1024 x 1024 is a megabyte (MB)

(mibibytes MiB in binary 220 same size as a MB, not an SI measurement)

In Cameras to find the Dots per inch we use this formula:

Resolution = Print Size

Dots Per Inch

With colour about 250 dots per inch is about the minimum amount of dots that are needed for the human eye to see before an image begins to look a bit broken up and made of squares.

(It might be useful to think of being close to a Monet picture.)

A Nikon chart for some cameras has some Megapixel cameras with these pixel sizes:

Megapixel Resolution of Camera
10.75 3872 x 2592
12.9 4228 x 2848
16.9 4928 x 3264

So what can you reasonably expect with a portrait shot on the 10.75 Megapixel camera.

Can we do a 16 x 24 inch? To find out we must calculate the DPI.

(DPI) We calculate the Values of X and Y as below.

3872 / X= 16              (Answer X= 242)

2048 /Y = 24              (Answer Y= 85)

So 242+85 = 327 DPI This would call a good quality picture to look at, as for it’s content that is a whole other story.

(Note this is printing portrait from a landscape shot, we would get a better score had we taken the shot as a portrait !)

However the same camera printing to 32 x 48 inches would give 168.5 DPI you will see squares!

 

Want your own copy of this a PDF:

TheAdventuresOfAPixel