background preloader

JS

Facebook Twitter

Essential JavaScript Design Patterns For Beginners. Design patterns are reusable solutions to commonly occurring problems in software design. They are both exciting and a fascinating topic to explore in any programming language. One reason for this is that they help us build upon the combined experience of many developers that came before us and ensure we structure our code in an optimized way, meeting the needs of problems we're attempting to solve. Design patterns also provide us a common vocabulary to describe solutions. This can be significantly simpler than describing syntax and semantics when we're attempting to convey a way of structuring a solution in code form to others.

In this book we will explore applying both classical and modern design patterns to the JavaScript programming language. Target Audience This book is targeted at professional developers wishing to improve their knowledge of design patterns and how they can be applied to the JavaScript programming language. Acknowledgments Credits Reading We already use patterns everyday. Creating a Minimal Blog Design Using HTML5, CSS3 and jQuery - Joel Sutherland. A zip of this project is at the end of the post.

Creating a Minimal Blog Design Using HTML5, CSS3 and jQuery - Joel Sutherland

Redesigning this blog was a long time coming. I had started blogging on my personal site in late 2008 on Posterous, but quickly slowed and then stopped posting when my focus turned to my company blogs (New Media Campaigns, GetHiFi). In restarting my personal blog, I had some goals that I wanted to achieve with the design: Minimal in appearance and codeUses modern web development techniquesTakes advantage of HiFi, our new CMS The net result is something I am fairly proud of. HTML5@font-faceCSS3jQueryHiFi This post is meant to be both a tour of the site and a how-to.

The Design I initially put together the design in photoshop. The page width is 600 pixels, which is my preference for content, especially blogs. Finally, I kept the navigation really simple. The Markup. Day 12 — 3D pixel particles. The Christmas season is pretty much over, but before you take the tree down, and return your baubles to the musty box in the cupboard, we have one final 12 days of CreativeJS post for you.

Day 12 — 3D pixel particles

And it’s a goodie! Today, I’m going to explain a magic formula that can figure out where a 3D point would be on your 2D canvas. Once we know that we can make some 3D pixel particles! A 3D point has an x, y and z position, where z is how far away it is from you. If a point is at 0,0,0 then we are going to render it right in the middle of the screen. The first part of the formula tells us how big or small things should appear at a given z distance : Where fov is a notional field of view, in other words, how zoomed-in or wide-angled our virtual lens is1. Now we know how big things are at that distance, we just multiply our 3D x and y by that scale factor to get our 2D x and y. If you think about it, this kinda makes sense. Get it? And that’s all there is to it.

So let’s make a whole bunch of 3D points! For vs While. Tutorials. Javascript, node.js and for loops. What does this code print out?

Javascript, node.js and for loops

Assume that console.log logs to the console. Experiment #1: For loop console.log('For loop');for(var i = 0; i < 5; i++) { console.log(i);} 0, 1, 2, 3, 4 - easy, right? What about this code? Experiment #2: setTimeout The result is 5, 5, 5, 5, 5.What about this? Experiment #3: Callback function function wrap(callback) { callback();} console.log('Simple wrap');for(var i = 0; i < 5; i++) { wrap(function() {console.log(i)});} 0, 1, 2, 3, 4 — right?

Experiment #4: While loop emulating sleep function sleep(callback) { var now = new Date().getTime(); while(new Date().getTime() < now + 1000) { // do nothing } callback();} console.log('Sleep');for(var i = 0; i < 5; i++) { sleep(function() {console.log(i)});} 0, 1, 2, 3, 4. Experiment #5: Node.js process.nextTick. Fractals, computer graphics, mathematics, demoscene and more. Eloquent JavaScript.