vl4kn0 17 Light Poster

The answer is pretty lame :D The var __attr should be in __init__ method that's all

vl4kn0 17 Light Poster

Hi, I have got a little problem with __setitem__ method. It works fine in single class, but if class member is instance of the same class method __setitem__ doesn't work on class member but on class. Here is an example:

Here is a class with __setitem__ method:

class MyClass:
	attr = {}
	
	def __setitem__(self, key, value):
		self.attr[key] = value

and here i work with the class

>>> obj = MyClass()
>>> obj['key1'] = "value1"
>>> obj.attr
{'key1': 'value1'}
>>> obj.newinstance = MyClass()
>>> obj.newinstance.attr
{'key1': 'value1'}
>>> obj.newinstance['key1'] = "value2"
>>> obj.attr
{'key1': 'value2'}
>>>

as you see __setitem__ on newinstance works with self.attr from parent class. How can I hack this?

vl4kn0 17 Light Poster

on 36. line you have fp = open(argv[2], "r"); it should be fp = fopen(argv[2], "r");
Else you have declared variable char line[MAXSIZE]; but you don't use it in your code.

thanatosys commented: great help on a simple problem. +1
vl4kn0 17 Light Poster
#include <stdio.h>
 
int main(void)
{
	int sec_code;
	scanf("%d", &sec_code);
	
	while(sec_code < 1 || sec_code > 4) {
		printf("Ivalid value entered. Must be 1 to 4, please re-enter: ");
		scanf("%d", &sec_code);
	}
}

No if statement, no break. Is it what do you want?

vl4kn0 17 Light Poster
#include <stdio.h>

int main(void)
{
	int sec_code = 0;
	while(sec_code < 1 || sec_code > 4) {
		scanf("%d", &sec_code);
		if(sec_code < 1 || sec_code > 4) {
			printf("Ivalid value entered. Must be 1 to 4, please re-enter: ");
		}
	}
}
WaltP commented: A WHILE loop is not a POSTtest loop +15
vl4kn0 17 Light Poster

Ou. Yes of course should be $vardata. Thanks for correction. But I can't edit my post after 30 minutes :(

vl4kn0 17 Light Poster

In my opinion is much better tu use something like this:

Template.class.php:

<?php

class Template
{
	private $tpl_data = array();
	private $file;
	
	function __construct($filename)
	{
		// Load file into $file var
		$this->file = implode('', @file($filename));
	}
	
	public function assign($vardata)
	{
		// Load var array into $tpl_data
		foreach($vars as $key => $value) {
			$this->tpl_data[$key] = $value;
		}
	}
	
	public function run()
	{
		// replace {$key} into $value
		foreach($this->tpl_data as $key => $value) {
			$this->file = str_replace('{' . $key . '}', $value, $this->file);
			echo $this->file;
		}
	}
}

?>

template.html

<html>
  <head>
    <title>{TITLE}</title>
  </head>
  <body>
    <h1>{WELCOME}</h1>
  </body>
</html>

show_page.php

<?php

$tpl = new Template("template.html");
$tpl->assign(array(
	'TITLE' => 'Just a test',
	'WELCOME' => 'Welcome on our pages'
));
$tpl->run();

?>
vl4kn0 17 Light Poster

Gentoo, becouse is very fast and flexible. Portage is using USE flags for compilation software so I have in my distro only what I need.

vl4kn0 17 Light Poster

hmm. advice? good luck :P
by the way, fedora core 2 is too old :) try fedora 9

vl4kn0 17 Light Poster

Has someone here got posix specification? It would be in PDF format. Thanks

vl4kn0 17 Light Poster

You should reboot your system and in Grub or Lilo load kernel with parameter init=/bin/bash. Then you have root permissions but system will be for reading only. So you write command:

mount -o remount,rw /

. It remount your system for writing and you can run script passwd and change root password:

passwd root
vl4kn0 17 Light Poster

if you are working in linux and have acpi support you can open for reading file /proc/acpi/battery/{YOUR_BAT}/info. There is some info about laptop battery.

vl4kn0 17 Light Poster

do you run this script as owner of this home directory? or you can try chmod 777

vl4kn0 17 Light Poster

you must have installed alsa-base alsa-utils alsa-oss and if you have that, run alsaconf and then add yourself to group audio "adduser usre_name audio" after that run alsamixer for setting of volume

vl4kn0 17 Light Poster

if you have on one line only one value for example
1
2
3

to = open("file2", "w")  #open file for write mode
fp = open("file", "r")  #open read for write mode
for line in fp.readlines():   #read file 'file' for lines
	if int(line) <= 22 and int(line) >= 10:  #if value on line is smaller as 22 and bigger as 10
		to.write(line + "\n")  # write to file 'file2'
to.close() # close file 'file2'
fp.close()  # close file 'file'

and if you have name of acid and value for example
name_of_acid 1
name_of_acid 2
you can do that like this

to = open("file2", "w")  #open file for write mode
fp = open("file", "r")  #open read for write mode
for line in fp.readlines():   #read file 'file' for lines
	if ' ' in line:
		name, value = line.split(' ')  # split current line on name of acid and value
		if int(value) <= 22 and int(value) >= 10:  #if value on line is smaller as 22 and bigger as 10
			to.write(name + ' ' + value + "\n")  # write to file 'file2'
to.close() # close file 'file2'
fp.close()  # close file 'file'
vl4kn0 17 Light Poster

Thats right. You must allow it in your php.ini file. If you don't have access to this file you can try function ini_set().

vl4kn0 17 Light Poster

xampp is good choice. it contains php/perl, mysql, apache2 of course, proftpd etc... and if you want console based mysql client you can download apache-server. if you have debian based distro you can only type "apt-get install mysql-server apache2 mod-libapache-php5" thats all :)

vl4kn0 17 Light Poster

I'm using fluxbox right now and I'm glad for that. It's very easy to use and configuration is not very difficult. On google are many manuals how to configure fluxbox.

vl4kn0 17 Light Poster

I had Ubuntu and it realy is not way. Debian is good choice. But 1CD debian is useless. I prefer debian netinstall and if you will have any problems google is good, or you can try slackware, it is conservative distro but it has a lot of comments in configuration files.

lio04 commented: Very well dude! +1
vl4kn0 17 Light Poster

I don't know if I understand correct but you can try something like this

$sql = "SELECT COUNT(t1.id) AS music, COUNT(t2.id) AS videos, COUNT(t3.id) AS something_else FROM table_name1 t1, table_name2 t2, table_name3 t3 WHERE ...";
$result = mysql_query($sql);
$row = mysql_fetch_object($result);

and now you can call $row->video, $row->music etc as num of records in table...

vl4kn0 17 Light Poster

def Step: must by def Step(): and else I don't know :)

vl4kn0 17 Light Poster

do you have a dial-up connection, USB modem or something else? if you have USB modem and you want connect with ppp deamon you must remove BRLtty. or you can try setup automatic assignment IP adress from DHCP

vl4kn0 17 Light Poster

lol. i don't understand your question, but you can download ethereal(wireshark) it is good packet sniffer with gui ;)

vl4kn0 17 Light Poster

You can go on

http://hotscripts.com

and take a look around there for some scripts ;)

vl4kn0 17 Light Poster

FreeBSD is unix based OS. Linux isn't OS. It's only kernel ;) based on minix. and if you don't know that, so you haven't skillse for work with FreeBSD ;) in my opinion you can try Debian for example..