A connection attempt failed because the connected party did not properly respond

If you’re like me, using EasyPHP on Windows 7 for local development and have encountered this PHP/MySQL error:

Warning: mysql_connect() [function.mysql-connect]: [2002]
A connection attempt failed because the connected party did
not (trying to connect via tcp://localhost:3306) in
C:\Path\To\Script.php on line 26

Warning: mysql_connect() [function.mysql-connect]: A connection
attempt failed because the connected party did not properly
respond after a period of time, or established connection failed
because connected host has failed to respond. in
C:\Path\To\Script.php on line 26

Fatal error: Maximum execution time of 30 seconds exceeded in
C:\Path\To\Script.php on line 26

..then you’re in luck! Here’s a quick easy fix:

  1. Go to “C:\Windows\System32\drivers\etc“.
  2. Open “hosts” with Notepad program.
  3. Uncomment this line: “127.0.0.1 localhost” or add it if it’s not on the host entry.

That’s it! Save the changes you’ve made and refresh your browser.

Hope this helps!

* NOTE – Make sure you have a full access on “hosts” file.

  1. Right click on “hosts” file then click “Properties“.
  2. On “Security” tab click “Edit…” button.
  3. Select the user that you are currently using.
  4. Under “Permissions for Users” box, tick “Full control” on “Allow” column.
  5. And then click “OK” button to apply the changes.

jixedbar: A stick or die jQuery plugin (jstcky Redux)

I just recently released a new OSS project called jixedbar, a jQuery plugin that stick/fix a Div element on the bottom of a page/website. Inspired by Facebook’s fixed app/menu bar, the code is based on the jstcky (deprecated project) but with improved codebase, features, and written as a jQuery plugin to maximize the use of jQuery’s rich features.

Here’s a quick demo: http://ryan.rawswift.com/sandbox/jixedbar-0.0.2/demo/

You can get the Beta release from Google Code Project Host, either by downloading the archive file or through Subversion (SVN) repository.

Send your comments and suggestions to rawswift at gmai dot com.

Cheers!

Aptana: How to enable PHP Code Assist

If you are a PHP developer, you know that code refactor, code completion, and code assist is a very essential features that you’ll want to have on an IDE and Adobe’s Dreamweaver couldn’t give that to you. Don’t get me wrong, I love Dreamweaver, actually I’m still using it (on my Windows desktop) for HTML and web design mockups and it’s still one of the best HTML editor out there but that’s about it, an HTML editor, nothing more.

Have you ever tried Aptana? Well you should! If you’re a Web developer, building the next biggest, greatest, and newest application of the future then Aptana will be a great tool for you. It has code refactor, PHP code completion, code assist, FTP, SFTP, and SSH support and it’s FREE (Aptana Community Edition)! Plus it also has support for Ruby (Rails), Python, Adobe Air, and other language or platform. But wait there’s more! Ajax libraries (jQuery, Prototype/Scriptaculous, Adobe Spry, Dojo, etc). And if you’re a code version control freak, no worries! It has CVS, Subversion, or Git plugin support.

Enough with the promotion! Cause I will not get paid even doing so. But if you want an IDE with tons of support and features then Aptana is one of the best out there. Especially their code assist feature, it’s a top-notch. Aptana’s code completion for PHP’s common methods are default, you’ll have to install PHP plugin first to get this feature and for Aptana to recognize PHP codes and files.

To enable PHP Code Assist in Aptana, follow the simple instructions below. This will be useful if you have classes and methods that you want to be visible all over your project.

Code Assist will only work locally which means your source file must be in your local drive (not on a remote). But there’s a workaround for this, and we’ll get to that later on.

This is how to enable PHP Code Assist:

Local Projects

  1. Click “Project” tab (found on the left panel of Aptana environment).
  2. Create a new project (right click, New -> Project…).
  3. (on New Project window, under Aptana Projects) Select “PHP Project“.
  4. Click “Next” button, type in your project name then click “Finish” button.
  5. Select and right click on the newly created project and click on “Properties“.
  6. Select “Project Natures“.
  7. Tick “com.aptana.ide.editor.php.phpnature (PHP Nature)“.
  8. Then click “Ok” button.

Remote Projects

If your working with remote files (remote server or hosted site) then steps are different but almost similar to the above.

  1. Click “Project” tab (found on the left panel of Aptana environment).
  2. Create a new project (right click, New -> Project…).
  3. (on New Project window, under Aptana Projects) Select “Existing Hosted Site“.
  4. Click “Next” button, type in your project name then click “Next“.
  5. Choose or create a new remote location (FTP or SFTP) then click “Finish” button.

    Please note that the source file needs to be downloaded into your local drive, so choose “Yes” in the Download prompt/window. Be patient and wait for the download to complete.

  6. Select and right click on the newly created project and click on “Properties“.
  7. Select “Project Natures“.
  8. Tick “com.aptana.ide.editor.php.phpnature (PHP Nature)“.
  9. Then click “Ok” button.

After doing the changes in the source file, you can use the “Smart Sync” feature of Aptana to synchronize your local and remote source files. Another cool feature of Aptana.

Hope this helps!

A Little Taste of C#

Microsoft Visual C# Express Edition

Microsoft Visual C# Express

For the past couple of days, I’ve been learning C# language. Thus far, I really enjoy learning C#. Actually after an hour of reading articles/posts and sample codes on the Internet, I was able to dive in and create a simple application. No, not that “Hello world” app, but a useful app for me.

Building Windows application was not new to me. 3 or 4 years ago I’ve built an enterprise application for a medical company using Visual Basic, version 6. I have a lot of fun building that application. Well, it’s an Inventory system, not an average inventory system but a real mind boggling system that will really turn your brain upside-down. What really makes it complicated is the integration of the company’s Business Model. We try to automate everything but within the Business Model there are a lot of complicated processes that will surely twist your brain. But anyway I’m trough with it, solved the problems, and release it just in time. What I am proud of is the result application, which is a very stable and efficient enterprise application. 3+ years running without a glitch, imagine that!

Anyway, I really like C# language. Coming from Visual Basic, C, and PHP, I haven’t had the hard time learning it. I you have the same programming background as I am; surely you’ll be able to learn the language in no time, especially if you’re into OOP paradigm. If you’re a Java developer then transition will be swift.

The first thing to remember before diving right in is in C# language “Everything is an object.” If you’re into OO then you’ll know what I mean.

Don’t worry how messy your codes will be. Just built it! Refactor later! The most important thing right now is for your app to work. Hey! Nobody gets it for the first time. Unless you’re me, right! Haha enjoy and happy programming with C#.

What’s the taste? Sweeeeettt!

Reminders and things to-do:

  1. Download Visual C# Express from Microsoft website. It’s FREE!
  2. Read a lot of samples and article/post on the Internet. Here’s a couple I’ve found (Though I haven’t read them, It might come useful to you.)
    1. Introduction to C#
    2. Learning C# by example
  3. Think of a useful project to do. Plan it and build it!
  4. While building your app, spent the time to refactor your code. You’ll be saving yourself from a lot of headaches when your app turns into a monster code-base.
  5. Always think OO!
  6. Continuously improve your processes.

Subversion: How to copy a branch to an empty trunk

Here’s the scenario:

You have this really cool idea of an OSS project and you have already coded some of its source, though not stable enough for release you’d decided to create and uploaded it on Google Code repository to track the development history. “Trunk tree should only have the stable source”, with this in mind you’d decided to create a branch directory (/1.0) and upload your unstable source in there. After days of hacking and cracking, you finally have a source candidate for the trunk tree. So, how do you copy your candidate branch to the empty trunk?

Remember that when you create a new project on Google Code, your initial repository will already have a branches, tags, and trunk tree.

Using “svn merge” will not do, because you still have an empty trunk.

But how about “svn copy“?

> svn copy https://your-project.googlecode.com/svn/branches/1.0 \
   https://your-project.googlecode.com/svn/trunk/

That wouldn’t do either. Yes it’ll copy all the files and directories inside the “/branch/1.0” directory but it’ll include the “/1.0” directory. Meaning the end result will be “/trunk/1.0“.

https://your-project.googlecode.com/svn/trunk/1.0

You don’t want that, do you? Remember that Trunk directory should always contain the latest and stable source. So the “/1.0” directory will be inappropriate. What you wanted to achieve in your project repository tree, is to look like this:

  • /svn/branches
    • /1.0
      • source.file.1
      • source.file.2
  • /tags
  • /trunk
    • source.file.1
    • source.file.2

Solution

The way to do this (without temporarily deleting the trunk directory) is to first, checkout the candidate branch, change working directory and import.

  1. Checkout the candidate/stable branch:
    > svn co https://your-project.googlecode.com/svn/branches/1.0 branch-1.0
    > cd branch-1.0
    
  2. Import to the empty trunk:
    > svn import https://your-project.googlecode.com/svn/trunk \
       -m 'Stable source from branches/1.0, revision 26.'
    

Pros: Quick and easy, without deleting the current trunk tree.
Cons: What happened on the branch (history) stays on the branch.

Got another solution? I’d love to hear from you.

jstcky: A stick or die JavaScript framework

Got a new project started at Google Code. It’s simple called “jstcky“. It’s a framework written in JavaScript and uses jQuery library that stick or fix a menu/app bar at the bottom of a page. It is inspired by Facebook’s fixed application/chat bar. Please checkout my post on how to fix an element/bar on the bottom of a page.

The project is still undergoing development. So, bugs may crawl and few functionalities as of this time.

I’ve already upload the jstcky codebase on Google Repository under “branches” tree. So do check it out!

Removing .svn directories, recursively

This command can be handy. Let say you want to archive your project from the repository and you don’t want to include the ‘.svn‘ directories.

First, checkout your project from the repository:

svn co http://myproject.domain.org/svn/trunk/ myproject-dir

Second, remove the .svn directories:

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

Then archive it using tar command:

tar -cvzf myproject_archive.tgz myproject-dir

…and there you have it!

python.raven.development

I’m currently working on a small project which is written in Python and based on MVC architecture. Here’s a glimpse of its Apache host config:

<VirtualHost *:80>

ServerName python.raven.com
ServerAdmin webmaster@python.raven.com
DocumentRoot /home/www/python/raven

# logs
ErrorLog /var/log/apache2/python.raven.com-error_log
CustomLog /var/log/apache2/python.raven.com-access_log combined

# set custom handler
<directory /home/www/python/raven>
   SetHandler mod_python
   PythonHandler index
   PythonDebug On
</directory>

# override
<locationmatch>
   SetHandler None
</locationmatch>
Alias /images   /home/www/python/raven/pub/images

</VirtualHost>

The framework’s core will be based on my previous MVC work (written in PHP).

3am Framework

Devel

Devel

It’s already past 3am and I’m still wide awake. My body wants to dive into bed but my mind is still actively trying to figure out if it’s logical to:

* Merge the database class in the model class?
* Unified it into a single object thus lesser layers.
* Should the developer’s model be extendable directly to its controller or it should be automatically be loaded and mapped by the core controller?
* $__LAYOUT, $LAYOUT or $__use_layout?
* Routing mapping: independently defined, separate variables or single array?
* URL: With or without trailing slashes?

…+documentation and a whole lot of ‘em

I guess this is what they call bike shedding but the difference is it’s all happening in my mind. I’m arguing with my self. But so far I think I’m still on the right track in terms goals for my framework.

Oh well! 5+ years of software engineering and I guess I gotten’ used to it. Oh well! Time to linger on this and hopefully I’ll past out later…