Tuesday, February 15, 2011

Remove item from array with jQuery

Remove item (number or string) from array, using jQuery (method grep).



arr = [1, 2, 3, 4, 5] // array initial
var removeItem = 2;   // item do array que deverá ser removido


arr = jQuery.grep(arr, function(value) {
        return value != removeItem;
      });


// new array

Friday, December 31, 2010

How many Drupal sites are there in the world?


How do you find "all" the Drupal sites that Google knows about?
A post on drupal.org suggests Add New Comment, but that wont be entirely accurate. So far I have come up with a search that lists all sites with a User Account page on user/login:
intitle:"User account" inurl:"user/login"
Or you can use this link to search for drupal sites in Google.
I am aware this only lists sites with user login linked to somewhere and not blocked by Robots.txt.
I have also seen suggestions that looking for a CSS file might work, however with Drupal's CSS aggregation, this could be difficult.
Please share any alternatives, my search above (currently) shows around 2,620,000  (on Google UK). How can we make this better?

Wednesday, December 22, 2010

How to display sub menus (children) of primary links in drupal?

Step 1 : Since we'll be using php codes in a block to display menu, the first thing to do is to enable the PHP Filter under modules.
Step 2 : Go to administer->block->add block and create a new block. Add a description (i use submenu). Choose PHP Code as the filter and paste the code below in the body textarea.

<?php
$menuItems = menu_tree_page_data('primary-links'); 

foreach($menuItems as $key => $m) {
      //check current active menu
   if ($m['link']['in_active_trail'] && $menuItems [$key]['below']) {
       $menu = menu_tree_output($menuItems [$key]['below']);
   }  
}

//print the menu
print $menu;
?>
 
Make sure you include the php delimiters in your code. Press save.
Step 3 : Place your block in a region you want. and that's it. next time you select a menu item in the primary links, the children menu items will show in this block.
You can use active-trail to style the selected menu item.

Alternatively, you may use Menu Block module which can do the same without writing a single line of code. Let me know if you need any guidence.

Sunday, November 21, 2010

25+ Must-Have Cheat Sheets for Web Developers


Who wants to go to Google or break out the library of programming books every single time you get stuck on something? Below is a compilation of extremely useful cheat sheets, which can be printed, laminated and placed nearby for easy reference while doing your web development and design. Everyone has moments where a function cannot be remembered, and that is where these cheat sheets can be lifesavers. Bookmark this page for an easy portal to all of the cheat sheets, or an individual page if you find it helpful. Please don’t hesitate to post any cheat sheets we neglected to include, for this is about sharing knowledge. 

With Courtesy: Chris Strosser.

1. PHP


PHP Cheat Sheet

http://www.addedbytes.com/cheat-sheets/php-cheat-sheet/

2. MySQL


MySQL Cheat Sheet
http://www.addedbytes.com/cheat-sheets/mysql-cheat-sheet/

3. JavaScript


JavaScript Cheat Sheet
http://www.addedbytes.com/cheat-sheets/javascript-cheat-sheet/

4. CSS


CSS Cheat Sheet
http://www.addedbytes.com/cheat-sheets/css-cheat-sheet/

5. Regular Expressions

Regular Expressions Cheat Sheet

http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/

6. Apache’s mod_rewrite


mod_rewrite Cheat Sheet
http://www.addedbytes.com/apache/mod_rewrite-cheat-sheet/

7. jQuery


jQuery Cheat Sheet
http://acodingfool.typepad.com/blog/pdf/jquery_1.3_cheatsheet_v1.pdf

8. HTML


HTML Cheat Sheet
http://www.addedbytes.com/cheat-sheets/html-cheat-sheet/

9. HTML Character Entities


HTML Entities Cheat Sheet
http://www.addedbytes.com/cheat-sheets/html-character-entities-cheat-sheet/

10. RGB Hex Color Codes


RGB Color Codes Cheat Sheet
http://www.addedbytes.com/cheat-sheets/colour-chart/

11. .htaccess


.htaccess Cheat Sheet
http://www.thejackol.com/htaccess-cheatsheet/

12. Apache


Apache Cheat Sheet
http://www.petefreitag.com/cheatsheets/apache/

13. SEO


SEO Cheat Sheet
http://www.seomoz.org/blog/the-web-developers-seo-cheat-sheet

14. Gmail


Gmail Cheat Sheet
http://www.marcofolio.net/cheat_sheets/gmail_keyboard_shortcuts_cheat_sheet.html

15. HTML5


HTML5 Cheat Sheet
http://www.smashingmagazine.com/2009/07/06/html-5-cheat-sheet-pdf/

16. Google Analytics


Google Analytics Cheat Sheet
http://www.searchenginejournal.com/the-huge-collection-of-google-analytics-tips/7426/

17. WordPress Cheat Sheets


WordPress Cheat Sheets
http://speckyboy.com/2009/06/17/14-essential-wordpress-development-and-design-cheat-sheets/

18. Subversion


Subversion Cheat Sheet
http://www.addedbytes.com/cheat-sheets/subversion-cheat-sheet/

19. Eclipse


Eclipse Cheat Sheet
http://refcardz.dzone.com/refcardz/getting-started-eclipse?oid=hom7187

20. Google Search Engine


Google Cheat Sheet
http://www.google.com/help/cheatsheet.html

21. Twitter


Twitter Cheat Sheet
http://jasontheodor.com/2009/04/28/twitter-tweet-sheet-2/

22. CakePHP


CakePHP Cheat Sheet
http://cakephp.org/files/Resources/CakePHP-1.2-Cheatsheet.pdf

23. Joomla


Joomla 1.5 Cheat Sheet
http://www.younic.de/joomla-basic-template-cheatsheet

24. CodeIgniter


CodeIgniter Cheat Sheet
http://designfellow.com/blog/freebies/codeigniter-quick-reference-cheat-sheet-version-2-0-released/

25. Drupal


Drupal Cheat Sheet
http://www.inmensia.com/files/pictures/internal/CheatSheetDrupal4.7.png

26. Firebug


Firebug Cheat Sheet
http://duvet-dayz.com/firebug-cheatsheet/