Lubuntu 13.10 – Install VirtualBox guest additions



1) Installing Vbox guest addition using VBox option, where we choose from the virtualbox menu “Devices” and then Install guest additions does not work directly. So run terminal and log in as the root with choosen password (sudo su). Then:

apt-get update
apt-get upgrade
apt-get intstall dkms

2) Mount the CDROM media with the additions (for example through VBox Devices menu).

3) Open terminal and copy run script from the cdrom (named VBOXADDITIONS_4_2.18_88780 in my case) to somewhere where we are able to run it

cp /path_to_your_cd_rom/VBOXADDITIONS_4_2.18_88780/ /root/
cd /root

4) Now we have to reboot Lubuntu linux to complete guest additions installation complete.

By dbglory Posted in Linux

Make a Layout With Fluid and Fixed-size Columns

CSS is not at its best when it comes to creating a layout. The flexible box model that is intended for this purpose is not yet ready to use due to the lack of support from Internet Explorer, so designers usually have to use floats or set an element’s display property to inline-block to achieve effects they want. This CSS’s inability is even more bothersome when you want to make your website responsive.

In this post I’ll focus on a specific problem — that is how to write styles when you want to have a fluid content box together with a fixed-size content box that are next to each other and they’re taking the same horizontal space.

Let's make a responsive layout with fluid and fixed content with HTML and CSS


Continue reading

By dbglory Posted in HTML 5

Building a Responsive Two Column Layout

  • Demo
  • CodePen
  • Github Repo
  • Use min-width media queries to progressively enhance the layout of the design.
  • Use “box-sizing: border-box” to calculate borders as part of the total width of an element.
  • Use Scott Jehl’s Respond.js polyfill for min/max-width CSS3 Media Queries (for IE 6-8, and more).
  • All wireframes were created using Balsamiq Mockups. I highly recommend this tool for making quick wireframes.

Continue reading

By dbglory Posted in HTML 5

Disable ctrl + n and other ctrl + key combinations in JavaScript

Few days ago Vijay asked if there’s a way to disable ctrl + n combination (open the new window shortcut. So I set out to create a small Java Script that disables any ctrl + key combination (e.g. ctrl + v, ctrl + c, ctrl + a, etc.).

Script is a bit more complicated than Disable form submit on enter keypress and it should work in both Fire Fox and Internet Explorer.

Continue reading

$watch How the $apply Runs a $digest

UPDATE: This post is meant for beginners, for those that just started to learn Angular and want to know how data-binding works. If you already know how to use Angular properly, I highly suggest you go to the source code instead.

Angular users want to know how data-binding works. There is a lot of vocabulary around this: $watch$apply$digestdirty-checking… What are they and how do they work? Here I want to address all those questions, which are well addressed in the documentation, but I want to glue some pieces together to address everything in here, but keep in mind that I want to do that in a simple way. For more technical issues, check the source.

Let’s start from the beginning. Continue reading

Save a Base64 Encoded Canvas image to a png file using PHP

This and the next post will demonstrate how to draw on a canvas and then save the file on a server using PHP. Here is the very simple server side code:

// requires php5
define(‘UPLOAD_DIR’, ‘images/’);
$img = $_POST[‘img’];
$img = str_replace(‘data:image/png;base64,’, ”, $img);
$img = str_replace(‘ ‘, ‘+’, $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . ‘.png’;
$success = file_put_contents($file, $data);
print $success ? $file : ‘Unable to save the file.’;

The next post will be the slightly more complicated front-end code. This was particularly designed for a Sencha Touch iPad app that will allow people to sign with their finger. It has some flaws, but the basics are pretty reusable and good!

Your result may look something like this:

Copy from
By dbglory Posted in PHP

AngularJS and scope.$apply

If you’ve written a non-trivial amount of code in AngularJS, you may have come across the $scope.$apply() method. On the surface, it may seem like just a method you call to get your bindings to update. But why does it exist? And when do you need to use it?

To really understand when to use $apply, it’s good to know exactly why we need to use it, so let’s dive in!

JavaScript is Turn Based

The JavaScript code we write doesn’t all run in one go, instead it executes in turns. Each of these turns runs uninterupted from start to finish, and when a turn is running, nothing else happens in our browser. No other JavaScript code runs, and our web page interface is completely frozen. This is why poorly coded JavaScript can freeze a web page. Continue reading

Stored Procedures in MySQL and PHP

Put simply, a Stored Procedure (“SP”) is a procedure (written in SQL and other control statements) stored in a database which can be called by the database engine and connected programming languages.

In this tutorial, we will see how to create an SP in MySQL and execute it in MySQL server and in PHP.

Note: We are not going to cover the full aspect of the SP here. The official MySQL document should always be the place for reference. Continue reading

By dbglory Posted in PHP