[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<———————————————————-