Vendo Sony Vaio VGNW235D/Pink




Equipped with an Intel Pentium Duo Processor, 4GB system memory, a 15.5" high definition LCD display and the latest wireless technology, this Sony VAIO handles everything from rich digital entertainment to your day to day tasks. It features a sophisticated new design and all new Windows 7 Home Premium for a smoother and faster user experience.

Mfr. Part Number: VGNNW235DP
Base Features
Approximate Battery Life Up To 4 Hours
Hard Drive Speed/Capacity 320 GB (5400 RPM)
LED Backlit Display No
Optical Drive 8x Super Multi Double Layer DVD±R/RW
Processor Speed 2.1 GHz
Processor Type Intel Centrino Pentium Duo T4300
RAM 4 GB
Screen Size 15.5"
Graphics
Discrete Video Memory No
Expandable Video Memory No
Graphics Chipset Intel GL40 Express
Integrated Video Memory Yes
Native Screen Resolution 1366 x 768
Upgradable Video System No
Video Memory 1750 MB
Audio
Audio Chipset Intel High Definition Audio
Audio Output Stereo
Digital Input Yes
Digital Output Yes
Hardware Volume Control Yes
Integrated Amplifier Yes
Integrated Microphone Yes
Microphone Input Yes
Speaker Wattage Information Not Available
Speakers Yes
Inputs/Outputs
Card Reader Yes
Card Reader - Compatible Memory Types MS Pro Standard/Duo; SD
Composite Output No
ExpressCard/34 Input Yes
ExpressCard/54 Input No
HDCP Compliant No
HDMI Port No
IEEE 1394 Input/Output 1
IR Receiver No
Number of Touchpad Buttons 2
PC Card Input 1 ExpressCard/34 Slot
S-Video Output No
Type of Keyboard QWERTY - 86 Keys - Bilingual
Type of Modem Not Applicable
Type of Pointing Device Electro-Static Touchpad
USB 2.0 3
VGA Output 1
Webcam Yes
Networking
Ethernet Port 10/100/1000
Integrated Bluetooth No
Integrated WiFi 802.11 b/g/n
Power
Battery - Capacity 3600 mAh
Battery - Number of Cells 6
Battery Type Lithium-Ion
Computing Features
Processor Cache 2 MB L2
System Bus 800 MHz Front Side Bus
Software
Loaded Software 1 Click To Disc Editor
Loaded Software 2 VAIO Movie Story
Loaded Software 3 VAIO MusicBox
Loaded Software 4 VAIO Media Plus
Operating System Language Bilingual
Pre-loaded Operating System Windows 7 Home Premium 64-Bit
Accessories
Headphones No
Remote No
Product Features
Notebook Depth 27.00 cm
Notebook Thickness (closed) 3.81 cm
Notebook Weight (including Battery) 2.9 kg
Notebook Width 36.02 cm
Warranty Labour 1 Year
Warranty Parts 1 Year

FEATURES:

  • An Intel Pentium Duo processor T4300 and 4GB system memory deliver impressive processing speeds and all the power you need to efficiently multitask and enjoy your digital media
  • Watch video in HD and be more productive with a 15.5" widescreen LCD display
  • Store your documents, video, music, pics and more on the 320GB hard drive
  • Burn your own DVDs up to 8.5GB in size with the 8X SuperMulti DVD+/-R/RW drive with dual layer support
  • A built-in 1.3 megapixel MOTION EYE camera and microphone lets you video chat, shoot video footage and snap pictures
  • 802.11 b/g/n wireless LAN lets you surf the net in any open hotspot and enjoy vastly enhanced wireless performance when connected to an 802.11n network
  • Integrated memory card reader (Memory Stick PRO Standard/Duo and SD compatible)
  • This model comes equipped with Windows 7 Home Premium 64-bit
  • Sophisticated design with subtle textured finish

Please Note: This product contains both English and French operating instructions and system software. In this context GB or Gigabytes refers to 1 Billion Bytes. The actual formatted capacity will be less.

Some space for rambling

Folks, I know I've been quiet here lately - in part because I was writing for Suite101, in part because I moved to Canada and back, and who knows - maybe I'll move to Canada again some day... anyway, I really feel like writing a bit about my personal feelings about the world around me for a change. So if you subscribe to my feeds or check my front page from time to time, you will see:

  1. Posts about things that are not technical
  2. Posts in Portuguese

You may be asking yourself why I don't set up a separate blog, and the reason is: because that's who I am - a technical person who also has thoughts of things other than programming that I'd like to share.

Please be patient as I will try to write in both Portuguese and English, and I promise I'll do my best not to bore you to death.

Cheers,
Vinny

O bem contra o mal na visão da matemática

Aviso: Este post apresenta meu ponto de vista sobre um dos aspectos do Cristianismo. É recomendado que se tenha a mente aberta ou então que nem prossiga na leitura. Não sou contra Cristo - pelo contrário, simpatizo com diversas religiões, Cristãs e não Cristãs. Apenas não concordo 100% com o que está escrito na bíblia.

Introdução

Um tempo atrás comecei a assistir à série "Dexter", que é sobre de um inspetor de criminalística que no seu tempo livre gosta de matar serial killers que escapam da justiça. Isso me fez pensar sobre toda a questão de bem versus mal, nossa história desde tempos imemoriais e a situação do cotidiano. Minha conclusão é a seguinte: Deus em sua infinita sabedoria nos deu a matemática. E é na matemática - mais especificamente na multiplicação - que podemos usar nossa lógica (também nos dada por Deus) e chegar à conclusão que "dar a outra face" pode não ter sido exatamente o que Jesus quis dizer quando esteve aqui e foi assassinado por nós.

Passamos por diversos terrores através dos tempos - do império romano, da horda de mongóis de Gengis Kahn, passando pela inquisição e mais recentemente o holocausto - a maioria (?? talvez todas) das vezes por motivos de poder e controle das massas.

Uma que me chamou a atenção foi da igreja católica e a inquisição que matou tantas e tantas pessoas das formas mais horrendas. Quando penso nisso, lembro daquela parte da biblia onde diz que Jesus "deu a outra face" e nos ensina a fazer o mesmo. Por mais que tente, isso é algo que eu simplesmente não consigo engolir. E quando coloquei todos esses pedaços juntos, me ocorreu que a vida e a matemática são muito parecidas em um determinado aspecto.

Das Leis da Multiplicação

Vejamos: considere que o bem e boas ações sejam equivalentes a números positivos (são atos positivos, certo?), e que o mal e atos violentos sejam equivalentes a números negativos.

Cenário 1:
Dona Maria participa de uma campanha de arrecadação de alimentos não perecíveis que serão doados às comunidades pobres da região (um ato bom, portanto um número positivo). Sr. João a ajuda na arrecadação dos alimentos (outro número positivo, que quando aplicado à Dona Maria se potencializa)

Conclusão: Um ato positivo, quando aplicado a outro ato positivo resulta em coisas positivas.

Cenário 2:
Dona Maria participa de uma campanha de arrecadação de alimentos não perecíveis que serão doados às comunidades pobres da região (um ato bom, portanto um número positivo). Um dos donos do tráfico de drogas da região prefere que a favela onde ele se esconde continue a passar fome para que dependa dele cada vez mais e manda matar Dona Maria (um ato obviamente negativo). Várias famílias passaram fome por causa desse ato negativo.

Conclusão: Um ato/número positivo quando multiplicado por um ato/número negativo é sobrepujado e o resultado é negativo. O negativo SEMPRE vence.

Cenário 3:
Dona Maria participa de uma campanha... bla bla bla... e o bandido encarregado de matá-la recebe ajuda de outro bandido (ajuda = um ato positivo) para dar cabo do serviço.

Conclusão: Positivo quando aplicado a um Negativo resulta em um negativo ainda maior.

Cenário 4:
Dona Maria participa de uma campanha...bla bla bla... e o traficante manda matá-la pelo motivo descrito no Cenário 2. No entanto, quando ele está prestes a cometer o ato, um policial entra em cena e mata o traficante. Lembremos que violência é característica negativa e o policial provavelmente terá que responder a inquérito para constatar que este extremo realmente foi justificado. No entanto, em nosso ponto de vista, esta característica negativa quando aplicada à negatividade do traficante que estava prestes a matar Dona Maria resultou em Dona Maria conseguir fazer sua campanha e ajudar a várias famílias.

Conclusão: Um número negativo quando multiplicado por outro número negativo resulta em um número positivo!

Nesse post usei o mesmo exemplo para todos os cenários, mas posso pensar em muitos mais que vejo no dia a dia. Até mesmo a censura que por muito tempo foi vista como algo negativo está tendo um papel de auxílio à negatividade. Elaborarei mais sobre isso em outro post.

Das Autoridades Bandidas

