Thursday, May 26, 2011

Essential Drupal Modules

This is Outdated: Updated Version: 40 Essential Drupal Modules (1/4/2010)

Via my contact form, someone asked me to list 5 or 10 of the best drupal add ons. I decided to move away from "best", and rather decided to move to "can't live without". Or to put it differently, without these 10 modules, your experience with the minimial base install of drupal is likely to suck. (in spite of my physics teacher I once had who insisted that nothing sucked, but rather blew...).

Anyhow, this list isn't really ordered in any fashion other than the order that I think of ten "can't live without modules". Now -- there are many modules that have dropped my jaw that I haven't included. But that is still because I can still live without the majority of those modules.

10 DRUPAL MODULES THAT WILL KILL YOU IN YOUR SLEEP IF YOU DON'T INSTALL THEM NOW

1. TinyMCE WYSIWYG EDITOR -- Sometimes, we geeks forget that it is we who are the freaks. Most people don't know how to code an image, link, paragraph, unordered list, much less understand how image alignments work. TinyMCE, the only WYSIWYG editor that really works for drupal, opens up the world of webpublishing to this 98.9 percent of the population. Anyone who thinks that visitors who can't code an link aren't worth their time are both stupid, and will likely die cold, broke, and alone.

2. Feedback -- Its a simple module, sure. But every site needs it, and drupal doesn't include it. Sure, not everyone wants a contact form. However, most of those people, I'd argue should stick to blogger and myspace.com. Drupal -- being best suited for serious endevours and serious people needs a freakin' contact form.

3. Blockbar -- A totally underrated module, imho. What does block bar do? It makes all that crap that overwhelms first time drupal users disappear. Its now part of my personal toolkit that I implement on every install. Its role: make drupal friendly to non-cyborg types (e.g. those who haven't worked themselves to death to the point that this entry is their saturday night... wooohooo...)

4. Control Panel -- You know, I bet a few drupal veterns are going to scoff at this mention. However, remember cyborgs: not everyone is a cyborg. The best UI is always going to seek to remind users of soemthing they probably used before (::cough:: control panels on windows, and Mac -- seeing as how they are on the internet, I think its a pretty safe bet they are familiar.) And no, CYGWIN is not a good poster child for "good user interface" (though CYGWIN saves me, an ubercyborg freak hours upon hours every day).

Plain and simple, humans are monkeys -- and monkeys have an easier time navigating in visually rich enviroments, as opposed to enviroments inspired by manilla folders, and tax forms. So, monkeys: pictures good, text and white bad. Use control panels widely in your site, and you'll be amazed how many more people suddenly figure out how to use drupal.

Seriously. Anyone who disagrees on this point can shutup. They are wrong. I'd tell them they were wrong and that they should shutup again if I could.(wait, I just did)

Relax, Control Panels has the most dirt-plain simple API every for adding your own Icons to your own themes. Truly, its worth the download (or an include, or a rewrite then include -- echm, CS).

5. Printer Friendly Pages -- Cyborgs be damned, a large portion of the population "surfs" the web like this:

  1. they find they info they are looking for
  2. they print it out and often file it in a folder if they need it later.

Yes, you could tell these folks to "get with it". However, you'd be a fool to do so. You may want to check up on the relationships between internet access, age, and wealth if you think I'm bluffing, partner. Oh, and this module not only generates very printer friendly pages, but it also parses out your links, and lists them as foot notes on the bottom of the page.

6. Bad Behavior -- Because comment, trackback, malicious scripts, and bad bots will hit your site everyday. This module + 3rd party free libraries of scripts -- imho -- is usually all a medium level traffic site needs to withstand the internet's disgusting onslaught. Of course to be perfectly honest, this script no longer works at my site. However, this being one of 20 drupal sites I've been building, updatingng, or fixing is alright. I'd take a 1/20 percent chance of having to moderate comments if I were you. Its better than trying to delete 3000 spams from 200 nodes when you don't know a lick of MySQL.

7. Simplenews -- An email newsletter management module. It includes easy import/export of subscribers, lets non UID members unsubscribe and subscribe and manages all that info, gives you all the must-have-info on what's happening with your mail blasts, and well -- f#cking a' man -- since enewsletter stopped working about 2 months ago, its really the only good module that I'd trust to a non-cyborg for managing such an uberimport task!

8. Views -- its new, and changing everything.

9. CCK -- going to be hella disruptive to drupal at large. HELL-A hardcore, disruptive, even.

10. CiviCRM -- for god's sake could they get it compatible with 4.7?! Regardless of 4.7's beta status, I have to develop on 4.7 to prevent from screwing people over with obsolete code. I've tried to update it, but its beyond my PHP understanding.

CiviCRM is maybe the only module I know of that could create an industry of consultants all by itself. Moreover, the people who run the project are -- as far as I know -- the most responsive team in the entire industry. If you mention them anywhere on the public internet, you can rest assured they will hear you in 2-5 hours. This is one module, like CCK and Views that has the potential to change everything. That is, when they get it to be compatible with the non-obsolete-developing-for-it-is-a-total-waste-of-time-and-money version of drupal. ;-) O! -- screw Joomla!, get CiviCRM to work with forms API and the world will be shared by we, the open source community forever!

