2011-08-17

PySide in Eclipse generates false errors

PyDev starts generating false errors for my code after installing PySide.

To fix this problem follow this steps:
1. In Eclipse open Window -> Preferences -> Pydev -> Interpreter - Python
2. Add C:\Python27\Lib\site-packages to SystemPYTHONPATH (if you already have it... remove this line and add it again)

Installing Eclipse IDE for C++ and QT with MinGW on Windows

Follow next steps to install Eclipse IDE for C++ and QT with MinGQ on Windows:
1. Instal MinGW (with MSYS) http://sourceforge.net/projects/mingw/files/
2. Install gdb-6.3-2.exe http://citylan.dl.sourceforge.net/project/mingw/MinGW/BaseSystem/GDB/Release%20Candidate_%20gdb-6.3/gdb-6.3-2.exe
3. Add path to MinGW and MSYS folder (for me it's C:\MinGW\bin;C:\MinGW\msys\1.0\bin;) to system variable (PATH)
4. Install QT (qt-win-opensource-4.6.4-mingw.exe) http://get.qt.nokia.com/qt/source/qt-win-opensource-4.6.4-mingw.exe
5. Install Eclipse IDE for C/C++ Developers (includes Incubating components), http://www.eclipse.org/downloads/ - just download and unzip it. INSTALL 32-bit version (and of course you need JRE 32-bit version ...for example this one jre-6u27-windows-i586.exe from here http://www.oracle.com/technetwork/java/javase/downloads/jre-6u27-download-440425.html
6. install QT Eclipse integration http://get.qt.nokia.com/qteclipse/qt-eclipse-integration-win32-1.6.1.exe
7. Reboot and then Run Eclipse
8. In eclipse Preferense->Qt press "Add new Qt version"... and add path to your ...\qt\4.4.1\bin folder

2011-05-26

multiple virtualhost in wampserver2

1. add this line to c:\windows\system32\drivers\etc\hosts
127.0.0.1 mysite.com

2. add this block to httpd.conf file:

NameVirtualHost 127.0.0.1
<virtualhost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wamp/www"
</VirtualHost>

<virtualhost 127.0.0.1>
ServerName mysite.com
DocumentRoot "C:\wamp\www\share\www"
</VirtualHost>




fo MAMP users, just add this

ServerName devshara
DocumentRoot "/Users/const/Dev/svn/sharamba/development/www"

2011-05-21

Light Explorer in Notepad++

Light Explorer in Notepad++ "allows documents to be opened from a dockable file explorer, that is very light weight and fast. Author: Javier Sanjose"

2011-05-15

PHP: Netbeans block comment (like /* comment */)

To comment multiple lines in Netbeans (like this /* comment */) you need to create macros

Tools -> Options -> Editor -> Macros -> New
The code of macros is:
cut-to-clipboard "/*" paste-from-clipboard "*/"

and Set shortcut to Ctrl+Shift+Q.

2011-04-26

Python: how to remove duplicates from list

# -*- coding: utf-8 -*-
qi=[1,1,3,1,6,4,5,1,6] #some elements repeat
qi.sort() #sort urls (just for fun)
qi_normal=set(qi) #this removes duplicate URL's
print "list wit repeated elemnts:", qi
print "list without repeted ellemnts:",qi_normal

Python: How to remove \n (end of line) symbol

# -*- coding: utf-8 -*-
str = [u"afaaas\n", "adasf \t"]
print "withouth strip():", str
print "with strip:\n", str[0].strip()
print str[1].strip()

as you can see .strip() also remove \t

2011-04-25

Python: read utf-8 file

This how I read utf-8 (without BOM) file in python:
import codecs
txtfile = codecs.open("bla.txt", "r", "utf-8")
t= txtfile.read()
txtfile.close()
print t

2011-04-24

Erlang frameworks comparison

http://chicagoboss.org/projects/chicagoboss/wiki/Comparison_of_Erlang_Web_Frameworks
http://stackoverflow.com/questions/1822518/current-state-of-erlang-web-development-frameworks-template-languages

Interesting info:
http://brainslugs.blogspot.com/2008/02/yaws-erlang.html

Tut for beginers:
http://www.giantflyingsaucer.com/blog/?p=251
http://www.rsdn.ru/article/erlang/GettingStartedWithErlang.xml

mochiweb:
http://habrahabr.ru/blogs/erlang/111252/

2011-04-17

Pylons error in windows 7: "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0 : ordinal not in range(128)"

to solve this issue i delete all cyrillic sections (smth. like this "аудио/x-gsm") in the windows registry:

[HKEY_CLASSES_ROOT\CLSID\{4063BE15-3B08-470D-A0D5-B37161CFFD69}\EnableFullPage\MIME]
and
[HKEY_CLASSES_ROOT\MIME\Database\Content Type]

pylons installation error "ImportError: No module named _weakrefset"

in go-pylons.py add after line 43

if sys.version_info[:2] >= (2, 7):
REQUIRED_MODULES.extend(['_weakrefset'])

Console 2 for Windows

I like it, maybe you like it to, so try it if you can't stand standart windows console:
http://sourceforge.net/projects/console/

If you know some other consoles for windows, plz let me know.

Description:
"Console is a Windows console window enhancement. Console features include: multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles"

2011-04-13

Django error on windows: "Error loading MySQLdb module: No module named MySQLdb"

If you got this error "Error loading MySQLdb module: No module named MySQLdb" in Django on windows... just install this
http://www.codegood.com/downloads?dl_cat=2

2011-03-22

Import large file to mysql (using phpmyadmin)

In phpmyadmin max size of importing file depends on php settings.

So... change this lines in php.ini if needed
upload_max_filesize = 20M
post_max_size = 20M

2011-03-20

SVN Tortoise icons in Total Commander 7.50

To show SVN Tortoise icons in Total Commander (7.50) turn on "Show overlay icons, e.g. for links" (Configuration -> Options -> Icons)

Yii and Wampserver

I've got "Internal Server Error" in my yii web application until I turn on rewrite_module in Apache on wampserver (clik on wamp tray icon -> Apache -> Apache modules -> rewrite_module).


Also I use this PHP Settings (clik on wamp tray icon -> PHP -> PHP settings):

short open tag - tells PHP whether the short form ( ) of PHP's open tag should be allowed

(XDebug): Remote debug - to debug in netBeans

and you need to add following in your php.ini
; XDEBUG Extension

zend_extension = "c:/wamp/bin/php/php5.3.5/zend_ext/php_xdebug-2.1.0-5.3-vc6.dll"

[xdebug]
xdebug.remote_enable = On
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"



If you have got errors like "Undefined variable: model" you should change error_reporting in php.ini:

Open file php.ini and find
error_reporting = E_ALL 
replace with
error_reporting = E_ALL & ~E_NOTICE 
or comment it

Do not forget restart your wamp server

2011-02-19

Problem with log in Chrome Web Inspector

Finnaly found why logging doesn't work in Chrome (web inspector). So... problem was in fire bug for chrome, when I switched it off logging start to work in naitive chrome developer tool (web inspector).

BTW: to send smth. to console in web inspector use this js code in your web application:
<script type="text/javascript"> 
/*<![CDATA[*/
if(typeof(console)=='object')
{
console.group("Application Log");
console.log("Your message");
console.groupEnd();
}
/*]]>*/
</script>

2011-02-05

yii CAutoComplete css

To chose higlight in dropdown list use this css^

//redefine color of selected item in dropdown list
.ac_over{
 background-color:#bb0000;
}

CAutoCoplete has class names like this
<li class="ac_even ac_over">...
That's mean that this element has 2 classes at the same time (separatede by space): ac_even and ac_over

Didn't know this trik before :)

2011-02-04

yii sRBAC

soo.... while installing yii sRBAC I got some problems.

Here they are:

1) Problem with config. Finally ... AuthManager in protected/config/main.php should looks like this:
<?php
return array(
//......some code.....

// application components
'components'=>array(
  'authManager' => array(
    'class'  => 'CDbAuthManager',
    'connectionID'     => 'db',
    'itemTable'          => 'AuthItem',
    'itemChildTable'    => 'AuthItemChild',
    'assignmentTable' => 'AuthAssignment',
    'defaultRoles'       =>  array('Guest'),
  ),
),

// autoloading model and component classes
'import'=>array(
      'application.models.*',
      'application.components.*',
      'application.modules.srbac.controllers.SBaseController',
  ),

'modules'=>array(
  'srbac'   => array(
                   'userclass' => 'User',
                   'userid'    => 'id',
                   'username'  => 'username',
                   'debug'     => true,
                   'pageSize'  => 20,
                   'superUser' => 'Authority',
                   'css'       => 'srbac.css', // <=====changed
                   //'notAuthorizedView' => 'application.theme.unauthorized', // <=====changed
                   'userActions'          => array('Show','View','List','Index'),
                   'listBoxNumberOfLines' => 15,
                   //'imagesPath'           => 'images',
                   //'imagesPack'           => 'noia',
                   'iconText'             => true,
                   'layout' => 'webroot.themes.THEME_NAME.views.layouts.nocolumn', // <=====changed (use this alias if you use theme in yii)
       
  ),
),
 
 
);
?>
2) I got problems with "lower case table names" in mySQL. To allow upper case in mySQL use this advice: 'add this line lower_case_table_names=2 to your my.ini file and restart wamp' http://www.wampserver.com/phorum/read.php?2,58873

2011-02-01

Problems with UTF-8 in Yii/Php

If you've got problems with UTF-8 in Yii/Php (using strlen or substr)... here is the solution:
mb_internal_encoding("UTF-8"); //set encoding

mb_strlen($utfstring); //use mb_strlen instead strlen
mb_substr($utfstring); //the same thing for substr