I just wrote the following line of code as part of an implementation of a bucket sort.
Somehow I feel wrong inside about it. Look at it, it’s fairly complicated. In the context of the program you could work out what it was doing, but the effort would be made easier if it was rewritten as this.
int temp = ( array[j] / static_cast( pow(10.0, y) ) ) % BUCKETS;
Just splitting up that nasty math part from the method call clear up a bit of the ambiguity of what the line is doing, and the next version is even better.
// Returns a set number of digits from an
// integer in the array, based on the number
// of buckets and the current iteration.
// For example:
// array[j] = 123456;
// y = 4;
// BUCKETS = 100;
// temp = 12;
int temp = ( array[j] / static_cast( pow(10.0, y) ) ) % BUCKETS;
While this doesn’t really tell you whats going on, it can lead you to finding the pattern involved. That pattern is described thus:
For an integer N, the digit X positions to the left of the least significant digit is: (N/10^X)%(10^Y) Where Y is a “look-ahead” to retrieve the next-Y digits as well.
Thats my informal definition mix for base 10 numbers, derived from a few dozen minutes of fighting with bc. I could put this information into the program, and then deciphering it’s workings would be a snap. But why? I mean, I’m never going to use this again, and if I need to, I worked it out the first time, the second shouldn’t be any harder. How much documentation is too much? How much is too little?
I hate bloated files, sources that are so filled with comments you never see any code. I think (like many before me) that code should be self-documenting as much as possible. I don’t belive in using in-line comments. They get in the way and don’t often help. But I’ve also always thought you shouldn’t break out the comment blocks for anything that wasn’t “serious”, so do I lower the definition of a “serious” comment, or do I throw away my would-be in-liners?
I suppose this is one of those things that comes with time, but I’ve tried to maintain old code before, that someone else wrote with zero comments, and it’s impossible. I think I’ll err on the side of caution, for whoever comes after me.
Bah! I’m sick of C++. Now that I’m learning Java, C++ just seems lame. Then again, I haven’t done any C++ in about a year, so I’m not terribly sharp on that front. I spent a good two hours just wandering through my old books trying to remember how to do things like class specification files and the like.
On the other hand, it took maybe an hour to write an assignment for my Java class, add in extra features to the class, do exception handling and learn enough about Ant to create a build file to handle compiling for me. Oh, and I wrote a shell script and a batch file to launch them jar.
I’m almost afraid to turn in the version I ended up with. The assignment said to not bother with exception handling, so I’m not sure if all that other stuff would make me look like a know-it-all. I’m not, it was just fun to do all the other stuff and learn the basics of it. Whatever. back to my C++…
This article is in response to a Facebook posting about Facebook “selling” personal information through their developers section. I originally tried to post this on facebook, but it has restrictive message limits, so here it is in it’s entirety. (Pardon the spelling and such, I wrote this is in a rush.)
This is the posting I found on the Facebook site, verbatim:
IMPORTANT! EVERYONE MUST READ THIS-
With all the new changes, Facebook has adopted a “Facebook Development Platform.” Basically, it allows Facebook Inc. to sell any information on you to anyone. This includes your picture, hometown, current location, interests, political views, musical preferences, relationship status, etc. Pretty much anything that you enter on Facebook is sold. The best part is that you are AUTOMATICALLY ENROLLED! They didn’t even tell us! I’m pretty sure Facebook thought they could get away with nobody noticing it since everyone is so overloaded with this new news feed/mini feed junk. If you don’t believe me, check it out for yourself in the Facebook Terms of Service. It’s black and white.So screw them, to remove yourself from the “Facebook Development Platform” follow these instructions:1. Log in to facebook.
2. Click “My Privacy” on the left edge of the window.
3. Under the network, “Everyone” click “edit settings”
3. Scroll to the bottom of the page to the heading “Facebook Development Platform” and uncheck the statement that says “My information may be used according to the restricted Terms of Service.”
4. Click Save.
5. You have official thwarted facebook from whoring out your personal info to the highest bidder!Spread the news! Tell your friends to remove their name from the selling block. This is utterly disgusting!
First of all, they aren’t selling the information, they are exposing web services. What that means is that they’ve realeased API’s to let developers write applications to extend Facebook. The developers can’t access information about you unless you log in to the application they developed. Additionally all information passess through http://api.facebook.com/, which means the developers don’t have direct acess to your passwords, so they aren’t going to steal your account information that way.
Anyone seeking to develop an application has to apply for an API key, which doesn’t cost anything, but can uniquely identify, and allow for the immediate disabling of any application written to steal data.
From the Facebook API FAQ:
“Any content delivered to the outside application can be safely displayed to the user. However, in general, content delievered when using a session key should only be stored until that session key expires, or twelve hours, whichever comes later. The exceptions to this are user ids and affiliations information. This is detailed further in the accompanying documentation.”
The opening of these API’s and web services are a contribution to the Facebook society, and something they’re doing for free. Open source programming is a great benefit to end users, and these API’s and those of other sites allow the creation of rich, dynamic and integrated web applications.
If people take the time to read and understand whats going on with the system they can see that there is noting to “be afraid” of, and that their information is just as secure as ever. Which, I’ll admit, isn’t saying much. Social networking systems such as Facebook are hugely complex systems, and Facebooks should be applauded on their content control systems. They’ve added a at least a mediocum of security to the information on their system with a complex network of “friend” relationships. Compared to other sites, Myspace for example, the security of your information inside of Facebook is commendable.
That leads to the final argument here. Even though Facebook is releasing these API’s (which are a good thing) it’s all still in your control. As the post that first sparked this response says, you can opt out. And barring that Facebook, like other web services such as Flickr, Myspace, etc. is an opt-in. You signed up, if you don’t like it that much, unsubscribe.
I apologize if this was even slightly emotionally charged, I just don’t want to see a good thing ruined because of illogical fears.
Here are some links to help understand whats actually going on.
And here are some example applications built on the API.
Please read and consider these. If you find a posting on Facebook that goes against the new web services, post a link to this site! We could potentially lose a great number of wonderfull social services provided by clever programmers and the Facebook API’s!
This is a post from a previous system. Information, links and images may not be vaild.
Last semester I used the program KJots alot for taking notes in my computer classess. It’s a great program, but it had some glitches I didn’t like and was platform specific.
For a long time I had the notion of making my own similar program, either in nice portable Java or as a web technology. This afternoon I had about three hours between classes and whipped up a basic frame of the system. I skipped the “making it pretty” part since I was just getting it going. It needs that, plus you can’t save changes yet, but other than that it’s there. I’d finish it up, but I have class in about 10. Anyway, check out my demo/live version here. User is “[email protected]” and pass is “demo”. You can get a clean copy of the source at this link. Hopefully some of this code can be built into lucidGW, esp. the authentication code.
I spent a little time setting up VIM today, and thought I’d share my .vimrc. Most of these configs are from the beastly , but well documented, file at http://www.amix.dk/vim/vimrc.html. Mine’s a bit simpler, but it does what I want from it. Always been a VIM fan.
" John's VIM Config
" Turn off VI compat
"Set shell to be bash
" Lets use the mouse!
" This is the most important line here...
" Set font (GUI)
set gfn=Monospace 10
" Highlight Matching parens.
" Kill all those crummy swap/backup files
" Make tabs only 2 spaces
" Auto-indent / Smart-indent
" No more \a bells!
On other fronts, I start school again on Monday, which in itself partially prompted the VIM editing, since I wanted some highlighting on Java files andwasn’t getting it. This should be an interesting semester, since between my Java class (hehe..), data structures and my job I’ll be juggling the syntax for three or four languages at once. Good times.