Shapes of CSS

This is a revision of an older article I wrote about creating triangles with a single div. What is more interesting about this method is that you don’t require any special CSS properties and it is 100% CSS 1+ compliant.

So how does this work?

I created a jsFiddle with all the shapes that can be created without CSS3. Open it for examples and source code.

Now we’ll start simply by creating something as simple as a square…

.square {
    width: 200px;
    height: 200px;
    background: #366787;
}

CSS Square

Ok, but that doesn’t have to do with triangles, right? So how do we hack it, to create a triangle?
Well, first of all we should set the element to width and height of 0. The trick is to play with the border.

.triangle {
    height: 0;
    border-width: 0 50px 90px;
    border-style: solid;
    border-color: #366787 transparent;
}

CSS Triangle

Notice how there is no top border, the left and the right are 50px each and the bottom border is 90px;
Also the top and the bottom border have color and the left and right are transparent.

Try it and play with the numbers. Using this method you can create a lot of other figures.

Also take a look at the source code and all the examples on jsFiddle.

Before installing ruby from source in Linux, make sure you have the following installed:

libyaml-dev
libreadline6-dev

Then cd into /tmp. There you’ll need to download the latest ruby source from http://ruby-lang.org
The latest version now is Ruby 2.0, which’s source is available from here:

http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz

Now you’ll need to download and extract the archive contents:

wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
taz xvf ruby-2.0.0-p0.tar.gz

You should know the magic:

cd ruby-2.0.0-p0
./configure
make -j 3 # three is the number of cores your processor have + 1. Use it to speed up compilation time
make install # Should be ran as root. `sudo make install` on Debian based distributions

Now you have ruby. Run ruby -v to confirm it.

As a normal Ruby developer you’ll also need RubyGems. Copy the link from their website and download the archive. Then install it by running ruby setup.rb

wget http://production.cf.rubygems.org/rubygems/rubygems-2.0.3.tgz
tar xvf rubygems-2.0.3.tgz
cd rubygems-2.0.3
ruby setup.

It was a while ago when Leap Motion, Inc introduced us with their invention. As soon as they started the development program I signed up for it. My application was approved several weeks ago and earlier this morning I received my developer unit.

It’s a fantastic device! It is astonishing how accurately it measures your position in 3D space. Now you can grab, move and modify things on your screen as they were really there. It will certainly give a new way of interacting with computers in future.

It looks really stylish – smooth like an iPhone and with the same colors too.

It took me some time to calibrate the device, to get it up and running. Since the technology is very new, it has lots of software issues, but I believe they’ll be fixed in the near future.

Their SDK isn’t that complex too. The device creates a socket server which you can connect to and then receive its data. It is available for the most widely used languages like C++, C#, Java and even JavaScript. Now with technologies like WebSockets we can connect to the device and embed such logic even in web pages.

Duck Debugging

I just got my Christmas present from a friend. It’s a “Professional Duck Debugger”. A very nice present, “Something which every programmer should have” – as he said. Here is the Wikipedia article on Duck Debugging.
Scientists have discovered, that when you are talking aloud it involves more parts of your brain, than when you are just thinking. It triggers parts of your brain involved in moving your diaphragm, tongue and lips. Hearing woods triggers parts of the brain connected to the ears. Well sometimes it’s  certainly a bad strategy, but when you describe your problem to the duck, the solution becomes obvious. Also that way nobody would even think you have psychic problems when talking to yourself. :)

Here are some images of my Professional Duck Debugger:
image

image