2012-10-06

Iterm2 how to setup word jumpig using alt+left alt+right arrow


In Preferences->Profiles->Keys:

find "option ←" and edit its "action" like this: select "send escape sequence" and in the "escape sequence box" enter "b"

find "option  →" and edit its "action" like this: select "send escape sequence" and in the "escape sequence box" enter "f"

Add this to your ~/.inputrc:
#Pressing alt+left/right arrow force cursor to jump 1 word left/right
"\e[1;9D": backward-word
"\e[1;9C": forward-word

2012-03-16

Python MySQLdb with MAMP

U need xCode, mySQL instaled and MySQL-python-1.2.3
Also you need MAMP instaled.

in MySQL-python-1.2.3 folder in site.cfg file add mysql_config path:
# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.
mysql_config = /Applications/MAMP/Library/bin/mysql_config


in terminal in MySQL-python-1.2.3 folder do this:
$ sudo python setup.py clean
$ sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
$ sudo python setup.py build
$ sudo python setup.py install

If you got error "Reason: image not found" try this:
sudo cp /usr/local/mysql/lib/libmysqlclient_r.18.dylib /usr/local/mysql/lib/mysql/libmysqlclient_r.18.dylib

or this:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/


in your python script use unix_socket = path_to_MAMP_socket:
#!/usr/bin/python
import sys
import MySQLdb
import MySQLdb.cursors
db= MySQLdb.connect(unix_socket = '/Applications/MAMP/tmp/mysql/mysql.sock', host="localhost", port=3306 ,user="username", passwd="password",db="database")



related links:
http://paikialog.wordpress.com/2011/05/02/mac-install-python-mysqldb-to-mamp/
http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/

2012-03-03

Recursively delete .svn directories

rm -rf `find . -type d -name .svn`

Fixing the “unix:///var/mysql/mysql.sock” not found error on MAMP

If you've got this problem on mac (with MAMP):
PHP Error[2]: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

Try this:
sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

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