Dependemos das autoridades para nossa proteção. Concordo que não podemos sair por aí matando tudo quando é gente que nos parece ser bandido. Afinal, podemos estar errados e assim sendo geraríamos um resultado negativo. Não, não podemos nos arriscar a isso. As autoridades têm como obrigação nos proteger tanto nas ruas contra ladrões, estupradores, etc., quanto nos tribunais contra estelionatários e criminosos de colarinho branco. No entanto, alguns bandidos agem como lobos em pele de cordeiro e se infiltram na polícia ou viram advogados de defesa mesmo sabendo que seus clientes são culpados. Estes entes negativos podem ser enquadrados em uma categoria ainda pior de negatividade. Eles usam seu status de autoridade e potencializam ainda mais a negatividade do mundo.

Conclusão

Se todo o mau fosse erradicado do planeta da forma que fosse, o resultado seria positivo. A idéia de que devemos dar a outra face e perdoar me soa demais como estratégia de uma entidade dominadora (encaremos - o mau domina nosso mundo hoje) para que seus dominados não se revoltem. Duvido muito que Jesus tenha nos mandado dar a outra face. Mandou-nos amarmos uns aos outros, mas fica difícil amar o bandido que violentou uma menina na frente do namorado e depois os matou... Fica ainda mais difícil amar o advogado ou juíz que não prendeu o bandido por que ele não foi pego em flagrante.

Auxílio Retenção – infelizmente não é piada

Há muito tempo estou desgostoso do Brasil. Para piorar a situação, recebi um email umas duas semanas atrás falando sobre o Auxílio Reclusão (carinhosamente alcunhado de Incentivo à Bandidagem).

A princípio achei que era piada, mas para a minha decepção, não é piada não.

Resolvi tocar no assunto com minha mãe, que é defensora ferrenha desse país ao avesso, achando que finalmente ela enxergaria a pouca vergonha que é isso aqui. Bobo eu - ela como sempre acha uma desculpa para apoiar tudo que acontece aqui: "Ah, mas o filho do bandido não tem culpa se o pai dele é assim." O que ela deixa de ver é que em primeiro lugar filho de bandido não é filho, é empregado e infelizmente aprendiz. Empregado pois passa os dias nas esquinas pedindo esmola, e aprendiz por ser esse o modelo de pai que ele tem. Tentei contra-argumentar que se o bandido pensasse que a família morreria de fome caso ele fosse preso e não houvesse a pensão, ele pensaria duas vezes em fazer o que faz. Como a excelente argumentadora que é, respondeu que bandido não dá a mínima pros filhos (e nisso a gente concorda, dada a visão de empregado/aprendiz mencionada acima).

Perdi o round - mas continuei pensando a respeito. Hoje a Caixa abre conta para quem não tem renda e faz empréstimo de R$200,00. Peraí - digamos que o bandido tem uma conta na caixa e vai preso. A família recebe a pensão (que, pelo que fui informado, é de R$600,00) e precisa depositar em algum lugar. Depositando na conta do bandido, de quem é efetivamente o dinheiro?? Se os filhos de bandidos não têm culpa de terem os pais que têm, então por que é que eles têm que sofrer por isso? Que sejam adotados pelo serviço social e colocados em um ambiente melhor! Talvez com essa possibilidade de perder o empregado/aprendiz, o bandido venha a pensar duas vezes antes de fazer bandidagem.

Quem é que pode acreditar que este país vá melhorar enquanto direitos humanos de bandidos (independente de idade - se tem idade pra matar, tem idade pra pagar por isso) forem mais importantes que os direitos humanos das vítimas e suas famílias?

As músicas e a TV nacional tendem a idolatrar o bandido que precisa "lutar" por sua sobrevivência. Pena não mostrarem que a "luta" do bandido incide diretamente sobre a "luta" do cidadão de bem/classe média que se mata de trabalhar para alimentar a família. Afinal, rico anda de helicóptero, tem carro blindado e anda com segurança armada até os dentes. São as classes média e baixa que alimentam o bandido.

Uma mudança de direção

Pessoal,

Até hoje meu blog tem sido principalmente em inglês e voltado ao público técnico. Como tem acontecido muita coisa não técnica ultimamente, resolvi também compartilhar isso com vocês. Prometo tentar não matá-los de tédio e acho que muitos vão se identificar com o que estarei escrevendo.

Um abraço a todos

Vinny

I’m now on Suite101.com!

Hey folks!

I'd like to announce that I've debuted on suite101.com. My first article there was how to optimize your job hunting using RSS feeds.

Check out the article here.

Introduction to Ajax

In this article, I provide an explanation of Ajax with a historical introduction. If you are eager to start seeing the code, please scroll down.

 

What’s Ajax?

 

Ajax stands for Asynchronous Javascript And XML. It’s a way to call back-end scripts asynchronously – that is, without impacting user experience/flow. Basically, you don't even see the cursor become an hourglass or whatever other "waiting/processing" icon your system uses. It's not a language, but a technique. As for back-end scripts, you can use whatever you feel more comfortable with: PHP, Perl, Java, JSP, Shell, C, etc. The way to choose which technology to use as back-end is not outside the scope of this article.

 

Historical approach for calling back-end apps

 

Throughout web-development history, the very first way used to achieve back-end processing followed by front-end display was to create a form and set the back-end script as the action to that form. Upon submission, the form fields would be sent to the back-end script as a series of special environment variables, which would then be handled by the programmed logic. The back-end output would be displayed on the screen (either the same page/frame or a different page/frame, depending on the target attribute of the form).

The catch 22 of this approach is that if you want to present another form after processing, that form must be produced by the back-end script, which leads to maintenance mayhem – to add or remove a field, you have to do so in both the original HTML and in the HTML of the back-end script.

Continue reading...

PHP+PDO+MySQL: How I’m doing it and a question…

I recently decided to rewrite an application that I created for an English school where I used to work, and this time I want to do it right. I chose to write it in PHP with Object Orientation in mind, and use PDO+MySQL for the DAO portion.

The reason for using PDO is that it's the closest thing to the DBI that I found for PHP - and the reason for PHP is that it's just plain simpler than using pure Perl, and I don't have the time to learn Catalyst or some other Perl Web framework.

Anyway, here's what I'm doing for the PDO portion.

First I created a Db class which is just a DB connection wrapper.

<?php
class Db{

	public $dbh  = null;

	public function Db($db_type,$db_host,$db_user,
			         $db_pass,$db_base,$tbl_prefix){

		if ($db_type == 'mysql') { // in case I want to add oracle in the future

			$mysql_DSN = "mysql:host=".$db_host.";dbname=".$this->db_base;

			try {
				$this->dbh = new PDO($mysql_DSN, $db_user, $db_pass,
							   array(PDO::ATTR_PERSISTENT => true, PDO::ERRMODE_WARNING => true,
							         PDO::ATTR_ERRMODE => true));

			}
			catch(PDOException $e){
				$rc[msg] = $e->getMessage();
				die($rc[msg] . "  " . __LINE__);
			}

			return $this->dbh;

		}

	}

}
?>

Secondly, I created the DAO classes which extend the DB. They are responsible for prepare'ing and execute'ing the queries, and returning the data. Here's an example one (I stripped some bells and whistles in order to not confuse anyone):

<?php
class StudentsDao extends Db {

	public $sth = array();

	// Constructor
	public function StudentsDao($db_type=NULL,$db_host=NULL,$db_user=NULL,
				  	       $db_pass=NULL,$db_base=NULL,$tbl_prefix=NULL) { // These params are to be passed to Db class

		// Connect to DB
		$this->Db($db_type,$db_host,$db_user,
			      $db_pass,$db_base,$tbl_prefix);

		// Prepares queries
		$this->sth = $this->prepare($tbl_prefix); // Look at prepare() further down

	} // end of function StudentsDao

