Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

eliazar parra

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Ruby Title Case

Capitalize all words in a string with the briefest of snippets!

'some string here'.gsub(/\b\w/){$&.upcase}

HyperScript

HyperScript!

function each(a, f) { for(var i=0, l=a.length; i<l; i++) f(a[i]) };
each('a big blockquote br b center code div em form h1 h2 h3 h4 h5 h6 hr img iframe input i li ol option pre p script select small span strong style sub sup table tbody td textarea tr ul u'.split(' '),
	function(label){
		this[label]=function(){
			var tag=document.createElement(label);
			each(arguments, function(e){ 
				if(e.nodeType) tag.appendChild(e);
				else {
					if(typeof e=='string' || typeof e=='number') tag.innerHTML+=e;
					else for(var p in e) {
						if(p=='style') for(var q in e[p]) tag[p][q]=e[p][q];
						else o[q]=p[q];
					};
				};
			});
			return tag;
		};
	});

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS