Library takedown

The new reading list:

Maximum Security: A Hacker’s Guide to Protecting Your Internet Site and Network — I wonder what the last chapter I read was last time I checked it out hehe.

Upgrading and Repairing Servers — I’d love to learn more and it’s got some stuff that interests me a lot on the bare hardware-level.

Learning Java, Second Edition — Useful because the book I own on Java was published ~1996.

The TCP/IP Guide: A Comprehensive, Illustrated Internet Protocols Reference — Probably will put me to sleep but is useful to have on hand, should I have time to read it.

Linux® Programming Bible — Old (2000’ish I think) but worth a thumb through in case I learn any thing I missed from it. I think it even includes a basic unix shell in the code listing, which is nice because one of my projects was trying to implement a bare bones shell in ruby.

Not counting indexes, glossaries, or appendixes (one of which as A-D I think): There are 4746 pages in all !

Counting every books last page with a pg# on it, we have 5381 pages total !!!

FreeBSD + Java?

How easy is it…

The JDK and JRE packages on the FreeBSD Foundation require the following to install and run correctly:

inputproto-1.4.2.1, javavmwrapper-2.3, kbproto-1.0.3, libICE-1.0.4,1, libSM-1.0.3,1, libX11-1.1.3,1, libXau-1.0.3_2, libXdmcp-1.0.2, libXext-1.0.3,1, libXi-1.1.3,1, libXp-1.0.0,1, libXt-1.0.5, libXtst-1.0.3, pkg-config-0.22, printproto-1.0.3, recordproto-1.13.2, xextproto-7.0.2, xproto-7.0.10_1, xtrans-1.0.4

If you run a Desktop based system with Xorg installed most of these are probably already there, on my laptop which has KDE 3.5.7 for the GUI all I had to do was install one package first:

pkg_add -r javavmwrapper

If you don’t have a required package it will tell you what you need to install when you try to pkg_add Java. Most probably can be pkg_add -r’d unless you want to the ports.

I then went over to the FreeBSD Foundation website to download Java

If you only want to run Java programs, you will need the JRE (Java Runetime Environment) but if you wish to develop Java programs you’ll require the JDK (Java Development Kit).

The packages currently are for FreeBSD 5.5/i386 and FreeBSD 6.1/i386 and amd64. Just download the one that matches your FreeBSD major branch and CPU Architecture. I fetched both JRE and JDK for FreeBSD 6.1/i386 which is about a 70MB download combined, my Laptop runs PC-BSD v1.4 so the underlaying system is FreeBSD 6.2-Stable, no problems so far.

You need to accept the license agreement to download and when you pkg_add, just scroll to the bottom and type ‘yes’ and press enter, you can probably use the shift+g command to jump to the bottom of the license.

I think because of the terms that the JRE/JDK were licensed for distro we’ve got to live with the manual download. Once you’ve got your packages downloaded, just do a :

pkg_add ./diablo-jdk-freebsd6.i386.1.5.0.07.01.tbz

of course replacing ./ with the path (if necessary) and the filename with the proper one. Tip: If you don’t want to typo it, use tab completion in your shell. I usually just download things to /tmp and cd over to it. You also need to be root in order to run pkg_add with any possibility of success. Depending on ones shell a ‘rehash’ command might also be needed before the programs can be found in the command prompt.

which tells me that java and javac are working, and it passed the test of compiling a small test program and running it.

I’m exausted…. Tonights a night I feel like just sleeping, but I know then nothing would ever get done…. Thats how I end up staying up til around 0400 and having to be to work by 1000… After enough years it takes it’s toll I guess.

I’ve broken out my old Java source book to see if it might be able to use it for a SAS project I’m working on.. I was figured I would just use Ruby and place the classified parts into a C Program. I can make the C program make very darn sure that it is “The” authorized ruby script that it passes information to. But then I remembered that there are ways of out witting that with Ruby. And just counting on end-users lack of technical exbertise would kinda be stupid, because other wise they could just have the info… Since my prefered way of doing it in C/C++ would require replacing the Ruby prototype with a C++/QT4 program, that means it would have to be under the GPL, a license I don’t like but one I can live with (ISC and X/MIT licenses are more my style). I was planning on making as much of the code available as possible any way. But using a compiled language would just make it much safer and more effective, if I didn’t need a program to call it and try and make it ‘secure’ enough, much easier to just do it all in one spot… And I think Java would make it easier b/c I’m used to C/C++ and probably know Java syntax better then C++, even if I’m about 9 years out dated in Java haha!

Hey….. if only Windows built in ftp client was worth a flying fuck… hehe