	// Function that prepares queries
	public function prepare() {

		$sth = null; // will hold our temporary array

		// get all students
		$string = sprintf('select * from %s.%sstudents where id = ?',DB_BASE,TBL_PREFIX);	// I have these constants defined in the main page
		$sth['getStudentById'] = $this->dbh->prepare($string);

		// update Student by Id
		$string = sprintf('update %s.%sstudents
				   set field1 = ?, field2 = ?, field3 = ?
				   where id = ?',DB_BASE,TBL_PREFIX);	// Note that this table has 3 control fields (id, sys_creation_date, and sys_update_date)  prior to field1, field2, and field3 - I don't want them to be touched

		$sth['updStudentById'] = $this->dbh->prepare($string);

		return $sth;

	} // end of prepare()

	// Here we have the handlers for the queries prepared above.

	// Fetches all students
	public function getStudentById($id) {

		$s = $this->sth['getStudents'];
		$s->execute(array($id)) || die(print_r($s->errorInfo,1));
		$result = $s->fetchAll(PDO::FETCH_ASSOC);

		if (sizeof($result) == 0) {
			// no data found
			$out[err_cd] = 1;
		}
		else {
			// data was found
			$out[err_cd] = 0;
			$out[data] = $result;
		}

		return $out;

	}

	// Updates student by Id - this is a tricky one
	public function updateStudentById($data,$id){ // $data can have data regarding one or more fields

		// Populate current fields
		$fields = $this->getStudentById($id); // get current values

		// Remove unwanted fields
		$fields = array_slice($fields[data][0],3); // remove the 3 initial control fields

		// Replace with new fields
		foreach($data as $k=>$v){
			$fields[strtolower($k)] = $v;
		}
		$fields['id'] = $id;

		$s = $this->sth['updStudentById'];
		$s->execute(array_values($fields)) || die(print_r($s->errorInfo,1));
		$count = $s->rowCount();

		if ($count == 1) {
			$out[err_cd] = 0;
		}
		else {
			$out[err_cd] = -1;
		}
		$out[err_msg] = $this->status[$out[err_cd]];
		return $out;

	}
?>

In the example above, you will probably frown on the fact that I'm calling getStudentById() at the beginning of updateStudentById(). It's OK - I frown on it, too. Let me explain why I did that:

I wanted to be able to pass the function an associative array containing only the fields I want to update - be it only field1, or field1 and field2 and so on. But I wanted to do that against my already prepared query, and not touching any additional fields. In my application, students table has a BUNCH of fields. In other words, update any given field or set of fields using the single prepared statement, without having to set ALL the fields in $data

My original idea was to basically, to emulate something like this:

update students set field1=field1, field2='some new value ', field3=field3 where id = 1

That would set field1 to whatever value field1 already had.

Here's the question part:
Unfortunately, I couldn't figure out how to do that using the PDO (how to bind a field name instead of a value against the ?-mark). If you know how to do that, do leave a comment explaining how! :D

The technique shown in the example will basically pull all values from the record and populate them in the $fields array. The array_slice() is used to remove the control fields that I have in my table, and the rest gets compared against the $data array and if any matching fields are found in $data, those fields get their values assigned over the existing $fields values.

Ajax: Form fields into URL query string

Here's a quickie for you Ajax coders who need a function to parse your form fields into a URL query string. It handles input fields (text, hidden, whatever), radio and checkbox elements, and single/multiple select menus. Just make sure that all your form fields have IDs. Multiple choice SELECTs get grouped by pipes (|). Update:Modified multiple-choice SELECTs to work like real GETs.

function build_post_string(frm) {

	var poststr;
	var poststr_array = [];

	if (!frm.id) {
		// assume it's a string. get the form object
		frm = document.getElementById(frm);
	}

	for (i=0;i<frm.elements.length;i++){

		var elem = frm.elements[i];

		if (!elem.id) {
			// skip any fields that don't have IDs
			continue;
		}

		if (elem.type == 'radio' || elem.type == 'checkbox') {
			// only grab radio buttons and checkboxes that are checked
			if (!elem.checked) {
				continue;
			}
		}

		// get select values
		if (elem.nodeName.match(/SELECT/i) && elem.multiple) {
			//var sel = elem;
			var sel_array = new Array();

			for (var o=0;o<elem.options.length;o++) {

				if (elem.options[o].selected) {
					sel_array[sel_array.length] = elem.id+"="+elem.options[o].value;
				}
			}

			var sel_str = sel_array.join('&');

			// build key/value pairs for SELECTs
			poststr_array[poststr_array.length] = sel_str;
		}
		else if (elem.nodeName.match(/SELECT/i)) {
			poststr_array[poststr_array.length] = elem.id+'='+elem.options[elem.selectedIndex].value;
		}
		else {
			// build key/value pairs for everything else
			poststr_array[poststr_array.length] = elem.id+"="+elem.value;
		}

	}

	// build poststr
	poststr = poststr_array.join("&");
	return poststr;

}

Perl: Installing DBD::Oracle + Oracle Instant Client on Ubuntu 9.04

A couple of weeks ago I finally got a new laptop at work - which meant of course that I had to reinstall everything. Although we use Windows XP, there's one app that I have to run through Linux. The solution was Sun's VirtualBox running Ubuntu 9.04. When I tried to run the app, I realized that I still needed to install DBI and DBD::Oracle - which brings me to this article. Nothing better than a reinstall to generate article material :)

DBD::Oracle is usually a pain to install if you haven't already done it a gazillion times. After that, it's just an annoying itch. In this article I'll cover installing DBD::Oracle using Oracle Instant Client, Ubuntu 9.04, and Perl 5.10. Since we're using the Instant Client, you'll need some Oracle DB you can connect to in order to do the testing. You can choose to skip testing altogether, but you might be into a surprise later. Continue reading...