simple mp3 cover finder

very bad coding style, not finished
but i don't want to do it better.

1) find and download picture



require 'net/http'
require 'uri'
#require 'FileUtils'

def download_pic_by_str( str )
req_str = str.split(" ").join("+")

uri = "http://images.google.com/images?hl=en&client=firefox&rls=org.mozilla%3Aru%3Aofficial&um=1&sa=1&q=#{req_str}&btnG=Search+images&aq=f&oq=&aqi=g10&start=0ask_google.rb"
url = URI.parse( uri )
res = Net::HTTP.get(url)

ind = res.index('dyn.setResults([["/imgres?')
http_ind = res.index( "http", ind )
http_end = res.index( '\\' , http_ind )

uri = res[http_ind,http_end - http_ind]
puts "What image download: "+uri.to_s
file_name = uri[/([a-zA-Z0-9\-_])*\.[a-zA-Z0-9\-_]*$/]
puts "Result filename: "+file_name
url = URI.parse( uri )
res = Net::HTTP.get(url)
f = File.new("images/"+file_name,"wb")
f.print( res )
f.close
end

if __FILE__ == $0

if ARGV.size > 0
request_string = ARGV.join(" ")
else
request_string = "beatles let it be"
end
FileUtils.mkdir_p 'images'

download_pic_by_str request_string
end


2) this file should be runned, send search string to download function



require "get_mp3_tag"
require "ask_google_a_picture"
require "iconv"

ic_w_u = Iconv.new('WINDOWS-1251','CP866')
ic_w_u2 = Iconv.new('UTF-8','WINDOWS-1251')

mp3_name = "Give Me Some Love.mp32"
mp3_name = ic_w_u2.iconv( mp3_name )
puts "Mp3 filename :" + mp3_name

FileUtils.mkdir_p 'images'

request = mp3_name + get_str("mp3/#{mp3_name}.mp3")

download_pic_by_str( request )

3) generate search string phraze to mp3

require 'rubygems'
require 'id3lib'

def get_str( mp3_file_path )
tag = ID3Lib::Tag.new(mp3_file_path)
puts "Title: "+tag.title.to_s
tag.title.to_s+" "+tag.album.to_s+" "+tag.track.to_s
end


i paid for it about an hour.

Mac Os Snow Leopard updating message error

I found new error on new Mac OS X, hi integers! :)
On image:

firefox updating :)

NeuroArchivator updated.

Version 1.4.0.0
features:
[+] neuron w vector normalization possibility;
[+] benchmark possibility added;
[+] benchmark result added;

more about: normalization process increase stability, and corrects w vector from overflow.
what do we use to with normalization:
a) normalization W vector to each neuron, after each teach process;
b) normalization W vector after creating;
c) normalization inputted X vector (newX[i] = (2*X[i] / (max_color_value) - 1); // default max_color_value at RGB = 255;

results at git: http://reexperiments.indefero.net/p/NeuroArch/source/tree/master/

MIF, MID files on UNIX

MapInfo can use mif, mid formats on it's maps.
Today, i'd like to show how simple we can read this files (this file almost full copy of one of the example), but it really work with russian encoded mif-mid. End this file not se easy to find to.
So...

Let's meet "mitab" http://mitab.maptools.org/

This code open and fully read MIF, MID files.
Tomorrow i'll try to copy from cloudmade.com map of belarus, and create some simple example, that will show it.
But now an C++ example:


#include
#include
using namespace std;

int main (int argc, char * const argv[])
{
const char filename[] = "/Users/rilley_elf/maps/админ_центры_пл.mif";
mitab_handle map = mitab_c_open( filename );
if (map == NULL)
{
cout << "mitab_c_open failed. " <<
filename << mitab_c_getlasterrormsg() << endl;
return 1;
}
int fieldsCount = mitab_c_get_field_count( map );
int feature_id;
for ( feature_id = mitab_c_next_feature_id(map, -1);
feature_id != -1;
feature_id = mitab_c_next_feature_id(map, feature_id))
{
mitab_feature feature;
int feature_type, num_parts, partno, pointno;

feature = mitab_c_read_feature( map, feature_id );
if( feature == NULL )
{
cout << "Failed to read feature. "
<< feature_id << mitab_c_getlasterrormsg() << endl;
return 1;
}

feature_type = mitab_c_get_type(feature);
num_parts = mitab_c_get_parts(feature);

cout << "Read feature " << feature_id << ": "
<< feature_id << ". type=" << feature_type
<< ". num_parts=" << num_parts << endl;

for(int fieldno = 0; fieldno < fieldsCount; fieldno++)
{
char* name = (char*)mitab_c_get_field_name(map, fieldno);
char* str = (char*)mitab_c_get_field_as_string(feature, fieldno);
wcout << name << endl;
wcout << str << endl;
}
for(partno = 0; partno < num_parts; partno++)
{
int num_points = mitab_c_get_vertex_count(feature, partno);
if (num_parts > 1)
printf(" Part no %d:\n", partno);
for(pointno = 0; pointno < num_points; pointno++)
{
double dX, dY;
dX = mitab_c_get_vertex_x(feature, partno, pointno);
dY = mitab_c_get_vertex_y(feature, partno, pointno);

printf(" %.16g %.16g\n", dX, dY);
}
}
mitab_c_destroy_feature( feature );
}
mitab_c_close( map );
if( mitab_c_getlasterrormsg() != NULL
&& strlen(mitab_c_getlasterrormsg()) > 0 )
fprintf( stderr, "Last Error: %s\n", mitab_c_getlasterrormsg() );
return 0;
}

скачок евро на tut.by

fond of current task

today's work request ask me to understand how mplayer use win32codecs (windows dll's).

and this is awesome, i finally get to the moment where task is so cool, as possible.

i'm fond of my current job.

someone kill mplayer developers