Posts

Showing posts from 2013

Writing fast and powerful javascript applications

I just published this article on Assist Software's blog.

http://assist-software.net/blog/writing-fast-and-powerful-javascript-applications

Apache 2.2 Forbidden 403 error

While configuring some virtual hosts for local development, I had some trouble with 403 forbidden error. (Apache/2.2.22)

Fix: add this to your virtualhost

<Directory /path/to/document/root/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
AuthType None
Satisfy Any
Require all granted
</Directory>
Also make sure the document root folder has search permissions (755 is fine)

Sublime text 3 sidebar collapse expand bug or folders missing (fix)

In the latest builds of Sublime Text 3 beta, the sidebar sometimes bugged itself. Either the folders are missing, or not expanding, or sometimes all the files are overlaped.

Workaround: In the menu, Click:
View -> Sidebar -> Show Open Files.
Restart Sublime.

Should work, but let's home the team fies the bug in the following revisions.

Happy coding!

Django emails with html/txt templates

Django Templated Emailis a tool which sends email in django with html/txt templates.

Features:

Html / Txt templates
Context variables
Current site (from sites framework) available in templates as {{ site }} variable

Installation and usage:
Run the following command inside your django's project directory

Bootstrap carousel - fade effect vs slide

To implement a fade transition for your bootstrap carousel, add and use the following class to the carousel main holder.
.carousel.c-fade .item {
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
.carousel.c-fade .active.left,
.carousel.c-fade .active.right {
left: 0;
z-index: 2;
opacity: 0;
filter: alpha(opacity=0);
}
.carousel.c-fade .next,
.carousel.c-fade .prev {
left: 0;
z-index: 1;
}
.carousel.c-fade .carousel-control {
z-index: 3;
}
Example:
<div id="my-carousel" class="carousel slide c-fade">

PHP - Automatic "Table of Contents" based on headers (h1, h2, etc)

Works like a charm.

Also it add automatic ids for your tags, for automatic linking.

Demo here: http://assist-software.net/blog/qualsyst-iso-management-application
function create_automatic_toc($content) {
preg_match_all( '/<h([1-6])(.*)>([^<]+)<\/h[1-6]>/i', $content, $matches, PREG_SET_ORDER );

global $anchors;

$anchors = array();
$toc = '<ul class="toc">'."\n";
$i = 0;

foreach ( $matches as $heading ) {

if ($i == 0)
$startlvl = $heading[1];
$lvl = $heading[1];

$ret = preg_match( '/id=[\'|"](.*)?[\'|"]/i', stripslashes($heading[2]), $anchor );
if ( $ret && $anchor[1] != '' ) {
$anchor = stripslashes( $anchor[1] );
$add_id = false;
} else {
$anchor = preg_replace( '/\s+/', '-', preg_replace('/[^a-z\s]/', '', strtolower( $heading[3] ) ) );

Object has no method 'curCSS'

I was implementing jquery-ui autocomplete on an older project, and came across this error:
Uncaught TypeError: Object function (a,b){return new p.fn.init(a,b,c)} has no method 'curCSS'
Problem: Jquery removed .curCSS() method in 1.8 version.

The solution:  ...

MySql - Cannot delete or update a parent row: a foreign key constraint fails

Have you ever tried to make a relation with a foreign key, and when inserting, you get this error?
Cannot delete or update a parent row: a foreign key constraint fails
Googling this will give you many possible solutions:

foreign key does not exist in the related table
you have invalid data in one of the tables
your foreign key relation is backwards
disable foreign key checks (not cool)

For me, none of these worked.

By mistake, I found the real problem: One of the related tables had a different storage engine.

The Solution: Set the same ...