Monday, January 5, 2009

BrainWyrms

random incoherence and infantile meanderings

Archive for the ‘codeplay’ Category

Muxtape is dead, long live Opentape

Posted by Nomad Scry On September - 4 - 2008

Muxtape was this weird little online analog (digital analog?) of the old mix tapes that we used to make with the dual decks.  But it is gone now.  At least for now.  The mafia side of the music industry is working on making them die now.  ”Muxtape will be unavailable for a brief period while we sort out a problem with the RIAA.”

But from the ashes, something must rise… right?  This time, it is a new opensource software program that enables practically anyone to -be- Muxtape.  It is called Opentape and pretty much all it takes to get running is a web host with PHP5 and an FTP client.  

So instead of everyone hosting their analogous mixtapes at one central location, now anyone so inclined can host their mixtape on their own site.  To see it in action, check out my BrainWyrms mix… Right at this moment, I’ve got Nine Inch Nails from Ghosts I.  I’ll probably add some other “open-source” music as I find it.

Share and Enjoy:
  • E-mail this story to a friend!
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Pownce
  • Digg
  • Slashdot
  • TwitThis

Bubble Sort: It Works! [C++]

Posted by Nomad Scry On February - 27 - 2008

Finally, a functional bubble sort.  And all I had to do was stare at someone else’s code to see what I was doing wrong.

And then stare at it some more.  And some more.  BLAH.

#include <iostream>

int sort[] = { 6, 3, 2, 5, 4, 1 }; // Curly braces - NOT brackets.
int i, x, y;
bool z; // didn’t work until after switching to bool NOT int
int elements;

int main() {
elements = sizeof(sort)/sizeof(sort[0]); // How many elements are we sorting?
do {
z = false; // swapper is false
for (i = 0; i < elements-1; i++) { // elements-1 was the single most important breakthrough
if (sort[i] > sort[i+1]) {
x = sort[i];
y = sort[i+1];
sort[i+1] = x;
sort[i] = y;
z = true; // Swapper is true
}
std::cout << i << x << y << ” - “;
}
} while (z); // while swapper is true
std::cout << “\n”;
for (i = 0; i < elements ; i++) { // so this should go display the sorted information
std::cout << i+1 << ” : ” << sort[i] << “\n”;
}
return 0;
}

At one point, I only had the do…while loop.  Before that I had only the for loop.  Of course, neither one by itself was doing what I wanted.  As soon as I saw that in my reference program, I slapped myself.

The next thing that seemed to make a big difference was when I went from

x = sort[i+1];
y = sort[i];

to

x = sort[i];
y = sort[i+1];

and I really just don’t understand why that would matter.  I saw the same thing in PHP when I was doing my stupid multi-dimension array for making mazes.  I do not understand why, but it seems to make a big difference.  Like, from it doesn’t work - to it does work.

Next up, I stopped using “z”, my swapper variable, as an integer.  I was under the impression that when evaluating an expression, a variable equal to null/zero is equivalent to false and one equal to one was also true.  That may very well be the case, but going over to using “z” as a boolean worked much better.

Then there was the big head slapper.  No, really, the BIG head slapper.  My for loop, set to the limit of “elements”?  Arrays count from 0, ‘cuz its binary.  Dur.  Dur duh duh!  So the limit should be set to “elements-1″.  So that it also will start from 0.  [seething angrily at self-stupidity]

But even at that point, I was getting a functional bubble sort that was stuck in an infinite loop.   And the reason that it was looping?  Because

} while (z = true);

and

} while (z);

have different meanings?  If my boolean variable “z” is true, how does “equals true” differ from  “is true”???  Well, as soon as I went to the second style … that’s when my bubble sort finally actually worked.  I don’t understand.

Share and Enjoy:
  • E-mail this story to a friend!
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Pownce
  • Digg
  • Slashdot
  • TwitThis

Bubble Sort in flux [C++]

Posted by Nomad Scry On February - 16 - 2008

I’ve started to hack into my marginally functional program … and I’m starting to think I’ve probably messed it up to the point of needing to start over from a clear slate. It doesn’t help that I haven’t bothered to look up the proper way to structure a “do…while”.

#include <iostream>

int sort[] = { 2, 3, 1, 5, 4, 6 }; // Curly braces - NOT brackets.
int i = 0;
int x = 0;
int y = 0;
int z = 0;
int elements;

int main() {
elements = sizeof(sort)/sizeof(sort[0]); // How many elements are we sorting?
do {
// I haven’t worked out the code for this one yet
if (sort[i] > sort[i+1]) {
x=sort[i+1];
y=sort[i];
sort[i]=x;
sort[i+1]=y;
z=0; // Set if change is made
}
else { z = 1; }
if (i < elements) { i++; }
} while (z = 0);
for (i=0; i < elements ;i++) { // so this should go display the sorted information
std::cout << sort[i];
}
return 0;
}

