Tuesday, March 31, 2015
GIMP: Resize A Large Photo
Resizing images is a common task that you have to do to show your photo image on a website. Most digital camera or smart phones takes photos that are a lot larger than what most web sites can display in it's original size. In this blog we will show you how to resize your photo in GIMP.
Step By Step Instructions:
1. Open the original photo in GIMP
As you can see the photo has the dimension of 2048x1530, not suitable for web display
2. Click Image → Scale Image
3. The "Scale Image" dialog box will be displayed. The link icon puts a constrain on the width and the height to be propositional. Usually it is the best option, however you need to specify an exact width and height value you can click on the link icon to input your own width and height. For this blog we will leave the width and height linked.
4. Type in the new width and height for the image, for this image I am going to type in 600 for the width, the height field will be adjusted automatically to be proportionate with the new width. Note you have to click on the height field for the height to be adjusted. This might be a bug. Click on the "Scale" button, and the image will be resized.
As you can see from the top status bar the image now has the dimension of 600x448
5. Now that we have the resized image we can export our image as a .jpeg file
6. To export the image click File → Export As, once the "Export Image" dialog is displayed, expand the "Select File_Type (By Extension)
7. Select "JPEG image" File Type
8. In the "Name" field give your resized photo a name.
9. Click the "Export" button
10. Accept the default export settings, and then click "Export" again
And here is the resized photo, suitable for the web.
GIMP: Resize A Large Photo
Resizing images is a common task that you have to do to show your photo image on a website. Most digital camera or smart phones takes photos that are a lot larger than what most web sites can display in it's original size. In this blog we will show you how to resize your photo in GIMP.
Step By Step Instructions:
1. Open the original photo in GIMP
As you can see the photo has the dimension of 2048x1530, not suitable for web display
2. Click Image → Scale Image
3. The "Scale Image" dialog box will be displayed. The link icon puts a constrain on the width and the height to be propositional. Usually it is the best option, however you need to specify an exact width and height value you can click on the link icon to input your own width and height. For this blog we will leave the width and height linked.
4. Type in the new width and height for the image, for this image I am going to type in 600 for the width, the height field will be adjusted automatically to be proportionate with the new width. Note you have to click on the height field for the height to be adjusted. This might be a bug. Click on the "Scale" button, and the image will be resized.
As you can see from the top status bar the image now has the dimension of 600x448
5. Now that we have the resized image we can export our image as a .jpeg file
6. To export the image click File → Export As, once the "Export Image" dialog is displayed, expand the "Select File_Type (By Extension)
7. Select "JPEG image" File Type
8. In the "Name" field give your resized photo a name.
9. Click the "Export" button
10. Accept the default export settings, and then click "Export" again
And here is the resized photo, suitable for the web.
Step By Step Instructions:
1. Open the original photo in GIMP
As you can see the photo has the dimension of 2048x1530, not suitable for web display
2. Click Image → Scale Image
3. The "Scale Image" dialog box will be displayed. The link icon puts a constrain on the width and the height to be propositional. Usually it is the best option, however you need to specify an exact width and height value you can click on the link icon to input your own width and height. For this blog we will leave the width and height linked.
4. Type in the new width and height for the image, for this image I am going to type in 600 for the width, the height field will be adjusted automatically to be proportionate with the new width. Note you have to click on the height field for the height to be adjusted. This might be a bug. Click on the "Scale" button, and the image will be resized.
As you can see from the top status bar the image now has the dimension of 600x448
5. Now that we have the resized image we can export our image as a .jpeg file
6. To export the image click File → Export As, once the "Export Image" dialog is displayed, expand the "Select File_Type (By Extension)
7. Select "JPEG image" File Type
8. In the "Name" field give your resized photo a name.
9. Click the "Export" button
10. Accept the default export settings, and then click "Export" again
And here is the resized photo, suitable for the web.
Monday, March 30, 2015
GIMP Layout : Single Window Mode
Most new users to GIMP gets intimidated with the floating windows that is the default view when you first open GIMP.
As you can see it is pretty intimidating, the majority of users sees this interface and runs back to GIMP's more expensive alternatives. Even though GIMP has most of the features of the more expensive softwares. Most back end developers I encountered would hear good things about GIMP, download the software. Get all excited about it, then when they first open it, their reaction is what in the world !@#$$$ (NC-17 censored) is this. They would go back and use paint as their photo editor. Which is a shame, because GIMP is quite powerful.
However, there's a very easy solution to this UI dilemma and make GIMP more user friendly.
Step-By-Step Instructions:
- Click → Windows → Single Window Mode
- GIMP will dock all the floating windows into a single window, looking like all the other conventional programs that you are used to
3. The next step is optional, if you feel more comfortable with the single window mode, you can save the current positions by clicking on Edit → Preferences
4. In the Preferences dialog, select "Window Management", then click on the button "Save Window Postions Now", make sure the "Save window positions on exit" is checked, then click "OK"
5. Now close GIMP and open it again, you will see that the single window mode is used instead of the default view.
GIMP Layout : Single Window Mode
Most new users to GIMP gets intimidated with the floating windows that is the default view when you first open GIMP.
As you can see it is pretty intimidating, the majority of users sees this interface and runs back to GIMP's more expensive alternatives. Even though GIMP has most of the features of the more expensive softwares. Most back end developers I encountered would hear good things about GIMP, download the software. Get all excited about it, then when they first open it, their reaction is what in the world !@#$$$ (NC-17 censored) is this. They would go back and use paint as their photo editor. Which is a shame, because GIMP is quite powerful.
However, there's a very easy solution to this UI dilemma and make GIMP more user friendly.
Step-By-Step Instructions:
3. The next step is optional, if you feel more comfortable with the single window mode, you can save the current positions by clicking on Edit → Preferences
4. In the Preferences dialog, select "Window Management", then click on the button "Save Window Postions Now", make sure the "Save window positions on exit" is checked, then click "OK"
5. Now close GIMP and open it again, you will see that the single window mode is used instead of the default view.
As you can see it is pretty intimidating, the majority of users sees this interface and runs back to GIMP's more expensive alternatives. Even though GIMP has most of the features of the more expensive softwares. Most back end developers I encountered would hear good things about GIMP, download the software. Get all excited about it, then when they first open it, their reaction is what in the world !@#$$$ (NC-17 censored) is this. They would go back and use paint as their photo editor. Which is a shame, because GIMP is quite powerful.
However, there's a very easy solution to this UI dilemma and make GIMP more user friendly.
Step-By-Step Instructions:
- Click → Windows → Single Window Mode
- GIMP will dock all the floating windows into a single window, looking like all the other conventional programs that you are used to
3. The next step is optional, if you feel more comfortable with the single window mode, you can save the current positions by clicking on Edit → Preferences
4. In the Preferences dialog, select "Window Management", then click on the button "Save Window Postions Now", make sure the "Save window positions on exit" is checked, then click "OK"
5. Now close GIMP and open it again, you will see that the single window mode is used instead of the default view.
Thursday, March 26, 2015
C# : Automatically Implemented Properties
There are times when you see a class property without it's private member counterpart and all you see is the {set; get;} accessors. What you are looking at are auto properties that you can create in C#, the only requirements is that the set; and get; accessors contains no logic. Usually there are private members that the properties expose to other classes using the get/set accessors, like the code below:
public class Product
{
private int productId;
private string name;
private string description;
private decimal price;
public int ProductId
{
get
{ return productId; }
set
{
productId = value;
}
}
public string Name
{
get
{ return name; }
set
{
name = value;
}
}
public string Description
{
get
{ return description; }
set
{
description = value;
}
}
public decimal Price
{
get
{ return price; }
set
{
price = value;
}
}
}
The above class uses the regular ways you define properties that are exposed to other classes. Even though there are only get/set properties. The auto implemented version of the class requires a lot less typing.
public class ProductThe properties do not have be define as a private member of the class. This pattern is called the field-backed property pattern. This means that the C# compiler will take care of the private members fields for us when we build our classes. The above example are mutable properties, meaning outside classes can change the values of the properties.
{
public int ProductId { get; set; }
public string Name { get; set;}
public string Description { get; set; }
public decimal Price { get; set; }
}
To create immutable properties, all you have to do is add the keyword private to the set; accessors. Immutable properties, means that the properties are only changeable within the class itself. Outside classes can only read the properties.
public class Product
{
public int ProductId { get; private set; }
public string Name { get; private set;}
public string Description { private get; set; }
public decimal Price { get; private set; }
}
C# : Automatically Implemented Properties
There are times when you see a class property without it's private member counterpart and all you see is the {set; get;} accessors. What you are looking at are auto properties that you can create in C#, the only requirements is that the set; and get; accessors contains no logic. Usually there are private members that the properties expose to other classes using the get/set accessors, like the code below:
The above class uses the regular ways you define properties that are exposed to other classes. Even though there are only get/set properties. The auto implemented version of the class requires a lot less typing.
To create immutable properties, all you have to do is add the keyword private to the set; accessors. Immutable properties, means that the properties are only changeable within the class itself. Outside classes can only read the properties.
public class Product
{
private int productId;
private string name;
private string description;
private decimal price;
public int ProductId
{
get
{ return productId; }
set
{
productId = value;
}
}
public string Name
{
get
{ return name; }
set
{
name = value;
}
}
public string Description
{
get
{ return description; }
set
{
description = value;
}
}
public decimal Price
{
get
{ return price; }
set
{
price = value;
}
}
}
The above class uses the regular ways you define properties that are exposed to other classes. Even though there are only get/set properties. The auto implemented version of the class requires a lot less typing.
public class ProductThe properties do not have be define as a private member of the class. This pattern is called the field-backed property pattern. This means that the C# compiler will take care of the private members fields for us when we build our classes. The above example are mutable properties, meaning outside classes can change the values of the properties.
{
public int ProductId { get; set; }
public string Name { get; set;}
public string Description { get; set; }
public decimal Price { get; set; }
}
To create immutable properties, all you have to do is add the keyword private to the set; accessors. Immutable properties, means that the properties are only changeable within the class itself. Outside classes can only read the properties.
public class Product
{
public int ProductId { get; private set; }
public string Name { get; private set;}
public string Description { private get; set; }
public decimal Price { get; private set; }
}
Wednesday, March 25, 2015
JQuery: Using JQuery CDN Set Up
In this blog I will go over how to set up jQuery for your web pages. There are two methods to using jQuery. The first is the use the CDN URLs that are hosted by jQuery, Google, and Microsoft just to name a few. In this tutorial we will set the CDN from Google. The process should be the same for jQuery and Microsoft CDNs.
Here are the URL for Google's jQuery Library:
https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
You might be wondering why there are two versions of jQuery 1.x and 2.x, they both use the same APIs and they pretty much mirror each other on a release basis. The only difference is that the 2.x versions does not support IE 6,7, or 8. Just to be on the safe side I always use the 1.x versions.
<!DOCTYPE html>Now add the following script tag to the head element
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
</body>
</html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
To test if jQuery is working write a simple alert message using the $ sign, which is short hand the jQuery object.
<script>
$(document).ready(alert("jquery is
working"));
</script>
You should see an alert message that says "jquery is working" when you load the page.
Here is the complete markup code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(alert("jquery is working"));
</script>
</head>
<body>
</body>
</html>
JQuery: Using JQuery CDN Set Up
In this blog I will go over how to set up jQuery for your web pages. There are two methods to using jQuery. The first is the use the CDN URLs that are hosted by jQuery, Google, and Microsoft just to name a few. In this tutorial we will set the CDN from Google. The process should be the same for jQuery and Microsoft CDNs.
1.x snippet: 2.x snippet:
You might be wondering why there are two versions of jQuery 1.x and 2.x, they both use the same APIs and they pretty much mirror each other on a release basis. The only difference is that the 2.x versions does not support IE 6,7, or 8. Just to be on the safe side I always use the 1.x versions.
So here are the steps to using jQuery in your web page:
1. First create an HTML5 page markup
To test if jQuery is working write a simple alert message using the $ sign, which is short hand the jQuery object.
You should see an alert message that says "jquery is working" when you load the page.
Here is the complete markup code
Here are the URL for Google's jQuery Library:
https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
You might be wondering why there are two versions of jQuery 1.x and 2.x, they both use the same APIs and they pretty much mirror each other on a release basis. The only difference is that the 2.x versions does not support IE 6,7, or 8. Just to be on the safe side I always use the 1.x versions.
<!DOCTYPE html>Now add the following script tag to the head element
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
</body>
</html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
To test if jQuery is working write a simple alert message using the $ sign, which is short hand the jQuery object.
<script>
$(document).ready(alert("jquery is
working"));
</script>
You should see an alert message that says "jquery is working" when you load the page.
Here is the complete markup code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(alert("jquery is working"));
</script>
</head>
<body>
</body>
</html>
Tuesday, March 24, 2015
Linux Ubuntu Server: Switching To root User With The sudo Command
Since Ubuntu does not configure the root account by default you have to manually assign root a password before you can use the root account. However, there's a way to log in as "root" without setting up the "root" password. The way to do this is to use the "sudo" and "su" command in combination. The "sudo" elevates your privileges to root like priviledges, while the "su" command is used to switch from one user to another. So when used together you get to log in as "root".
So in your Linux prompt type in the following command
sudo su
enter the password when asked, after you've entered your password you can run commands as "root"
Linux Ubuntu Server: Switching To root User With The sudo Command
Since Ubuntu does not configure the root account by default you have to manually assign root a password before you can use the root account. However, there's a way to log in as "root" without setting up the "root" password. The way to do this is to use the "sudo" and "su" command in combination. The "sudo" elevates your privileges to root like priviledges, while the "su" command is used to switch from one user to another. So when used together you get to log in as "root".
So in your Linux prompt type in the following command
sudo su
enter the password when asked, after you've entered your password you can run commands as "root"
So in your Linux prompt type in the following command
sudo su
enter the password when asked, after you've entered your password you can run commands as "root"
Monday, March 23, 2015
ASP.NET MVC : Upgrade ASP.NET MVC 4 to ASP.NET MVC 5 Using NuGet Part 1
In this blog we will go over how to upgrade your existing project which uses ASP.NET MVC 4 to ASP.NET MVC 5 using NuGet. During the upgrade you will encounter some errors but they are easy enough to fix by changing the Web.Config file. In the first blog we will create a simple ASP.NET MVC 4 application from scratch.
But first thing is first let's begin by creating a project in ASP.NET MVC 4:
- Create a blank solution in Visual Studio call "MVCProjects"
2. Now add a new project to the "MVCProjects" by selecting ASP.NET MVC4, call it "MyMVC4".
Make sure you select Visual C# → Web → Visual Studio 2012 → ASP.NET MVC 4 Web Application, then click "OK"
3. Select the "Empty" template, and "Razor" as the "View Engine", then click "OK"
4. Right click on the "Controller" and select "Add" → "Controller"
5. On the "Add Controller" screen type "HomeController" on the "Controller name" text box and select "Empty MVC controller". We just want to keep things simple for this blog. Then click "Add"
6. You see the "HomeController.cs" class being added to the "Controllers" folder
8. Right click on the "Index()" method and select "Add View"
9. Uncheck the "Use a layout or master page" checkbox. Accept the default settings, MVC uses conventions so the view has the same name as the method name in the "HomeController.cs" file which is "Index()", then click "Add"
10. In the "Views" folder you see that the "Home" folder has been created with the view "Index.cshtml", the .cshtml extension means that the view uses the C# syntax.
11. Double click on the view "Index.cshtml" and type "Hello World" between the <div> tag like the markup below
12. Press Ctrl+F5 to run the application, you will see the following.
In this blog we went over how to create a simple ASP.NET MVC 4 application. In the next part we will go through the steps on how to upgrade your ASP.NET MVC 4 application to ASP.NET MVC 5 using NuGet
3. Select the "Empty" template, and "Razor" as the "View Engine", then click "OK"
4. Right click on the "Controller" and select "Add" → "Controller"
5. On the "Add Controller" screen type "HomeController" on the "Controller name" text box and select "Empty MVC controller". We just want to keep things simple for this blog. Then click "Add"
6. You see the "HomeController.cs" class being added to the "Controllers" folder
7. Double click on the "HomeController.cs" file and you will see the following code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MyMVC4.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
}
}
8. Right click on the "Index()" method and select "Add View"
9. Uncheck the "Use a layout or master page" checkbox. Accept the default settings, MVC uses conventions so the view has the same name as the method name in the "HomeController.cs" file which is "Index()", then click "Add"
10. In the "Views" folder you see that the "Home" folder has been created with the view "Index.cshtml", the .cshtml extension means that the view uses the C# syntax.
11. Double click on the view "Index.cshtml" and type "Hello World" between the <div> tag like the markup below
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<div>
Hello World!
</div>
</body>
</html>
12. Press Ctrl+F5 to run the application, you will see the following.
In this blog we went over how to create a simple ASP.NET MVC 4 application. In the next part we will go through the steps on how to upgrade your ASP.NET MVC 4 application to ASP.NET MVC 5 using NuGet
Labels:
ASP.NET MVC,
ASP.NET MVC 4,
ASP.NET MVC 5,
ASPNET,
Design Pattern,
MVC,
NuGet
ASP.NET MVC : Upgrade ASP.NET MVC 4 to ASP.NET MVC 5 Using NuGet Part 1
In this blog we will go over how to upgrade your existing project which uses ASP.NET MVC 4 to ASP.NET MVC 5 using NuGet. During the upgrade you will encounter some errors but they are easy enough to fix by changing the Web.Config file. In the first blog we will create a simple ASP.NET MVC 4 application from scratch.
But first thing is first let's begin by creating a project in ASP.NET MVC 4:
But first thing is first let's begin by creating a project in ASP.NET MVC 4:
- Create a blank solution in Visual Studio call "MVCProjects"
2. Now add a new project to the "MVCProjects" by selecting ASP.NET MVC4, call it "MyMVC4".
Make sure you select Visual C# → Web → Visual Studio 2012 → ASP.NET MVC 4 Web Application, then click "OK"
3. Select the "Empty" template, and "Razor" as the "View Engine", then click "OK"
4. Right click on the "Controller" and select "Add" → "Controller"
5. On the "Add Controller" screen type "HomeController" on the "Controller name" text box and select "Empty MVC controller". We just want to keep things simple for this blog. Then click "Add"
6. You see the "HomeController.cs" class being added to the "Controllers" folder
8. Right click on the "Index()" method and select "Add View"
9. Uncheck the "Use a layout or master page" checkbox. Accept the default settings, MVC uses conventions so the view has the same name as the method name in the "HomeController.cs" file which is "Index()", then click "Add"
10. In the "Views" folder you see that the "Home" folder has been created with the view "Index.cshtml", the .cshtml extension means that the view uses the C# syntax.
11. Double click on the view "Index.cshtml" and type "Hello World" between the <div> tag like the markup below
12. Press Ctrl+F5 to run the application, you will see the following.
In this blog we went over how to create a simple ASP.NET MVC 4 application. In the next part we will go through the steps on how to upgrade your ASP.NET MVC 4 application to ASP.NET MVC 5 using NuGet
3. Select the "Empty" template, and "Razor" as the "View Engine", then click "OK"
4. Right click on the "Controller" and select "Add" → "Controller"
5. On the "Add Controller" screen type "HomeController" on the "Controller name" text box and select "Empty MVC controller". We just want to keep things simple for this blog. Then click "Add"
6. You see the "HomeController.cs" class being added to the "Controllers" folder
7. Double click on the "HomeController.cs" file and you will see the following code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MyMVC4.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
}
}
8. Right click on the "Index()" method and select "Add View"
9. Uncheck the "Use a layout or master page" checkbox. Accept the default settings, MVC uses conventions so the view has the same name as the method name in the "HomeController.cs" file which is "Index()", then click "Add"
10. In the "Views" folder you see that the "Home" folder has been created with the view "Index.cshtml", the .cshtml extension means that the view uses the C# syntax.
11. Double click on the view "Index.cshtml" and type "Hello World" between the <div> tag like the markup below
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<div>
Hello World!
</div>
</body>
</html>
12. Press Ctrl+F5 to run the application, you will see the following.
In this blog we went over how to create a simple ASP.NET MVC 4 application. In the next part we will go through the steps on how to upgrade your ASP.NET MVC 4 application to ASP.NET MVC 5 using NuGet
Labels:
ASP.NET MVC,
ASP.NET MVC 4,
ASP.NET MVC 5,
ASPNET,
Design Pattern,
MVC,
NuGet
Subscribe to:
Posts (Atom)