Arquivo de novembro, 2007

SUPERTESTES

Publicado: novembro 23, 2007 em Diversão


ENSINO FUNDAMENTAL

5ª Série do Ensino Fundamental
6ª Série do Ensino Fundamental
7ª Série do Ensino Fundamental
8ª Série do Ensino Fundamental

ENSINO MÉDIO

Funções
Domínio de funções
Função do 1º grau
Função do 2º grau
Função composta
Função inversa
Funções especiais
Inequações do 1º e 2º grau
Sistema de inequações
Inequações produto – quociente
Função modular
Exponencial – Equações
Exponencial – Função e inequações
Logaritmos – Introdução
Logaritmos – Propriedades
Logaritmos – Mudança de base e colog
Logaritmos – Equações
Logaritmos – Inequações
Progressão Aritmética ( PA ) – Termo geral
Progressão Aritmética ( PA ) – Propriedades
Progressão Aritmética ( PA ) – Soma dos termos e interpolação
Progressão Geométrica ( PG ) – Termo geral
Progressão Geométrica ( PG ) – Propriedades
Progressão Geométrica ( PG ) – Soma dos termos e interpolação
Matriz – Formação e igualdade
Matriz – Operações
Sistemas Lineares
Sistemas Lineares – Discussão
Sistemas Lineares – Homogêneos
Geometria dos sólidos – Poliedros
Prismas – Cubo e paralelepípedos
Prismas – Triangulares e hexagonais
Pirâmides
Cilindros
Cone
Esfera
Análise combinatória – Princípio multiplicativo
Análise combinatória – Fatorial ( ! )
Análise combinatória – Arranjos
Análise combinatória – Permutações
Analise combinatória – Combinações
Probabilidade
Binômio de Newton 01
Binômio de Newton 02
Binômio de Newton 03
Introdução à Geometria Analítica ( GA )
GA – Distância entre dois pontos
GA – Ponto médio
GA – Coeficiente angular e equação da reta
GA – Posições relativas entre retas
GA – Área de polígonos
GA – Distância entre ponto e reta
GA – Circunferência
GA – Posições relativa entre ponto e circunferência
GA – Posições relativas entre reta e circunferência
GA – Lugar geométrico
Polinômios
Polinômios – Operações
Equações algébricas – Teorema da decomposição e Teorema d’Alembert
Equações algébricas – Teorema das raízes racionais e complexas
Equações algébricas – Relações de Girard
Números complexos – Adição, subtração, multiplicação e igualdade
Números complexos – Conjugado, divisão e potências
Números complexos – Módulo
Números complexos – Forma polar ou trigonométrica
Números complexos – Multiplicação, divisão e potenciação na forma trigonométrica
Números complexos – Radiciação e exponencial na forma trigonométrica

Sendo C=A+B
relação: Cij=Aij+Bij

Tabela

|  10  5  |        | 1   15 |        | 11   20  |
|  7  22  |  +   | 7   2   |  =    | 14   24  |
| -3  14  |       | 3   4   |        |  0   18   |

A resolução deste problema tem um ponto em comum relação ao anterior,já que todos os elementos das matrizes
devem ser acessados

constante N_LIN = 3;
N_COL = 2;
tipo Matriz_3x2: vetor [N_LIN, N_COL] de real;
Soma_Matriz(A, B: Matriz_3x2; ref C: Matriz_3x2): neutro
var i,j:inteiro
inicio
para (i <- 1,i <= N_LIN;i <- i + 1) faça
para (j <- 1,j <= N_LIN;j <- j + 1) faça
C[i,j] <- A[i,j]+B[i,j];
fim

DICA: MATRIZ –> para a turma de LPA

Publicado: novembro 23, 2007 em algoritmo

Vetores  bidimensionais  ( MATRIZES )

Entendendo

Primeiro exemplo lógico

constante N_LIN = 2;
N_LIN = 3;

tipo Matriz_2x3: vetor [N_LIN, N_COL] de real;
Lê_Matriz_Versão1(ref M: Matriz_2x3): neutro
início
escreva(“Entre com o elemento – Linha1, Coluna 1: “);
leia(M[1,1];
escreva(“Entre com o elemento – Linha1, Coluna 2: “);
leia(M[1,2];
escreva(“Entre com o elemento – Linha1, Coluna 3: “);
leia(M[1,3];
escreva(“Entre com o elemento – Linha2, Coluna 1: “);
leia(M[2,1];
escreva(“Entre com o elemento – Linha2, Coluna 2: “);
leia(M[2,2];
escreva(“Entre com o elemento – Linha2, Coluna 3: “);
leia(M[2,3];
fim

Bom, neste primeira representação,é de fato inadequada,pois é extremamente trabalhosa.O que de fato iria ter que ser feito basicamente tudo na ‘ unha ‘,isto é,como ficaria para vc manipular uma matriz do tipo 100×100 que seria no caso uma matriz com 10.000 elementos ? É claro que é inviável este tipo de implmentação.

Para resolver o problema teremos de fazer uma manipulação de dois índices simultâneos: um para a linha e outro para a coluna.
Como toda a matriz será lida,teremos que acessar todos os elementos,para isto a estratégia seria varrer todos os elementos de cada  linha por vez.

Uma segunda opção seria criar um laço para tratar o índice das colunas.

Segundo exemplo lógico

constante N_LIN = 2;
N_LIN = 3;

tipo Matriz_2x3: vetor [N_LIN, N_COL] de real;
Lê_Matriz_Versão1(ref M: Matriz_2x3): neutro;
var i : inteiro;
início
para (i <-1; i <= N_COL;i <- i + 1 ) faça
início
escreva(“Entre com o elemento – Linha1, Coluna”,i);
leia(M[1,i];
fim
para (i <-1; i <= N_COL;i <- i + 1 ) faça
início
escreva(“Entre com o elemento – Linha2, Coluna”,i);
leia(M[2,i];
fim
fim

Bom,agora esta implementação ficou bem melhor que a primeira,mais continua apresentando repetição de procedimentos feitos de forma manual.Isto faz com que a abordagem seja inadequada para o caso,imagine uma matriz 100×100.O laço da leitura da coluna seria feito 100 vezes,se tornado algo inviável.

A solução FINAL seria criar um laço para  as linhas.

EXEMPLO

para (i <- 1,i <= N_LIN;i <- i+ 1) faça
início
{ código para tratar a linha }
fim

Então teremos um algoritmo final assim,USANDO 10.OOO ELEMENTOS  =)

constante N_LIN = 100;
N_LIN = 100;

tipo Matriz_100x100: vetor [N_LIN, N_COL] de real;
Lê_Matriz_Versão1(ref M: Matriz_2x3): neutro;
var i,j : inteiro;
início
para (i <-1; i <= N_LIN;i <- i + 1 ) faça
para (j <-1; i <= N_COL;i <- i + 1 ) faça
início
escreva(“Entre com o elemento – Linha”, i,” Coluna”,j);
leia(M[i,j];
fim
fim

Bom,é isso, acredito que os colégas de classe podem agora entender bem o conceito de MATRIZ em usando a LÓGICA DOS ALGORITMOS.

backupserver:~# vim hostip.sh
backupserver:~# chmod +x hostip.sh
backupserver:~# cp hostip.sh /etc/init.d/
backupserver:~# update-rc.d hostip.sh defaults
Adding system startup for /etc/init.d/hostip.sh …
/etc/rc0.d/K20hostip.sh -> ../init.d/hostip.sh
/etc/rc1.d/K20hostip.sh -> ../init.d/hostip.sh
/etc/rc6.d/K20hostip.sh -> ../init.d/hostip.sh
/etc/rc2.d/S20hostip.sh -> ../init.d/hostip.sh
/etc/rc3.d/S20hostip.sh -> ../init.d/hostip.sh
/etc/rc4.d/S20hostip.sh -> ../init.d/hostip.sh
/etc/rc5.d/S20hostip.sh -> ../init.d/hostip.sh
backupserver:~# ls -lha /etc/init.d/ |grep hostip

Padrão iniciando programa no boot

Publicado: novembro 22, 2007 em howto

update-rc.d script defaults


I’ve had few questions about obtaining the MAC and IP addresses on a Windows box. Personally, I find the ipconfig command as the easiest way to get this information. Here’s an example.

C:\Documents and Settings\hachid>ipconfig /all

Windows IP Configuration

Host Name . . . . . . . . . . . . : ixxx
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Mixed
IP Routing Enabled. . . . . . . . : Yes
WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) PRO/1000 CT Network Connect
ion
Physical Address. . . . . . . . . : xx-xx-xx-xx-xx-xx
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : xxx.xxx.x.x
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : xxx.xxx.xx.x
DHCP Server . . . . . . . . . . . : xxx.xxx.x.x
DNS Servers . . . . . . . . . . . : xxx.xxx.xx.x
xxx.xxx.xx.x
Lease Obtained. . . . . . . . . . : Monday, October 22, 2007 6:46:11 PM
Lease Expires . . . . . . . . . . : Tuesday, October 23, 2007 6:46:11 PM


After reviewing my Google Webmaster tools, I’ve observed several search iterations for “remove first 100 or 1000 lines in a log file.” Here’s an example to demonstrate removing the first 10 lines, 100 lines or 1000 lines in an .htaccess file.

Remove first 10 lines
# nl -ba .htaccess | more
1
2 order allow,deny
3 allow from all
4
5
6 deny from 213.xxx.xxx.xx
7 deny from 124.xxx.xxx.xx
8 deny from 81.xxx.xxx.xx
9 deny from 88.xxx.xxx.xx
10 deny from 88.xxx.xxx.11
11 deny from 84.xxx.xxx.56
12 deny from 88.xxx.xxx.xx
13 deny from 82.xxx.xxx.xx
14 deny from 69.xxx.xxx.xx
15 deny from 24.xxx.xxx.xx

# tail +11 .htaccess | more
deny from 84.xxx.xxx.56
deny from 88.xxx.xxx.xx
deny from 82.xxx.xxx.xx
deny from 69.xxx.xxx.xx
deny from 24.xxx.xxx.xx

Above is for illustration purposes but this syntax is all you need.
# tail +11 .htaccess > remove_10Lines.txt

Remove first 100 lines
# nl -ba .htaccess | more

96 deny from 85.xxx.xxx.xx
97 deny from 85.xxx.xxx.xx
98 deny from 85.xxx.xxx.xx
99 deny from 83.xxx.xxx.xx
100 deny from 81.xxx.xxx.70
101 deny from 81.xxx.xxx.29
102 deny from 81.xxx.xxx.xx
103 deny from 77.xxx.xxx.xx

# tail +101 .htaccess | more
deny from 81.xxx.xxx.29
deny from 81.xxx.xxx.xx
deny from 77.xxx.xxx.xx

Above is for illustration purposes but this syntax is all you need.
# tail +101 .htaccess > remove_100Lines.txt

Remove first 1000 lines
# nl -ba .htaccess | grep 1000 | more
1000 deny from 88.xxx.xxx.114

# nl -ba .htaccess | more

996 deny from 88.xxx.xxx.xxx
997 deny from 88.xxx.xxx.xxx
998 deny from 88.xxx.xxx.xxx
999 deny from 88.xxx.xxx.xxx
1000 deny from 88.xxx.xxx.114
1001 deny from 88.xxx.xxx.59
1002 deny from 88.xxx.xxx.xxx
1003 deny from 88.xxx.xxx.xxx

# tail +1001 .htaccess | more
deny from 88.xxx.xxx.59
deny from 88.xxx.xxx.xxx
deny from 88.xxx.xxx.xxx

Above is for illustration purposes but this syntax is all you need.
# tail +1001 .htaccess > remove_1000Lines.txt


Here is an easy way to determine how many login/logout sessions were recorded for a particular workstation. I will employ a few common UNIX system administration commands to fetch, filter, and then count the information derived from the wtmpx file. And by the way, my wtmpx file has not been cleared out in awhile.

# csh
# last | grep esoft | wc -l
24

In some organizations, logging in as the root user via the console is restricted. Check to see if anyone has logged in as root via the console.
# last | grep console | grep root | wc -l
20

Recorded Reboots
# last | awk ‘{print $1}’ | grep reboot | wc -l
36

Number of logins for each users/pseudo users (/bin/ later added per ux-admin’s suggestion)
# foreach i (`last | awk ‘{print $1}’ | sort | uniq | grep -v wtmp`)
? /bin/echo $i `last | grep $i | wc -l`
? end
ftp 16
reboot 36
restrict 1
root 167
esoft 24

Total logins for users/pseudo users
# last | awk ‘{print $1}’ | grep ‘.’ | grep -v wtmp | wc -l
244

Novidade

Publicado: novembro 22, 2007 em Uncategorized

Estarei em breve publicando o meu primeiro livro !!!!!!

Estarei em breve publicando o meu primeiro livro !!!!!!

Estarei em breve publicando o meu primeiro livro !!!!!!

Estarei em breve publicando o meu primeiro livro !!!!!!

This article shows how you can install Ruby on Rails (RoR) and integrate it in Apache2 on a Debian Etch system (including a short section at the end showing how to use RoR in a web site created with ISPConfig). Ruby on Rails is a web application framework which is rapidly gaining popularity among web programmers. It aims to increase the speed and ease with which database-driven web sites can be created and offers skeleton code frameworks (scaffolding) from the outset. Applications using the RoR framework are developed using the Model-View-Controller design pattern.
Remove ads

This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

1 Preliminary Note

I will use the hostname testapplication.example.com in this tutorial for the virtual host running Ruby on Rails.

2 Installing Ruby And Rails

In order to install Ruby and Ruby on Rails, we simply run

apt-get install ruby libzlib-ruby rdoc irb rubygems rails eruby

3 Installing Apache2 And mod-fcgid

Ruby on Rails can be integrated in Apache2 using mod-fcgid. Therefore we install the following packages:

apt-get install apache2 libapache2-mod-fcgid libfcgi-ruby1.8

Afterwards, we enable a few Apache modules:

a2enmod ssl
a2enmod rewrite
a2enmod suexec
a2enmod include

and reload Apache:

/etc/init.d/apache2 force-reload

4 Installing MySQL And The Ruby MySQL Bindings

Most probably you or your users will like to create database-driven Ruby on Rails applications, therefore we install the MySQL server and the Ruby MySQL bindings now:

apt-get install libmysql-ruby mysql-server

You should set a root password for MySQL now:

mysqladmin -u root password yourrootsqlpassword

If MySQL is listening not only on 127.0.0.1, but on other addresses as well (e.g. server1.example.com), you should set a root password for these addresses as well:

mysqladmin -h server1.example.com -u root password yourrootsqlpassword

5 Creating Our Ruby On Rails Environment

We can now create a directory in which we want to develop our future RoR applications. I’d like to develop them in /var/rails, so I create that directory now:

mkdir /var/rails

Apache2 should have read/write access to that directory, so we make the Apache user (www-data on Debian) and Apache group (again www-data) the owner and group of that directory:

chown -R www-data:www-data /var/rails

Now we can create our first RoR application which we will call testapplication. We will create testapplication under the user www-data so that Apache has read/write access to it:

cd /var/rails
su -m www-data

Now that we’re logged in as www-data, we run

rails testapplication

This will create a directory called testapplication within /var/rails that contains all directories and files we need to develop our RoR application.

Next, we type in

exit

to become the root user again.

6 Modifying Our Application’s .htaccess File

The web folder of testapplication is /var/rails/testapplication/public. It contains an .htaccess file that we must modify so that Apache2 can run RoR applications using mod-fcgid.

vi /var/rails/testapplication/public/.htaccess

Comment out the AddHandler fastcgi-script .fcgi and AddHandler cgi-script .cgi lines and add the line AddHandler fcgid-script .fcgi. Also comment out the line RewriteRule ^(.*)$ dispatch.cgi [QSA,L] and add the line RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] (note that it’s now dispatch.fcgi instead of dispatch.cgi). Afterwards, the file should look like this:
Remove ads

# General Apache options
#AddHandler fastcgi-script .fcgi
#AddHandler cgi-script .cgi
AddHandler fcgid-script .fcgi
Options +FollowSymLinks +ExecCGI

# If you don’t want Rails to look in certain directories,
# use the following rewrite rules so that Apache won’t rewrite certain requests
#
# Example:
#   RewriteCond %{REQUEST_URI} ^/notrails.*
#   RewriteRule .* – [L]

# Redirect all requests not available on the filesystem to Rails
# By default the cgi dispatcher is used which is very slow
#
# For better performance replace the dispatcher with the fastcgi one
#
# Example:
#   RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On

# If your Rails application is accessed via an Alias directive,
# then you MUST also set the RewriteBase in this htaccess file.
#
# Example:
#   Alias /myrailsapp /path/to/myrailsapp/public
#   RewriteBase /myrailsapp

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

# In case Rails experiences terminal errors
# Instead of displaying this message you can supply a file here which will be rendered instead
#
# Example:
#   ErrorDocument 500 /500.html

ErrorDocument 500 “<h2>Application error</h2>Rails application failed to start properly”

7 Creating A Virtual Host For Our RoR Application

(If you use ISPConfig, please go to chapter 8!)

Now it’s time to create an Apache vhost for our application. I will use the hostname testapplication.example.com so that our application can be reached under http://testapplication.example.com (assuming that testapplication.example.com points to the correct IP address).

The easiest way to create such a vhost is to replace the existing default vhost in /etc/apache2/sites-available/default (assuming that this default vhost isn’t needed!):

cp /etc/apache2/sites-available/default /etc/apache2/sites-available/default_old
cat /dev/null > /etc/apache2/sites-available/default
vi /etc/apache2/sites-available/default

<Virtualhost *:80>
ServerName testapplication.example.com
DocumentRoot /var/rails/testapplication/public/

<Directory /var/rails/testapplication/public>
Options ExecCGI FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</Virtualhost>

Of course, instead of replacing the default vhost, you can simply add your testapplication.example.com vhost at the end of /etc/apache2/sites-available/default so that you keep the default vhost.

Now we restart Apache:

/etc/init.d/apache2 restart

Next we open http://testapplication.example.com in a browser. We should see the default RoR page:

That’s it! Now we can start to develop our RoR application in the /var/rails/testapplication directory.

8 RoR And ISPConfig

(If you don’t use ISPConfig, skip this chapter!)

In this chapter I assume that you have created a web site called testapplication.example.com with the document root /var/www/web1/web in ISPConfig, and that your RoR testapplication is still in /var/rails/testapplication.

To make our RoR testapplication available in the testapplication.example.com vhost which we have created in ISPConfig, we do the following:

First, we put the following lines into the Apache Directives field of the testapplication.example.com web site in ISPConfig:

<Directory /var/www/web1/web>
Options +ExecCGI +FollowSymLinks
AllowOverride all
</Directory>

Then we rename /var/rails/testapplication/public to /var/rails/testapplication/web, copy the contents of /var/rails/testapplication to /var/www/web1, and make the Apache user the owner of /var/www/web1/web:

cd /var/rails/testapplication
mv public web
cp -pfr * /var/www/web1
chown www-data:web1 /var/www/web1/web

That’s it. The RoR application should now work in the testapplication.example.com vhost which we have created in ISPConfig.

9 Links

* Ruby on Rails: http://www.rubyonrails.org
* Ruby: http://www.ruby-lang.org
* Debian: http://www.debian.org
* ISPConfig: http://www.ispconfig.org