Currently browsing: Code Snippets

Transformed elements have a non-static position

Recently I discovered a CSS feature that took me by surprise. Apparently if you apply a CSS transformation to an element, it’s position is considered as non-static, even when element.style.position === ‘static’. Here is a codepen that proves this. As far as I can tell, this is happening on all browsers that implement CSS transforms.

Continue reading →

Best practice

If you did any development in AngularJS, I’m sure you know about the $watch function. On every digest cycle, Angular will evaluate an expression to see if its value changes. If it did, it will fire all the listeners on that particular watch. Of course, this can be very expensive as your app grows and […]

Continue reading →

Quick tip

If you are using protractor to test your webapps, then you are inevitably using Promises. Sometimes you might want to create an immediately resolved/rejected promise. Typically you would write this: But you can just as easily write the same thing like this: Much easier!

Continue reading →

Use Github to display 3D objects

Embedding Gists into websites is quite easy thanks to github. But did you know Github also allows you to embed a live 3D viewer for any stl file? Seriously Github, you are awesome! Example: This: <script src=”https://embed.github.com/view/3d/skalnik/secret-bear-clip/master/stl/clip.stl”></script> Becomes this:

Continue reading →

Setting environment variables in Angular using Grunt

I’ve come across an interesting problem recently. While developing an angular app, I needed to switch from a live web service to a local web service during the development. And this got me thinking: “This is the perfect situation where different environments would be incredibly useful”. Instead of manually changing the endpoints of the web […]

Continue reading →

Java MVC Framework

This post describes a Java MVC framework I use currently on one of my projects. It is a very basic stripped down version, with no functionality whatsoever. But it is a useful starting point for some projects written in Java and it should save a couple of minutes in the future.

Continue reading →

A smarter way to get the post thumbnail

Post thumnails are a new feature introduced in WordPress 2.9 and it lets you assign a representative image to your posts/pages/custom posts. It is very useful in archive pages where you have limited space for each article. But what if you don’t have a featured image for your post? What if you don’t need or […]

Continue reading →

How to get related posts in WordPress

Much too often, we see a ‘Related posts’ section after reading an article. However, there is no built-in widget/function to get these in WordPress. Many blogs implement their own way to get these or use a plugin to do it, most often finding posts from the same category and with the same tags. For those […]

Continue reading →