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!

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

HyperScript

HyperScript!

   1  
   2  function each(a, f) { for(var i=0, l=a.length; i<l; i++) f(a[i]) };
   3  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(' '),
   4  	function(label){
   5  		this[label]=function(){
   6  			var tag=document.createElement(label);
   7  			each(arguments, function(e){ 
   8  				if(e.nodeType) tag.appendChild(e);
   9  				else {
  10  					if(typeof e=='string' || typeof e=='number') tag.innerHTML+=e;
  11  					else for(var p in e) {
  12  						if(p=='style') for(var q in e[p]) tag[p][q]=e[p][q];
  13  						else o[q]=p[q];
  14  					};
  15  				};
  16  			});
  17  			return tag;
  18  		};
  19  	});
  20  
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS