Install PostgreSQL phpPgAdmin on Fedora 12

April 7th, 2010

Install PostgreSQL phpPgAdmin  on Fedora 12

1.  Update YUM

su – (or sudo)
yum update

2. install from repo

yum install postgresql-server  postgresql phpPgAdmin php-pgsql

3. Edit  settings  files:

a) vim /var/lib/pgsql/data/pg_hba.conf

set “trust” to  login “without password”

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# “local” is for Unix domain socket connections only
local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
# IPv6 local connections:
host    all         all         ::1/128               trust

b) vim /var/lib/pgsql/data/postgresql.conf

My basic settings (for  local working with db):

#——————————————————————————
# CONNECTIONS AND AUTHENTICATION
#——————————————————————————

# – Connection Settings -

listen_addresses = ‘*’          # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to ‘localhost’, ‘*’ = all
# (change requires restart)
port = 5432                             # (change requires restart)
max_connections = 100                   # (change requires restart)

c)   cp  /etc/phpPgAdmin/config.inc.php-dist config.inc.php

(Copy phpPgAdmin config file  (rename on basic setup) )

4. Initialize db

service postgresql initdb

5. Start server
/etc/init.d/postgresql start

Or configure service to start automatical:

/sbin/chkconfig postgresql on
/sbin/service postgresql start

6. Create user and database:
su – postgres
psql template1

psql#  create user db_user;
psql#  create database test_db owner db_user;

for quitfrom psql, type:
psql#  \q

7.  Go to : http;//localhost/phpPgAdmin/
put your login (db_user )

;-)

[tinyMCE, textarea, onclick,tinyMCE.triggerSave] send data from textarea with tinyMCE

March 17th, 2010

1st solution: save data as onsubmit function

<form action=”action_script.php” method=”post”>

<textarea id=”textarea_id” cols=”100″ rows=”15″></textarea>
<input name=”save” type=”submit” value=”Save” />
</form>

2nd solution: save data as onclick function

<textarea id=”textarea_id” cols=”100″ rows=”15″></textarea>
<input onclick=”tinyMCE.triggerSave(); yourOtherFunction()” name=”save” type=”submit” value=”Save” />

[php, python] Batch script to replace PHP short open tags with

March 1st, 2010


#!/usr/bin/env python
# change short tag ' # date 26-02-2010
#Jabber ID: skowroniasty@jabster.pl
# IDE Eclipse+PyDev

file =0
directory=0
def changeTags(name):
newName = name+’.old’
import shutil;
shutil.copyfile(name, newName)
filepathr = newName
filepathw = name #file to save new version
try:
file = open(filepathr, ‘r’)
except IOError as (errno, strerror):
print “I/O error({0}): {1}”.format(errno, strerror)
linelist = file.readlines()
file.close()
try:
filew = open(filepathw,’w')
except IOError as (errno, strerror):
print “I/O error({0}): {1}”.format(errno, strerror)

for oldline in linelist:
if oldline.startswith(”//”):
pass
else:
data = oldline.split()
newline = []
for i in data:
if i == ” i = ” newline.append(i+’ ‘)
filew.write(”.join(newline) + “\n”)
filew.close()

def walk(dir):
import os
global directory
global file
try:
for name in os.listdir(dir):
path = os.path.join(dir, name)
if os.path.isfile(path):
# print path;
file= file+1
changeTags(path)
else:
directory=directory+1
walk(path)

except IOError as (errno, strerror):
print “I/O error({0}): {1}”.format(errno, strerror)

def report(pathToReport):
global directory;
global file;
line1 =”done”
line2 =”all files:”
line3 =”all directory ”
reportFile=open(pathToReport, ‘w’)
reportFile.write(line1)
reportFile.write(line2+str(file))
reportFile.write(line3+str(directory))
reportFile.close()

pathToFiles=’/home/rafal/Pulpit/ef/’
reportFile=’convertTagsReport.txt’

pathToReport=pathToFiles+reportFile

import os
if os.path.exists(pathToReport):
print “Can’t convert 2nd time”
else:
walk(pathToFiles)
report(pathToReport)

print “DONE”

How mount ntfs drive or pendrive on archlinux?

November 18th, 2009

Simply way:

1.  pacman -Sy  ntfs-3g

2.  ls  /dev/sd*

3. choice the drive from result list

4.  mkdir  /mnt/mounted_volume

5. ntfs-3g  /dev/YOUR_CHOICE   /mnt/mounted_volume

————————————–8<———————————————-

For USB pendrive

1. ls  /dev/sd*

2.  choice the drive from result list

3. mkdir  /mnt/pendrive

4. mount /dev/YOUR_CHOICE   /mnt/pendrive

MySQL: add user, database, and set

November 14th, 2009

#login as root:

mysql -u root -p
#create database
CREATE database myDatabase_db;

#create  user
CREATE USER ‘admin_db’@'localhost’ IDENTIFIED BY ‘passw0rd’;

#add user to db (as admin)
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON myDatabase_db.* TO
‘admin_db’@'localhost’;

Restart MySQL, apache

November 14th, 2009

To start mysql server:
/etc/init.d/mysqld start

* To stop mysql server:
/etc/init.d/mysqld stop

* To restart mysql server
/etc/init.d/mysqld restart

*To restart apache
apachectl -k restar

[LINUX] Qwt integration with QtCreator

November 14th, 2009

1. Download and install fresh  QtCreator from http://qt.nokia.com

2. Download and install Qwt from http://qwt.sourceforge.net/index.html

For default install, use qmake; make; make install . Default path  /usr/local/qwt-XXXX

use ldconfig to add shared library:

[For Ubuntu Linux] create new file on /etc/ld.so.conf.d/ for exemple qwt.conf, and add to this file path      to  qwt library dictionary ( for example /usr/local/qwt-XXXX/lib) and run ldconfig

3. Copy plugin for QtCreator from Qwt directory  to  QtCretor directory.

For exemple:  cp /home/user/qwt-XXXX/designer/plugins/designer/libqwt_designer_plugin.so  /opt/qtsdk-2009.04/bin/designer/libqwt_designer_plugin.so

4. Restart QtCreator and enjoy ;-)

XP Boost

November 12th, 2009

copy and save as *.bat file
————————-8<———————————————————-
@echo off
echo *******Optymalizowanie systemu*****
echo 1. Kasowanie plikow wstepnego uruchamiania …
echo Wskazowka: dla starych PC’etow zaleca sie wylaczyc opcje prefetchu
echo opcja ENABLE PREFECH w kluczu
echo HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Memory Management\Prefetch Parameters
echo 0 – Disable
echo 1 – Only aplic.
echo 2 – Only start proc.
echo 3 – Enable
echo.
cd C:\Windows\Prefetch
del /Q /F /S *.*
echo *********************************************
echo 2. Defragmentacja plikow startowych
echo Wskazówka: Uruchamianie defragmentacji na starcie
echo ustaw ENABLE na ‘Y’
echo w kluczu: HKEY_LOCAL_MACHINE\Software\Microsoft\Dfrg\BootOptimize Function
defrag c: -b
echo.
echo ********************************************
echo home# www.ciupu.elektroda.eu
echo mail# ciupu@elektroda.net
echo jid# skowroniasty@jabster.pl
pause

————————-8<———————————————————-