Ярлыки

суббота, 3 ноября 2012 г.

Some steps for settings PostgreSQL


There are few steps for setting PostgreSQL:
0) pg_config --version
 - what version are installed?
1) pg_config --configure
  - see server configuration
2) sudo useradd postgres
 - command for add user
3) Make DB dir and delegate permissions to new user:
    mkdir /usr/local/pgsql/data
    chown postgres /usr/local/pgsql/data
4) starting DB:
    $ sudo - postgres
    pg$
5) Inizialize DB:
    pg$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
6) Starting DB again:
    /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
or 
   /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
7) permissions for remote host (not localhost) - in file /usr/local/pgsql/data/pg_hba.conf
in format: host - DB name - user - IP-address - mask - authentication (md5/trust)
  We must also write variable `listen_adresses="*"` in file postgresql.conf
8) start, stop and restart DB:
    pg_ctl start
    pg_ctl_stop
    pg_ctl_restart
9) test: connect to template "template1":
    psql -h 192.168.0.111 -d template1
10) reboot server
11) Then we must see for starting postmaster:
    ps -el | grep post
12) create DB:
    create_db ******
13) create user:
    CREATE USER myuser WITH password 'mypsw';

problem with encoding in PyQt4


Python2.7, Eric4, PyQt4 
I have follow problem:
when I send list to form for fill ComboBox: in ComboBox I see abracadabra. My coding is utf-8.

My code:
sectList=[i[0] for i in sectionsDict.items()]
print(sectList)
main_window.selectSection.addItems(sectList)

Function "print" insert for see what doing here.

Solve of the problem:
sectList=[unicode(i[0], 'cp1251') for i in sectionsDict.items()]
print(sectList)
main_window.selectSection.addItems(sectList)

Python: how to know IP address


>>> import socket
>>> print socket.gethostbyname_ex(socket.gethostname())[2]
['10.144.53.165', '192.168.56.1']
>>> print socket.gethostbyname_ex(socket.gethostname())
('myPC.net1.net2', [], ['10.144.53.165', '192.168.56.1'])
>>> print socket.gethostbyname(socket.gethostname())
10.144.53.165

четверг, 25 октября 2012 г.

Installing OracleClient11g on UbuntuServer

It's did by this instruction: http://www.gena01.com/forum/gena01-blog/oracle-instant-client-11g-on-ubuntu/

I did follow:

1. Installling libaio1 (must for Oracle 11g, optional for 10):
apt-get install libaio1

2. Installing alien:
apt-get install alien


3. Downloading RPMs from here:
http://www.oracle.com/technetwork/topics/linuxsoft-082809.html

4. RPMs converting into .deb through alien:
alien [download_file.rpm]

5. Installing debian-package:
dpkg -i [file_from_paragraph_4.deb]
 
6. And finally, doing this command:

aptitude search oracle
And we must see: 


p   cl-sql-oracle                                                          - CLSQL database backend, Oracle
p   libmono-oracle1.0-cil                                                  - Mono Oracle library
p   libmono-oracle2.0-cil                                                  - Mono Oracle library
i   oracle-instantclient11.1-basic                                         - Instant Client for Oracle Database 11g
i   oracle-instantclient11.1-devel                                         - Development headers for Instant Client.
i   oracle-instantclient11.1-sqlplus                                       - SQL*Plus for Instant Client.
p   spamoracle                                                             - A statistical analysis spam filter based on Bayes' formula
p   spamoracle-byte                                                        - A statistical analysis spam filter based on Bayes' formula

Install Django on UbuntuServer

How I installed Django on UbuntuServer 11.04 - the Natty Narwhal
python2
django1.3

Apache already installed. 

Installing apxs2: 
 sudo apt-get install apache2-threaded-dev

Installing mod_python-3.3.1:
sudo apt-get install libapache2-mod-python

stop Apache:
sudo /etc/init.d/apache2 stop

Than we write settings in Apache config file (for me - /etc/apache2/apache2.conf). This settings bind Django with URL:
#Connect to mod_python:
LoadModule python_module /usr/lib/apache2/modules/mod_python.so

#Connect Django with URL:
<Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE settings
    PythonDebug Off
    PythonPath "['/home/vinger4/vinger4site','/usr/local/lib/python3.2/dist-packages/django'] + sys.path"
    PythonAutoReload Off
</Location>

Correcting urls.py and settings.py
You must delete prefix of you site (in my case - vinger4site), because it wrote in PythonPath for Apache (please, see previous paragraph).

start Apache
sudo /etc/init.d/apache2 start

Now each request to the server must go through Apache.

Virtual Machine Image with Django


Virtual Machine Image with Django: 
http://bitnami.org/stack/djangostack

вторник, 2 октября 2012 г.

neo4j: class RelTypeFilterExcluder example


public class RelTypeFilterExcluder implements Predicate<Object> {
Set<String> exclude;

public RelTypeFilterExcluder(Set<String> excludeInput) {
this.exclude = excludeInput;
}

@Override
public boolean accept(Object arg0) {
String typeItem = ((PropertyContainer) arg0).getProperty("type").toString();
if ( this.exclude.contains(typeItem) ) {
return false;
}
return true;
}

}