Table of C keywords, by language standard

Traditional
auto
break
case
char
continue
default
do
double
else
extern
float
for
goto
if
int
long
register
return
short
sizeof
static
struct
switch
typedef
union
unsigned
while

C89 Standard
const
enum
signed
void
volatile

C99 Standard
_Bool
_Complex
_Imaginary
inline
restrict

I dunno why, but these past few weeks I’ve been having the strangest dreams =/

Extreme Sex and Perl programming…. Very strange combination for dreams lol.

What makes it all the more funky is Perl, is not a language I do much in. For the most part Ruby, C, and BourneShell make up most of the stuff I do. When I use Perl, it’s usually because I don’t know AWK and I’m to lazy to use any more |pipes in my command line.

I think odds are, if I had stuck with Perl when I had started learning it. It would’ve been my favorite language.

Reading Raider

A nice trip to the library…

C in a Nutshell -> Nice book, finished it in about 2-3 hours.

A Book on C -> I’m interested in some of the algorithms.

Learning Perl -> I have mixed feelings about working in Perl, but hey it’s a nice book.

PHP and MySQL for Dynamic Websites -> I really can use this… lol

Maximum Security: A Hacker’s Guide to Protecting Your Internet Site and Network -> So fat I’ll have to be restrictive in what I read of it. But a very interesting find indeed.

I know C, like I know English: I’m not terribly skilled at some of it but I know it well enough to use it. So I don’t really need to read most of the C books but theres some common algorithms discussed. That I’m interested in reading their implementations of; not to mention a brush up on Function Pointers, Variable-length arrays, and Unions -> I don’t think I’ve ever actually used a Union :/

Perl, I was learning at some point but gave up on it as boring. I like Perl for it’s syntactical style, it’s closer to what I’m used to. But I’ve rarely seen Perl at any great length. Feel beautify to me, it’s effective yes. Pretty, not often… but heck if it works use it!

If it’s some thing I’m not likely to use again or it’s a quickly on the CLI. I’ll usually not care if it’s understandable or well written. But when I do write a script; I kind of like to make it hard to foul up, easy to understand, and function well.

Code and Gems

On a whim, I started work on anew toy.

A ruby script to process in an M3U play list and output a track list in HTML (with some nice options and stuff too).

While I could probably find a script for amarok or google some thing to do it. I’ve been itching for some thing to sink my teeth in, thats not going to take years to do. To be honest, I’ve been going crazy…. Can’t stand not to have some program to work on, ether writing, debugging, configuring, or testing.

I’ve never really been the sort of guy, that could just sit down and say “Ok, we need to get result foo… So we’ve got to do bar to get it”. When I have most of what I’m doing formed in my minds eye, I can write it out. And kick it about till I make it work (usually). But if I just knock my head on the wall, I usually fail to figure out how to do the things in the middle. Unless my brain kicks into gear and figures out a nice overview $_$

Needless to say, I doubt I’d ever be happy playing with searching and sorting algorithms.. lol. To night, I’ve had a lot of fun. The program might not be one I’ll use much but the important thing is

  1. I’ve had fun working on it and
  2. It lets me learn more about the Language
  3. Enjoying working on a little some thing every now and then is my favorite way to learn the features, standard library/e.t.c, and memorize the syntax of the language

It’s been one of the rare times where I got a simple idea, a ruby script to take M3U files and spit out HTML track listings (simple and fancy/detailed). Sat down and started munching on the problem… step by step, without any real overview of how to do it.

When I worked on rf.c, a little program I made… Because using cat(1) to print an entire file to stdout instead of concatenating files annoys me 0.o

I had a lot of fun learning, it helped me get used to using GDB and writing C instead of reading for a change. but when I did rf.c, I had a pretty complete mental picture of the program before I ever started, I knew I’d want it to do x.y.z. And I knew how I would have to implement it more or less, before I started line one. With this toy, I had no idea what the heck I would be doing in Ruby other then I’d be dealing with strings and file paths.

So, it’s been a wonderful time just sitting and working as I go along… Hell when I do some thing. I test sections of it before I use it, make a prototype, fix the errors I can find, adopt it into a semi-finalized version. And work on it till it’s the best quality program I can make of it. So, whats the harm in playing with a toy? xD

Instead of having to sit down and create the blue print before hand !

0442 local, nearly 1000 Hours Zulu time… So I’m glad that I’ve only got a short run to work tomorrow and little need of waking up EARLY besides walking the dogs.. Ok, bed time !

Thursdays are always a pain