Share and Enjoy:
  • E-mail this story to a friend!
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Pownce
  • Digg
  • Slashdot
  • TwitThis

Bubble Sort [C++]

Posted by Nomad Scry On February - 14 - 2008

Last time, I said ::

int sort[] = { [10, 2, 8, 4, 6, 0] };  // elegiac pointed out that arrays need curly braces, I like square.  So I combined them.

And I was wrong.  I got a compile error that disappeared as soon as I removed my beloved square braces.

int sort[] = {10, 2, 8, 4, 6, 0};

works out just fine.

My main loop that moves things around seems to be working fine, I’m just only getting that single pass.  I’m trying to work out how to get a while to work for me, but for now… I’m happy with my single pass.

One thing elegiac had asked me was about the std::endl; that I had tacked into the program at the very end.  Testing it out showed me that it didn’t seem to make any difference at all whether I left it in or took it out.

At this point I am wondering if it makes more sense to keep thrashing at this or to look at my code samples and see how others have done this.  I’m certainly gaining a better understanding of how C++ feels doing it this way, but I think that the templating nonsense is still so far out of reach that I am not going to be able to thrash myself to an understanding of it.  I am going to need help.

I hate asking for help.

Share and Enjoy:
  • E-mail this story to a friend!
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Pownce
  • Digg
  • Slashdot
  • TwitThis

Bubble Sort again [C++]

Posted by Nomad Scry On February - 12 - 2008

 I’ve been busy doing the run around this week (AKA having a head cold), so I haven’t even had a chance to run this through the compiler yet… but elegiac and I have had a chance to step through the code again and see some blatant errors.

#include <iostream>
// namespace std; - I personally do not see the value in bringing the std into local.  So I’m not going to use it until I know better.

int sort[] = { [10, 2, 8, 4, 6, 0] };  // elegiac pointed out that arrays need curly braces, I like square.  So I combined them.
int i, x, y, z;
int elements;

int main() {
elements = sizeof(sort)/sizeof(sort[0]);  //  I think this will give me the number of elements within the array… I hope.
for (i=0; i < elements ; i++) {
if (sort[i] > sort[i+1]) { // Do I need to init (aka set to zero) my var holders for each cycle?
x=sort[i+1];
y=sort[i];
sort[i]=x;
sort[i+1]=y;
z=1; // Set if change is made
}
}
if (z) { // if change is made, run sorting cycle all over again
// I haven’t worked out the code for this one yet
}
for (i=0; i < elements ;i++) { // so this should go display the sorted information
std::cout << sort[i];
}
std::endl;
return = 0;
}

Share and Enjoy:
  • E-mail this story to a friend!
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Pownce
  • Digg
  • Slashdot
  • TwitThis

Bubble Sort [C++]

Posted by Nomad Scry On February - 10 - 2008

I’m working on my second C++ program. Baby steps here, as I am merely trying to implement a simple and dirty sort.This morning I wrote this out in longhand, and I haven’t debugged it or tried compiling it.

#include <iostream>

namespace std;

int sort[] = [10, 2, 8, 4, 6, 0];
int i, x, y, z;

int main() {

for (i=0; i < sizeof(sort) ; i++) { // I don’t know how “sizeof” works so….
if (sort[i] > sort[i+1]) { // Do I need to init (aka set to zero) my var holders for each cycle?
x=sort[i+1];
y=sort[i];
sort[i]=x;
sort[i+1]=y;
z=1; // Set if change is made
}
}
if (z) { // if change is made, run sorting cycle all over again
// I haven’t worked out the code for this one yet
}
for (i=0; i < sizeof(sort) ;i++)> // so this should go display the sorted information
std::cout << sort[i];
}
std::endl;
return = 0;

}

elegiac has previously suggested that I start out going straight to a template implementation - I just haven’t looked into it far enough to even rough draft anything. Now I needed to get this on my programming computer and see just how bad my code really is. Eeek.

Share and Enjoy:
  • E-mail this story to a friend!
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Pownce
  • Digg
  • Slashdot
  • TwitThis

Podcasts for the first weekend of 2009

Posted by Nomad Scry
Jan-4-2009 I 1 COMMENT

Podcasts for Wed Dec 31, 2008

Posted by Nomad Scry
Dec-31-2008 I ADD COMMENTS

Podcasts for END OF 2008

Posted by Nomad Scry
Dec-29-2008 I ADD COMMENTS

Podcasts for Xmas Week

Posted by Nomad Scry
Dec-25-2008 I ADD COMMENTS

Podcasts for Sun Dec 21, 2008

Posted by Nomad Scry
Dec-21-2008 I ADD COMMENTS
This site employs the Wavatars plugin by Shamus Young.