Or, at the very least, it would be really cool*.

*as the kids say.

Wednesday, May 25, 2011

My JS Quiz

I love js quizes. It has been too long since I've seen one pass by and I've saved up a few oddities while creating my parsers and Zeon.js. So at first I planned on creating some fancy form based thingie, but instead I'll just put the questions here and let you think of the answers for a bit. Maybe you can answer them on your own blog. I'll post the answers in a new blog post here in about a week.

I should warn you, these are specification related questions about stuff you usually don't think about or don't even have to know about, unless you like to work with the specification like I do :) I will use ES5 when posting the answers.

The questions are framed in such a way that they don't try to give away the answers for a previous question, although that's very difficult in some cases. In any case, don't assume a follow up question to give you the answer for a previous or following question ;) I can reveal you that I did pull some fancy reversed psychology trick on you people at least once ;) So be warned...

Try to answer them without actually testing it first. It's all the more fun that way. Then after you gave the answer, test it in your console :)

Assume a clean environment, NaN, undefined and such are what they ought to be. Answers such as "who knows" are never valid here ;)

This is not an actual submission form! You cannot submit the results! The inputs are merely there for your convience of looking back.



1: What's the scope lookup depth for the variablese,f,g and h when they are actually used?
So when they are accessed in the inner-most catch. For instance, x in var x; function(){ x; } has a scope lookup depth of two. The function scope and the global scope.

Code:
var f;
try{}
catch(e){
try{
var h;
} catch(g){
e,f;
g,h;
}
}




2: How do you get two succeeding forward slashes in a js source without creating a single line comment or having them be the body of another token?
So "//" is not the answer, neither is /\// and /* // */, etc. No space allowed between the slashes. Two answers possible (that I know of).

1
2


3: Is the semi after while in a do ... while required?
So is do .. while(..) x(); valid?

yes no


4: When parsing tokens, which token are you more likely to encounter: the regular expression token or the division token?
For instance, a token with a semi-colon only occurs at the end of a statement and within a for-header...

regex division


5: What should be the value of e after the following snippet?

Code:
var e = 5;
try {
var e = 6;
} catch(e) {
var e = 7;
}





6: For how many different type of things is the forward slash (/) used in js?
For instance, the + is used for addition and string concatenation.




7: Name them ;) (from 6)




8: Is l33t a valid regular expression flag?
So is var r = /.../l33t; valid js?

yes no


9: May a regular expression contain newlines?
The actual character, not the escape sequence \n

yes no


10: May strings contain newlines?
The actual character, not the escape sequence \n

yes no


11: Is the space between 5 and in required?
for (5 in x) ..

