libraries for fetching stuff off the net, WinInet, libcurl

I used to use WinInet until now, had it wrapped around with some code that evolved over the years, t’was ok.

Then this other I suddenly had to send a packet out of a specific connection and guess what… WinInet doesn’t support that. Neither does WinHTTP (WinInet’s predecessor).

So, looking around I bumped into libcurl, which I’ve tried to ignore all these years. Why ignore ? well because it looks big, and when a piece of code looks big it’s hard for it to attract coders. The bigger the code is, the higher the changes of an unknown convention of programming.

Guess what, this is what it takes to do download something with libcurl:

CString urlopen(const TCHAR* url)
{
USES_CONVERSION;

CURL* c = curl_easy_init();
ByteBucket bb;

curl_easy_setopt(c, CURLOPT_URL, T2A(url));
curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(c, CURLOPT_WRITEDATA, &bb);
CURLcode success = curl_easy_perform(c);

bb.AddByte(0); // null-termination
return CString( A2T((char*)bb.GetData()) );
}

static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp)
{
ByteBucket* bb = (ByteBucket*)userp;
bb->AddBuffer((BYTE*)buffer, size*nmemb);
return size*nmemb;
}

Fantastic ha ? ByteBucket is a trivial class I wrote that helps with these sort of things.

So isn’t it funny ? fearing from having to deal with lots of curl code I ended up with lots of WinInet code, while eventually the libcurl code was much simpler to work with.

Conclusion ? Fear is a programmer’s worst enemy… I think.

My shot laptop just woke up

So a few good months ago my laptop got shot by a police robot.
When I write “shot” I don’t mean anything less than a live bullet puncturing my precious new IBM-T43p (yeah, the high-speed front-site-bus one).

So there I am with my shot laptop…
I took it to a gathering of techie friends called Kinnernet but nobody had time to fix it (including myself), so when I got back home I decided to fix the darn thing.

When the bullet pierced ‘my precious’, it took out the screen, the keyboard and the motherboard. Luckily enough, the part of the motherboard that was taken out was a mere fan. When attempting to boot the kiddo (with external screen/keyboard ofcourse) the BIOS complained only about the fan…

2 days and 30$ later I was sitting in front of the then-shot now-dismantled laptop preparing for the minor surgery.



my new baby running windows (nothing to be proud of :-)
That’s the lot.
The laptop is now a fully functional desktop computer, and a strong one.

Yossi suggested I sell it on eBay but I don’t know if it will really get a worthy price, after all it’s serving me well right now. Then again a laptop that survives a shot-of-death may be worth something to a collector.

I can be reached at ohadpr AT gmail DOT com
You can also visit 3D3R Software-Studios which is where I work.

Opera (Ope-רע)

i’ve been trying out Opera for a few days now, here are a few verbs i’d use to describe it:

  • funky
  • futuristic
  • hitek
  • cool
  • childish
  • immature
  • funny


pros:

  • rather quick
  • it’s just sorta cool


mega-cons:

  • no default bookmark toolbar
  • gmail is sometimes weird
  • i think text-area editing of all sorts is a bit messed up.
  • when a tab finishes loading it takes the focus by default, god this is annoying.


It doesn’t work to well for me with GMail, so I’m gonna dump it.
Talk about the kind of black and white math that plagues software.

1 / 0

(16:09:49) Michael Ring: So this $!@#! Officer there didn’t understand what i just said. I think she got a “division by zero” operation in her head after my words

Fractal Music

My bro’, elad, who’s been into music for some time now, came up with the idea of harvesting sound out of Fractals.
He was amazed with the vast richness fractals provided visually, and was sure we could get some interesting results from trying to translate these into the audio world.

Well, he was sorta right, 2 hours and 20 lines of Python later… we got some crazy results.

What we did was generate a Mandelbrot, and simply use the values of the Mandelbrot function as the MIDI notes. We spaced all the notes evenly for now.

Now when you generate music, you need to choose some path in the mandelbrot (or in any other 2D surface, that’s because music moves in 1D for now). We tried straight lines, but got lots of monotonous areas, that’s because the Mandelbrot is filled with them.
Following my bro’s suggestion we moved to a spiral (he’s hot for spirals too). We chose an area of the fractal that looks like a sun, with spikes comming out, and we simply spiralled out of it, now this gave some cool effects.

Here’s what the spiral looks like:


Here are some results:

psychadelic fall.mid

2.mid
elad.mid
1.mp3 (mixed by my bro’)

Here’s the Python source-code (requiures PIL and python-midi)

Since we like this idea, we’re gonna have a few more sessions over it, here are some future thoughts:
* spacing notes unevenly.
* determining cut-offs.
* analyzing the data we get, calculate deriviate, and move the whole thing faster when the funcntion moves slower in an attempt to get things more evened out.
* usng other functions/images.
* use the mandelbrot data to determine infor other than notes, perhaps cut-offs, distance between notes and length of notes.

Gots ideas ? bring em on1, bring em on 2