jueves 26 de mayo de 2011

Tutorial : Running a symfony project under Dotcloud



Dotcloud is under beta now, you can ask for one.

The main issue I got while try to run a symfony project was to change the root directory. Googling fot symfony and dotcloud didnt answers this...so I create this post.

Lets create a new project

dotcloud create your_symfony_project_name

Lets create the www and db
dotcloud deploy --type python your_symfony_project_name.www
dotcloud deploy --type python your_symfony_project_name.db

Now optionally, import the database. In this case I was using mysql
otcloud run your_symfony_project_name.db "cat > data.sql" < your_local_dump_file.sql
Before push your code to www, lets add nginx configuration for Symfony. create nginx.conf at web directory of your project with this:
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
  expires 7d;
  break;
}

location / {
  try_files $uri $uri/ /index.php;
}

#Remove this at production!!
location ^~ /frontend_dev.php/ {
  try_files $uri /frontend_dev.php;
}
Next step upload the symfony proyect PHP files.
dotcloud push your_symfony_project_name.www ~/your_symfony_project_name
Symfony needs the root directory to be in "web" so create "dotcloud_build.yml" in your aplication root directory with this:
www:
    approot: web
REMEBER: clear the symfony cache!! To clear cache:
dotcloud ssh your_symfony_project_name.www 
cd code
./symfony cache:clear

Thats all folks!

miércoles 25 de mayo de 2011

Share internet with Ubuntu 11.04



This tutorial explains how to share internet from wifi (wlan0) to ethernet (eth0). So the
internet connection comes from the wifi and we share to other computer via ethernet.

edit /etc/network/interfaces, add statis IP to eth0
auto eth0
iface eth0 inet static
        address 10.0.0.1
        netmask 255.255.255.0

Restart network
sudo /etc/init.d/networking restart

Install dhcp3 and dnsmasq
sudo apt-get install dhcp3-server dnsmasq  

At this step is possible to get an error, we need to configure dhcp3 server. Edit /etc/dhcp/dhcpd.conf add this
subnet 10.0.0.0 netmask 255.255.255.0 {
  range 10.0.0.2 10.0.0.254;
  option routers 10.0.0.1;
  option domain-name-servers 10.0.0.1;
}
Now restart dhcpd
 sudo /etc/init.d/isc-dhcp-server restart

At this point we need to enable ip forwarding

sudo iptables -A FORWARD -o eth0 -i eth1 -s 10.0.0.0/24 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE 

now save the iptables commands:

sudo iptables-save | sudo tee /etc/iptables.sav

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Make a permanent ip_forward=1,edit /etc/sysctl.conf and add these lines:

net.ipv4.conf.default.forwarding=1
net.ipv4.conf.all.forwarding=1

please if you need an easy we to share internet, comment a link!!

sábado 7 de mayo de 2011

[SOLVED] Python PIL : IOError: decoder jpeg not available

The first thing I check when I got this error was to check if libjpeg was installed.
Lets try this

sudo apt-get install libjpeg libjpeg-dev
sudo apt-get install libfreetype6 libfreetype6-dev 

download jpeg source

    tar -xzvf jpegsrc.v8c.tar.gz
    cd jpeg-6b/
    ./configure
    make
    sudo make install


So download Python Imaging Library 1.1.7 Source Kit (all platforms)

The after run the setup.py install, check if the support was ok

--------------------------------------------------------------------
*** TKINTER support not available (Tcl/Tk 8.5 libraries needed)
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
--- LITTLECMS support available
--------------------------------------------------------------------


If not, in setup.py in PIL I had to change the path of :

JPEG_ROOT = None
ZLIB_ROOT = None

to
JPEG_ROOT = libinclude("/usr/")
ZLIB_ROOT = libinclude("/usr/")

martes 3 de mayo de 2011

[SOLVED] Ubuntu 11.04 Remove unity but use gnome 2

In other post I explain Howto remove unity and install gnome3. but since gnome3 is unstable this will change unity into default gnome but a stable version :

1) Click on the power button in the upper right corner (mine looks like a light switch) and choose the last option, System Settings.
2) Search for Login Screen
3) Double-click to display
4) Choose Unlock and enter your password
5) Select Ubuntu Classic as default session.

Please comment if you have problems.

lunes 2 de mayo de 2011

90% of programmers dont know that this==super!

In programming lenguages the use of super is commonly mistaken. Usually super seems to call the method of the super class of the class where the method is implemented.
Factoid :  super  mean start the search in the superclass of the receiver.

The error is easy to induce, a lot of programmers learns by induction the use of super (or learning by example).
This causes a misconception of the real definition of super and self (or this in java).
The real use of self or super is to specify how to search the message (or method) in the class hierarchy, I don't think a common programmer will think this way (not in the way algorithm is implemented).

Lets see the example :
example3 and example4 are instances of Three and Four respectively.

if you send the message result2 to example3 it will return 2
if you send the message result2 to example4 it will return 4

Also


if you send the message result3 to example3 it will return 2
if you send the message result3 to example4 it will return 2

But what will happened if Three implements the test message  test as { return 3 } when you send the result3 message to example4?

It will return 3 or 2? Actually it will return 2. If you don't know why check the definition of self and super




self (or this) means : start the search in the receiver class (receiver here is the object which get the message)

Super really means  : start the search in the superclass of the class containing the method in which super was used.

So the answer of the question it will return 2 or 3 depends on where the super sends is implemented (in which class!) not as self!

domingo 1 de mayo de 2011

MOSCRACK The Clustered WPA Cracker v2.06b released

Moscrack is a perl application designed to facilitate cracking WPA keys in parallel on a group of computers.
Moscrack is intended to facilitate the use of a WPA cracker on a cluster.  Currently it has only been used with Mosix (clustering software) and SSH nodes.  It works by reading a word list from STDIN or a file, breaking it into chunks  and passing those chunks off to seperate processes that run in parallel. The  parallel processes can then execute on different nodes in your cluster. All  results are checked (to a degree) and recorded on your master node. Logging,  error handling, etc… are all handled for you.
Moscrack is designed to be run for long periods of time (days/weeks/etc…). The goal is to make that easy and
reliable for you.



Google Analytics Alternative