yes no


12: Is the space between return and a string required?
return "foo";

yes no


13: Is the space between a division (/) and a regular expression required?
5 / /.*/

yes no


14: Is the space between return and a number required?
return 10;


15: What regular expression matches the empty string?
So what should regex be to make regex.test("") be true.




16: Can a backslash (\) occur somewhere in a variable name in the source code?

yes no


17: What is the result of f after this statement?

Code:
new function f(){
f = 5;
};





18: Whats the result of x after running this snippet?

Code:
var x = 5;
function f(){
x = x;
var x;
}
f();





19: May the default clause of a switch be placed before the last case clause?

yes no


20.a: If yes, are the remaining clauses used, ignored or do they cause an error?

used ignored I said no!


20.b: If no, what happens if you do anyways?




21: How many arguments may an accessor getter have?
var x = {get some(a,b,c,...?){ console.log('property read'); }};




22: How many arguments may an accessor setter have?
var x = {set some(a,b,c,...?){ console.log('property write'); }};




23: Are the parentheses required when invoking constructors?
new Person();

yes no


24: Are the parenthesis required when invoking functions?
Person();

yes no


25: Are the parenthesis required when invoking functions which are also constructors?
Person();

yes no


26: What happens if you declare a variable twice in the same scope?

Code:
var x = 5;
var x = "foo";





27: Why does the empty array equal false?
[] == false




28: Must a number start with a digit?
A digit is 0 ~ 9

yes no


29: Why will 2.toString() throw an error?




30: How do you fix the problem at #29?
There are three ways of getting around it (that I know of)

1
2
3


31: What's the longest expression in js you can think of that's still valid and only makes use of unique keywords, single character variables and (single) spaces?
Only alphabetic characters and spaces allowed. For instance, if is a keyword, but not valid in an expression. Neither is function because it requires parens and brackets.




32: What's the name of the property defined in following object literal?
{.3e-10:42}




What's the result value of ... after the expressions that follow it?

Assume the variable already exists if it's not explicitly defined


33: x after x=3?x=4:x=5




34: x in var x = new Array(5).map(function(){ return 0; })




35: x in var x=5,3




36: x in x=1,2




37: c in var C = function(){return C;}; var c = new new C;




38: f in function F(){ return 5; } var f = new F;




39: obj in var obj; (obj={a:1}).b=2;
Thanks to @cowboy




40: x in (x) = 5;




41: x in (1,x) = 5;




42: x in (x,x) = 5;




43: b in var a = {f:function(){return 1;}}; var b = a.f();




44: b in var a = {f:function(){return 1;}}; var b = (a.f)();




45: b in var a = {f:function(){return 1;}}; var b = (1,a.f)();




46: b in var n = NaN; b = n === n;




47: b in var b = NaN === new Number(NaN);
Thanks to @jdalton




48: b in var b = isNaN(new Number(NaN));
Thanks to @jdalton




49: b in var b = (function(){return this}).call(1) instanceof Number;
Thanks to @tobeytailor



Which of the following "scripts" are valid?

Assume they would be included as a complete script, as given. Will an error be thrown by the parser?

50: function f(){ break; }
51: x: function f(){}
52: x: switch(y){ break x; }
53: x: x: debugger;
54: x: while (y) x: continue x;
55: x: var x;
56: x: var x = x; break x;
57: x: try { throw y; } catch(e) { break x; }
58: try { throw y; } catch(e) { x: } break x;
59: x: try { throw x; } catch(e) { break x; }
60: if (x) a: debugger; if (y) break a;
61: x:var x;break x;
62: a = b && c = d
63: a & b = c
64: a + b = c
65: a = b ? c = d : e = f
66: a -- b
67: a - - b
68: a- -b
69: x: break x;

Answers follow in about a week... with explanations. I hope you will learn at least something from this quiz, regardless of your current level :)

If you spot an error, are convinced I meant something else with a certain question or are simply confused by a question please let me know on twitter :)