Well, even now that I’m not working usual hours on Thursdays… they are still nightmares. Most of the days been a collection of minor disasters of one sort or another.

I’ve managed to actually get two things done today… Just two worth noting.

Working on controlled pairs w/ the G3A3 in RvS, dealing with multiple targets, and my favorite. A quick double tap followed by a follow up to the head/neck to make sure they go down for good. The over riding rule I have in ammunition usage, is I keep firing till I can confirm the targets out of the picture. The first 2 rounds might get him, but I have no problem with firing a 3rd or 4th before they hit the ground. It might be a waste of ammo but if I’m not sure they are neutralised after my normal 2-3rnd burst. I’m shooting the target again! Just the same with multiple targets, Find the most threatening target, hit it, find the next, hit it. Rinse and repeat and keep firing till all targets are down or I’m wishing the game allowed me to throw the rifle at the tango ! I think having to deal with 2 or 3 tangos at once is important. You don’t really have time to make sure you kill any one on the first solvo…. I remember in F.E.A.R. I was pissed at always getting shot at by a bunch of Replicas trying to set up an Ambush. So when I started taking fire, I had enough of that crap. Grabbed my scattergun and came blitz’ing around the corner in Slow-Mo mode. Plugged one Replica with a shell, cycled over to the next and missed. Put a nice hole in the wall :/, no time to argue so I cycled back to the first with another shell as he dropped to the ground (kia) Cycled back to the second Replica again, took him down with a shot to stagger him as I dropped out of ‘Slow-mo’ mode. Then leaped into a nice Round-House that smashed the Replica’s skull on a near ledge in a very awkward way for a Video Game. A crazy and foolish assault but the game made for an interesting chance to engage multiple targets.

Also,

def edit_file( editor=nil, file=nil )

unless editor
if Platform::OS == :win32
#We need to dig in to the registry later
system( "notepad #{file}" )
elsif Platform::OS == :unix
if ENV['EDITOR']
system( "#{ENV['EDITOR']} #{file}" )
else
system( "vi #{file}" )
end
end
else
system( "#{editor} #{file}" )
end

end

I got to finish solving a little problem. How to figure out what OS the program is running on in order to adopt, e.g. notepad or vi as an editor of last resort. The Platform module from rubyforge gives us a decent way of finding out if it’s a Windows or Unix based system. I don’t have any access to a Mac… so oh well. :S

Later when I’ve got time, I want to see about pulling the systems default editor for .txt files from the registry, since $EDITOR is not useful on Windows NT. The snippet also shows some thing I really like about Ruby, the unless statement.

# For example, Ruby
unless 5 < 4
puts '5 is more then 4'
end


/* and in C which has no unless statement */
if ( !5 < 4 ) {
printf( "5 is more then 4" )
}

while I’ve never cared much for the if ( !expr ) bit in C, I learned to read it fine. In what reminds me of Perl, you can also do a bit of < code > unless expr on one line if you want in Ruby. What I like about the idea of an unless and until statement, is unlike if (!expr) and while (!expr), after a shit load of reading. It’s a little harder to miss the difference when it’s not dependent on seeing the ‘!’. One reason why I use parentheses the way I do, is I’ve found it much easier on the eyes. When I do have enough time. I find my self reading a lot, so when I’m half asleep and I’m trying to remember what I read 2,000 lines ago. It’s pretty dang easy to foul up and have to wait on the compiler to scream. I’m not lucky enough to be able to have both time to read code and to sleep… lol. I remember I once spent like a half hour trying to fix a program that wouldn’t build. The whole dang problem? Was just a comma instead of a period, some_struct,member instead of some_struct.member and after 3 or 4 hours of non stop working… I couldn’t tell the difference between the , and . with my font and tied eyes.

So needless to say, I like to keep in mind that I may not be functioning in a stable frame of mind when I do things. The less I can leave for my self to fuck up, the less I have to smack my self upside the head for not seeing in the first place.

While I’ve never claimed to be decent at it, C is my strongest language. There’s just some thing about C that gets me, like the ultimate balance to my tastes. With Ruby, I’ve found that the pace it allows me to maintain is to good to pass up. Just being able to open a new tab with irb in it; for testing short bits of code. Is so much faster then opening a new tab, writing a scratch file, compiling it, and screwing with it till it works. Before finally adopting it to make use of it in what ever I’m working on. I think theres actually an interceptor for C but I’ve never tried any thing but a compiler.

I’m used to C style syntax, I started learning with C++, not really a good choice but it worked. Java and Perl are pretty similar in the basics. When I found C, I fell in love :/ so I’m pretty used to the idea of having to deal with things when I have to. I know crap about PHP but it’s close enough to the languages I do know that I can get along ok. In Ruby the syntax is very different but it’s kind of nice. You even have the choice of { … } or do … end, I usually use do and end because I feel they fit in well with the syntactic style (imho).

When ever I write some thing, if it’s not short or a quickie I’ll never need again. I try to keep a few things in mind.

  1. That I know what the hell I did, when I haven’t worked on it closely in weeks or months
  2. That it’s fairly easy to understand whats happening
  3. That after you read it, you’ll probably get the jist of how it works. And hopefully what it does by reading the comments

I really hate when I start reading a function and it’s so deep. by the time I get to the functions ending ‘}’ I can’t even remember what the hell it was named — I’ve never written a routine that fat!! lol. When I can, I like things to fit on a screen/screen and a half’ish for what I need to see. If I can’t keep the routine down to a manageable size. I’ll usually write other functions in the module just to help it do it’s job. I’d rather follow the line of execution to another function to make a change, then have like another 40 lines to scroll past in search of it. Most of the personal conventions I have, are ether to make my self clear yet efficient without making it easy for me to screw up. I believe source code is meant to be read by humans and run by machines, in that order. If I think it makes it easier on the reader without much cost, I’ll do it. Thats probably why when I work on some thing, I do it in stages. I make a prototype and some test pieces, I learn from that. Then I adopt and apply it to the main section. Once it’s done and doing what I want it to do. I try to go back over it and see if I can improve its quality.

http://en.wikibooks.org/wiki/Ruby_Programming/Syntax

What a nice find hehehe.

I know the most about C syntactically, I even tend to think in terms of C when my brain tries to figure out how to deal with some thing. But I’d like to have the same grasp on Ruby as I do on C’s syntax. Get ride of those oh joy I need to fetch a language reference moments when I’m trying to do some thing.

Nerds log.

Been pondering a lot of stuff.

I’ve especially been trying to learn more about stacks, queues, lists, and stuff. And it makes me wonder about things we take for granted.

Like arrays for example. How I see an array, at least from a C perspective — personally I think languages like Ruby. That have arrays that don’t need to be ‘re sized’ on command must have implemented arrays in the language. As objects acline to a doubly linked list.

Generally (C like) when I look at an array. I think of it as a pointer and a block. A block of probably contiguous data in memory — its close together if not physically in hardware then as we may address it from software. And I see the array also as a pointer I can use to reference that block. That points to sections in that block of memory. Where each section is the start & end of a chunk of memory. e.g. the difference between ar[1] and ar[2] is [1] points to the start of the 2nd memory block of the array which is the end of the first. While [2] points to the end of the 2rd but the beginning of the 3rd.

Thus if all memory in an array. Had no padding to note and by incrementing or decrementing the memory address. Our point of reference would advance to the next mark. Sorta. If all addresses were in a fixed range of integers, say 0 – 10. address+1 or address-1 would move our reference to +/- 1 sector of memory. — Even if the physical hardware doesn’t address memory like so, it seems to me by the time we hit software we can run on the machine via an OS / run time it gets this way.

| 0 | 1 | 2 | 3 | 4 |5 | 6 | 7 | 8 | 9 | 10 |

To be honest, I don’t know how arrays are implemented. I expect it to be a simple bunch of blocks of memory close together or just a fat segmented block. Where an address reference’s marked points of it. In such a way that we have an abstraction in the language that,

for ( i = 0; i < MAXCNT; i++ ) {
do_something( ar[i] );
}

works, gets down to assembly code that makes just as much sense but is more complicated. Then down to hardware that knows what to make of machine code. And down to the physical machine to run it and a realm for electrical engineering or some thing.

When I think about functions. I tend to think of it as a block of memory with all the data it needs, like variables in its scope and what not. and a system of pointers that handle calling and returning. Like

ch = fgetc( fp );

I think it would allocate memory (I hear C is stack based?) for the function (fgetc), use a pointer to fetch that address (call the function). Set the pointer or another pointer or some t hing like that to the return value of the function. Run the code their some how work it out so what the called function returns is what ch contains when references in memory. To me a variable is just a name for a value.

foo = 5;

To me says instead of typing 5 every where, I’d like to be human and just talk about foo instead. And let you (computer) fill in the value the name points to. Or some thing like that any way.

And in a similar light that I’d want to use ‘ch’ as a reference to the data returned by fgetc(fp) rather then have to know what the freaking location in memory it has !

Ok, so maybe I’m talking out of my ass or maybe I’m getting smarter as time goes on. Who knows…