tag:blogger.com,1999:blog-4821457672065835842024-03-13T16:57:29.859+00:00Sunset SoftwareA blog about Linux, PHP, CSS, SQL, HTML, JavaScript, jQuery and Technology in general.Unknownnoreply@blogger.comBlogger71125tag:blogger.com,1999:blog-482145767206583584.post-62881159547494847642013-04-30T01:00:00.000+01:002013-04-30T01:00:03.551+01:00Blog closed<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
</style>
<div class="article">
<p>After 27 months I have published posts and videos at Youtube, I decided to have a new chapter of my life. I will stop to blogging at May 1<sup>st</sup> 2013. If you want to contact me, please contact me via Twitter. I would like to thanks to my readers and God for opportunity to blogging tutorials and another stuff.</p>
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-482145767206583584.post-59621724375244235402013-04-25T13:32:00.000+01:002013-04-25T13:32:00.530+01:00How to create a virtual interface on CentOS or Debian<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
.article #code{
background-color: #000;
color: #0F0;
border:2px solid #0F0;
padding:10px 40px;
border-radius:25px;
-moz-border-radius:25px; /* Old Firefox */
font-size: 14px;
font-family: "Courier New","Lucinda Console", monospace;
}
.article #red{
color: #F00;
}
.article table{
border: 1px solid #000;
text-align: center;
}
.article th{
background-color: #8a2be2;
color: #000;
}
.article #paint{
background-color: #cdb79e;
}
.article #question{
font-style: italic;
}
.article ol{
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
</style>
<div class="article">
<p>I was working on my DNS server and I wanted to create a virtual interface to distinguish internal requests from external requests. The command to create a virtual interface is:</p>
<div id="code">ifconfig eth0:0 199.133.189.122 netmask 255.255.255.192 up</div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-14069221927305661572013-04-16T12:39:00.002+01:002013-04-16T12:39:44.883+01:00Design Patterns - Observer Pattern<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 14px;
}
.article #book{
text-transform: uppercase;
margin: 5px;
padding: 5px;
color: #fff;
background-color: #f00;
border-radius: 10px;
-moz-border-radius:10px /*Old firefox*/
}
.article img{
display:block;
margin-left:auto;
margin-right:auto;
}
</style>
<div class="article">
<h1>Introduction</h1>
<p>A design pattern is a specific way of solving a particular problem. They are not simply about reusing code; they are more abstract and generalized than that. They are about using reusing ideas.</p>
<h1>The Observer Pattern</h1>
<p>Often, you'll have data in your application in your application that changes over time. Say that you have some GUI components that are required to show this data and update it when it changes. How would you handle it? One solution might be to pass the newly updated data to a method of the GUI component so that could redraw the information. A problem with this approach is remembering to do that each time the data is updated. What if it's not clear how often the data will be updated, and whether you want the GUI to update automatically when it does?</p>
<p>The observer pattern solves this problem by using two interfaces, <i>Observer</i> and <i>Observable</i>. As the names suggests, the <i>Observer</i> "watches" the <i>Observable</i> to see whether it changes.</p>
<p><i>Keeping with the theme of human senses, an <u>Observer</u> is sometimes called a <u>Listener</u>, but for this chapter we stick with the former name.</i><p/>
<p>In its most basic implementation, the <i>Observable</i> can add <i>Observers</i>. <i>Observable</i> then is responsible for notifying them if anything about its state has changed, and the <i>Observer</i> is responsible for reacting to the change. In this example, our data is the <i>Observable</i> and the GUI components are the <i>Observers</i>. If the data changes, those changes will automatically be reflected in any GUI component that is an <i>Observer</i> of the data. Next figure demonstrates the observer pattern</p>
<a href="http://2.bp.blogspot.com/-8Y6Vt8ZF7tA/UT8PAH_ajJI/AAAAAAAAAlI/N3NjjueVheA/s1600/img011.jpg" imageanchor="1" ><img border="0" src="http://2.bp.blogspot.com/-8Y6Vt8ZF7tA/UT8PAH_ajJI/AAAAAAAAAlI/N3NjjueVheA/s320/img011.jpg" /></a>
<h3>Widgets</h3>
<p>Continuing with the previous example, you'll use the observer pattern to handle displaying price information for some of the instruments within graphical elements on a Web page. First, you'll need to define some simple graphical components. These components will be basic HTML table structures whose functionality will be contained within an object. Such components often go under the all-purpose term of <i>widgets</i>.</p>
<h3>Designing the Widgets</h3>
<p>A graphical widget will have two responsibilities. It will need to draw its own HTML so that it can be seen on a Web page, and it will need to update the data it displays. You may have noticed (from previous figure) that an <i>update</i> method is defined in the Observer interface.</p>
<p>Each widget is an <i>Observer</i>. The item being observed is the data representing the instrument name and price information. The data source is <i>Observable</i>.</p>
<p>All widgets, then, should implement the <i>Observer</i> interface. In addition, each one should descend from an abstract class that defines some shared functionality between widget objects. This is an example of using interfaces and abstract class together. Because the <i>update()</i> method is the same for all widgets, it can be implemented in the abstract class. The class diagram is shown in next figure.</p>
<a href="http://2.bp.blogspot.com/-CgUNOpHoKyI/UT8PEMMozMI/AAAAAAAAAlQ/pUPJjl89zLE/s1600/img010.jpg" imageanchor="1" ><img border="0" src="http://2.bp.blogspot.com/-CgUNOpHoKyI/UT8PEMMozMI/AAAAAAAAAlQ/pUPJjl89zLE/s320/img010.jpg" /></a>
<p>Now all concrete implementations of widgets will descend from the <i>AbstractWidget</i> class. The <i>AbstractWidget</i> class in the turn implements the <i>Observer</i> interface. Notice the <i>update()</i> method in the class diagram for <i>AbstractWidget</i> is not shown in italics. This means that the method is actually implemented at that point. The # symbol indicates that the <i>internalData</i> property is protected. That means subclasses of <i>AbstractWidget</i> have access to it. If it were private, subclasses would not be able to access it.</p>
<div id="book">All text and images above is from the book:"Professional PHP5" <i>ISBN: 0-7645-7282-2</i> (Lecky-Thompson et al., 2005)</div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-86880611559362794782013-04-16T12:39:00.001+01:002013-04-16T12:39:26.234+01:00How to configure NTP Server and Client on CentOS<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
.article #code{
background-color: #000;
color: #0F0;
border:2px solid #0F0;
padding:10px 40px;
border-radius:25px;
-moz-border-radius:25px; /* Old Firefox */
font-size: 14px;
font-family: "Courier New","Lucinda Console", monospace;
}
.article #red{
color: #F00;
}
.article #statement{
font-style: italic;
}
.article ol{
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
.article #book{
text-transform: uppercase;
margin: 5px;
padding: 5px;
color: #fff;
background-color: #f00;
border-radius: 10px;
-moz-border-radius:10px /*Old firefox*/
}
.article #book a{
color: #00F;
}
.article img{
display:block;
margin-left:auto;
margin-right:auto;
}
.article #citation{
font:italic bold 14px Georgia,serif;
}
</style>
<div class="article">
<h1>Introduction</h1>
<p id="citation">NTP is widely used to synchronize a computer to Internet time servers or other sources, such as a radio or satellite receiver or telephone modem service. It can also be used as a server for dependent clients. It provides accuracies typically less than a millisecond on LANs and up to a few milliseconds on WANs. Typical NTP configurations utilize multiple redundant servers and diverse network paths in order to achieve high accuracy and reliability.</p><div id="book">Text retired from <a href="http://www.eecis.udel.edu/~mills/ntp/html/index.html#intro">Web page's Network Time Protocol</a></div>
<h1>Configure NTP Server</h1>
<ol id="code">
<li>yum install ntp (and type 'y' when show up two questions);</li>
<li>vi /etc/ntp.conf</li>
<li>Add the next statement for accept requests from another servers (DNS server, LDAP server, etc.) on your LAN:
<br/><span id="statement">restrict 10.50.0.0 mask 255.255.255.0 nomodify nopeer noquery</span></li>
<li>Add the next statement for public servers NTP synchronize with server's internal clock on your LAN:
<br/><span id="statement">server 0.europe.pool.ntp.org</span>
<br/><span id="statement">server 1.europe.pool.ntp.org</span>
<br/><span id="statement">server 2.europe.pool.ntp.org</span>
<br/><span id="statement">server 3.europe.pool.ntp.org</span>
</li>
<li>This command allow to set current time from indicated NTP server:
<br/><span id="statement">ntpdate pool.ntp.org</span></li>
<li>The same server can be defined on configuration file:
<br/><span id="statement">vi /etc/ntp/step-tickers</span>
<br/><span id="statement">pool.ntp.org</span></li>
<li><span id="statement">service ntpd start</span></li>
<li>Make sure the ntpd is active from beginning Linux boot;
<br/><span id="statement">chkconfig ntpd on</span></li>
<li>Checking synchronization status of service NTP.
<br/><span id="statement">nptq -pn</span>
<br/><span id="statement">tail -f /var/log/messages</span></li>
</ol>
<h1>Configure NTP Client</h1>
<ol id="code">
<li>This file allows to set server NTP to use for initial adjust clock during starting of ntpd:
<br/><span id="statement">vi /etc/ntp/step-tickers</span>
<br/><span id="statement">10.50.0.254</span></li>
<li>On the file /etc/ntp.conf, all you need is add server NTP's IP address to use:
<br/><span id="statement">vi /etc/ntp.conf</span>
<br/><span id="statement">server 10.50.0.254</span></li>
<li>Checking synchronization status of service NTP.
<br/><span id="statement">nptq -pn</span>
<br/><span id="statement">tail -f /var/log/messages</span>
<br/><span id="red">It can take long to see message of success. When I was configuring, it took about 1 hour.</span></li>
</ol>
<h1>Conclusion</h1>
<p>This protocol allows to keep operating system's clock synchronized with high accurate, running at information of synchronism got from another NTP servers.</p>
<p>Although the configuration is relatively simple, NTP performances a very important role. The possibility to make sure that clocks from many servers are kept with right time is relevant and it is a important factor to correct of many applications. The correction of local time in operating system allows also ensure that logs recorded in operating system have correct time and that is important when I use logs to diagnostic problems of some services.</p>
</div>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-482145767206583584.post-29561730889554713792013-04-16T12:39:00.000+01:002013-04-16T12:39:11.702+01:00Validation Email Address: Server side vs Client side<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
.article #code{
background-color: #000;
color: #0F0;
border:2px solid #0F0;
padding:10px 40px;
border-radius:25px;
-moz-border-radius:25px; /* Old Firefox */
font-size: 14px;
font-family: "Courier New","Lucinda Console", monospace;
}
.article ol{
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
</style>
<div class="article">
<p>The week ago I was programming my web application using PHP5.</p>
<p>There is two ways to validate email:
<ol>
<li>On server side (using <a href="http://php.net/manual/en/filter.examples.validation.php">filter_var</a> from PHP5)</li>
<li>On client side (using input type email from <a href="http://www.w3schools.com/tags/att_input_type.asp">HTML5</a>)</li>
</ol>
<h3>PHP5 example</h3>
<pre id="code">
$email = "xpto@email.com";
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "This ".$email." email address is considered valid.";
}
</pre>
<h3>HTML5 example</h3>
<pre id="code">
<form action="file.php" method="post">
E-mail: <input type="email" name="useremail"><br>
<input type="submit">
</form>
</pre>
</p>
<p>In my opinion it is better validate email on client side instead server side. So don't validate email on server side because it takes a lot work to warn user that has an invalid email address. With client side to validate email, it saves a lot work to warn user that has an invalid email address.</p>
<p>But if you are programming a web application using OOP, it is good idea to validate email from server side because you are not using form to validate email but you are using object, for example:
<pre id="code">
class User{
private $name, email;
public function __construct($name,$email){
$this->name=$name;
$this->email=validate($email);
}
private function validate($email){
$mail = "";
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$mail = $email;
}else{
echo "This $email is not valid!";
}
return $mail;
}
}
$user = new User("Peter","peter@xpto.com");//valid email
$user = new User("Paul","kjfddks");//prints "This kjfddks is not valid!"
</pre></p>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-59764630930557459012013-04-16T12:38:00.001+01:002013-04-16T12:38:56.919+01:00Sharing folders without login - Samba<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
.article #code{
background-color: #000;
color: #0F0;
border:2px solid #0F0;
padding:10px 40px;
border-radius:25px;
-moz-border-radius:25px; /* Old Firefox */
font-size: 14px;
font-family: "Courier New","Lucinda Console", monospace;
}
.article ol{
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
</style>
<div class="article">
<p>Samba is an open source software that allows to solve communications problems between Windows and Linux. With Samba, you can share folders, printers for Windows clients and can perform as a Primary Domain Controller (PDC) or as domain member. Samba can also be part of an Active Directory (AD) domain.</p>
<p>As a Systems Administrator, one of first things I wanted to do was share folders on Debian with my Windows to transfer easily files. My Debian is a local Web Server to test my PHP5 applications (yes, I am also PHP5 developer). Why do I want share folders without password? Because it is painful every time I need to login and I am working at home where is no danger around me. No one can crack me at home. At home, it is a great way to share files without login.</p>
<ol id="code">How to install and configure samba
<li>su -</li>
<li><i>insert your root's password</i></li>
<li>mkdir /home/<i>yourusername</i>/mysharedfolder</li>
<li>chown nobody /home/<i>yourusername</i>/mysharedfolder</li>
<li>apt-get install samba</li>
<li>nano /etc/samba/smb.conf</li>
<li>security = share</li>
<li>guest account = nobody</li>
<li><pre>
[mysharedfolder]
writable = yes
path = /path/to/directory
public = yes
guest ok = yes
guest only = yes
guest account = nobody
browsable = yes
</pre></li>
<li>Ctrl+X and then y</li>
<li>service samba restart</li>
</ol>
<p>Optionally, you can use Samba Web Administration Tool (SWAT) to configure the settings of shared folder.</p>
<ol id="code">How to install SWAT
<li>apt-get install swat</li>
<li><i>Go to your favorite web browser and type the next URL:</i> http://localhost:901</li>
<li><i>insert your root login</i></li>
<li><i>watch the next video how to configure samba</i></li>
</ol>
<p>Samba is very useful tool for who want share files between Windows and Linux and SWAT is also very useful for who want configure settings of sharing easily.</p>
<p>I have created another article about Samba before but this one requires a login. If you want to do login, please read this <a href="http://sunsetsoftware.blogspot.pt/2012/08/how-to-install-samba.html">article</a>.</p>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-57591140908175318252013-04-16T12:38:00.000+01:002013-04-16T12:38:25.331+01:00Box Model - CSS Tutorial<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
.article #code{
background-color: #000;
color: #0F0;
border:2px solid #0F0;
padding:10px 40px;
border-radius:25px;
-moz-border-radius:25px; /* Old Firefox */
font-size: 14px;
font-family: "Courier New","Lucinda Console", monospace;
}
.article #red{
color: #F00;
}
.article table{
border: 1px solid #000;
text-align: center;
}
.article th{
background-color: #8a2be2;
color: #000;
}
.article #paint{
background-color: #cdb79e;
}
.article #question{
font-style: italic;
}
.article ol{
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
</style>
<div class="article">
<p>After I want to get better my skills as Web Designer, I decided to study again all concepts of CSS! And there is one thing I consider very important: <strong>Box Model.</strong></p>
<p><span id="question">But what is Box Model and why is it very important?</span><br />
The Box Model is a box that wraps around HTML elements. It is very important because it allow the design become more organized and clean.</p>
<p><span id="question">What consists Box Model?</span><br />
Box Model consits of four things:<ol>
<li><strong>Margin</strong> - Clears an area around the border. The margin does not have a background color, it is completely transparent;</li>
<li><strong>Border</strong> - A border that goes around the padding and content. The border is affected by the background color of the box;</li>
<li><strong>Padding</strong> - Clears an area around the content. The padding is affected by the background color of the box</li>
<li><strong>Content</strong> - The content of the box, where text and images appear</li></ol>
</p>
<center><a href="http://2.bp.blogspot.com/-qa91yDT-pg4/UMsnQrnCnFI/AAAAAAAAAdg/NK1dFe81t_0/s1600/box-model.gif" imageanchor="1" style=""><img border="0" height="216" width="400" src="http://2.bp.blogspot.com/-qa91yDT-pg4/UMsnQrnCnFI/AAAAAAAAAdg/NK1dFe81t_0/s400/box-model.gif" /></a></center>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-32467691948292109042013-04-16T12:37:00.000+01:002013-04-16T12:37:54.568+01:00Design Patterns - Facade Pattern<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 14px;
}
.article #book{
text-transform: uppercase;
margin: 5px;
padding: 5px;
color: #fff;
background-color: #f00;
border-radius: 10px;
-moz-border-radius:10px /*Old firefox*/
}
.article img{
display:block;
margin-left:auto;
margin-right:auto;
}
</style>
<div class="article">
<h1>Introduction</h1>
<p>A design pattern is a specific way of solving a particular problem. They are not simply about reusing code; they are more abstract and generalized than that. They are about using reusing ideas.</p>
<h1>The Facade Pattern</h1>
<p>The best way to understand the facade pattern is to look at a component diagram of a system before and after using a facade.</p>
<p>The next figure shows the front end of a Web site communicating with an application on the Web server. In the right side of the diagram, the front end code is accessing various objects in the application. On the left, showing the facade, the front end communicates only with the facade object, which in turn delegates responsibilities to the internal objects.</p>
<a href="http://1.bp.blogspot.com/-dVDcVr8j8a8/UT8Ncv1VUPI/AAAAAAAAAk4/xmQlpg60SrM/s1600/img009.jpg" imageanchor="1" ><img border="0" src="http://1.bp.blogspot.com/-dVDcVr8j8a8/UT8Ncv1VUPI/AAAAAAAAAk4/xmQlpg60SrM/s320/img009.jpg" /></a>
<div id="book">All text and images above is from the book:"Professional PHP5" <i>ISBN: 0-7645-7282-2</i> (Lecky-Thompson et al., 2005)</div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-47417877278836622522013-04-01T10:24:00.000+01:002013-04-01T10:24:00.409+01:00Design Patterns - Decorator Pattern<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 14px;
}
.article #book{
text-transform: uppercase;
margin: 5px;
padding: 5px;
color: #fff;
background-color: #f00;
border-radius: 10px;
-moz-border-radius:10px /*Old firefox*/
}
.article img{
display:block;
margin-left:auto;
margin-right:auto;
}
</style>
<div class="article">
<h1>Introduction</h1>
<p>A design pattern is a specific way of solving a particular problem. They are not simply about reusing code; they are more abstract and generalized than that. They are about using reusing ideas.</p>
<h1>The Decorator Pattern</h1>
<p>The two concrete widgets created for the observer pattern have a different appearance. If you needed to add a new style of widget, you would subclass <i>Widget</i> and implement the <i>draw()</i> method to write the HTML. Say that needed to add a feature to all existing widgets, such as border. You could go into each <i>draw()</i> method and add some more HTML to each, but then the border would be hard-coded and all widgets would be forced to have a border. You could create a new set of subclasses of existing concrete widgets that implemented the border in the <i>draw()</i> method. If you had only two widgets, as in the <i>Observer</i> example, this might be an option - you would end up with four widgets. However, if you had five widgets to start with, it might not seem so appealing. Suddenly you have a lot of widget classes to worry about.</p>
<p>There is another way to handle situations like this, one that doesn't require you to create a new subclass for every widget you want to add a border to. Using the decorator pattern allows you to add features or functionality to existing objects without using inheritance. Next figure shows the class diagram for the decorator pattern.</p>
<a href="http://4.bp.blogspot.com/-YbRubauPdec/UT8L95VFaXI/AAAAAAAAAks/eFkRYzFqXHU/s1600/img008.jpg" imageanchor="1" ><img border="0" src="http://4.bp.blogspot.com/-YbRubauPdec/UT8L95VFaXI/AAAAAAAAAks/eFkRYzFqXHU/s320/img008.jpg" /></a>
<p>The class diagram indicates that <i>Decorators</i> are a type of Widget, too. This is good because we don't want to change the way we access a <i>Widget</i>, whether it's decorated or not.</p>
<div id="book">All text and images above is from the book:"Professional PHP5" <i>ISBN: 0-7645-7282-2</i> (Lecky-Thompson et al., 2005)</div>
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-482145767206583584.post-81257162482250754792013-03-21T16:37:00.000+00:002013-03-21T16:37:00.599+00:00Design Patterns - Composite Pattern<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 14px;
}
.article #book{
text-transform: uppercase;
margin: 5px;
padding: 5px;
color: #fff;
background-color: #f00;
border-radius: 10px;
-moz-border-radius:10px /*Old firefox*/
}
.article img{
margin-left:auto;
margin-right:auto;
display:block;
}
</style>
<div class="article">
<h1>Introduction</h1>
<p>A design pattern is a specific way of solving a particular problem. They are not simply about reusing code; they are more abstract and generalized than that. They are about using reusing ideas.</p>
<h1>Composite Pattern</h1>
<p>The next figure shows the general case for the composite:</p>
<a href="http://3.bp.blogspot.com/-oSI1P3lWMpo/UT8GoKRb-iI/AAAAAAAAAkU/ECLvHr6Dbgk/s1600/img005.jpg" imageanchor="1" ><img border="0" src="http://3.bp.blogspot.com/-oSI1P3lWMpo/UT8GoKRb-iI/AAAAAAAAAkU/ECLvHr6Dbgk/s320/img005.jpg" /></a>
<p>The composite pattern has two parts: the <i>Component</i> abstract class and the <i>Composite</i>, which is a concrete implementation of the <i>Component</i> class. All <i>Composite</i> objects descend from the abstract <i>Component</i> class. Any <i>Component</i> can contain other <i>Components</i>. A <i>Component</i> with no children can be thought of as an empty <i>Composite</i>.</p>
<p>Moving back from the general case, it will be necessary to make a change in the design and switch the <i>Instrument</i> interface to an abstract class. Interfaces and abstract classes are similar because neither one can be used directly to instantiate an object. The key difference is that an abstract class can have some fully implemented methods, whereas interfaces just have method declarations.</p>
<a href="http://4.bp.blogspot.com/-F_RC8fQFSJE/UT8GrwpVC9I/AAAAAAAAAkc/Jrk8GXmqZH8/s1600/img007.jpg" imageanchor="1" ><img border="0" src="http://4.bp.blogspot.com/-F_RC8fQFSJE/UT8GrwpVC9I/AAAAAAAAAkc/Jrk8GXmqZH8/s320/img007.jpg" /></a>
<div id="book">All text and images above is from the book:"Professional PHP5" <i>ISBN: 0-7645-7282-2</i> (Lecky-Thompson et al., 2005)</div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-62125839470403398122013-03-11T12:11:00.000+00:002013-03-11T21:22:09.809+00:00Commands Vi/Vim editor<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
.article #code{
background-color: #000;
color: #0F0;
border:2px solid #0F0;
padding:10px 40px;
border-radius:25px;
-moz-border-radius:25px; /* Old Firefox */
font-size: 14px;
font-family: "Courier New","Lucinda Console", monospace;
}
.article #red_text{
color: #F00;
}
.article table{
border: 1px solid #000;
text-align: center;
}
.article th{
background-color: #8a2be2;
color: #000;
}
.article #paint{
background-color: #cdb79e;
}
</style>
<div class="article">
<p>As system administrator, I have needed to edit configuration files of some services such as DNS (Domain Name System), LDAP (Lightweight Directory Access Protcol) and etc.</p>
<p>The editor I was using frequently was nano and rarely I used pico. All those editors were used on Ubuntu. When I decided to fit in CentOS, I noticed that I had to install package nano. But I did not want to! I wanted to vary and then I searched and found editor Vi (also it is equal to Vim, although Vim has more features than Vi). I confess, at first time, it was very confused. I did not know what commands to edit file and much less how to save the changes and exit. So I googled and found some commands useful to edit files.</p>
<p>Hereafter, you will see a list of commands to Vi/Vim editor:</p>
<center>
<table>
<tr><th>Command</th><th>Description</th></tr>
<tr><td>:wq</td><td>Save the file and exit</td></tr>
<tr id="paint"><td>:w</td><td>Save the file</td></tr>
<tr><td>:q</td><td>Quit and <span id="red_text">Vi/Vim refuses to exit if any changes was made</span></td></tr>
<tr id="paint"><td>:!q</td><td>Quit without changes to save</td></tr>
<tr><td>:a</td><td>Append after cursor</td></tr>
<tr id="paint"><td>:i</td><td>Insert after cursor</td></tr>
<tr><td>ESC</td><td>Exit insert/overwrite mode and go back to command mode</td></tr>
</table>
</center>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-67429468452018589662013-02-19T12:04:00.000+00:002013-02-19T12:04:00.110+00:00How to create tabs with JavaScript and HTML<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 14px;
}
.article #code{
background-color: #000;
color: #0F0;
border:2px solid #0F0;
padding:10px 40px;
border-radius:25px;
-moz-border-radius:25px; /* Old Firefox */
font-size: 14px;
font-family: "Courier New","Lucinda Console", monospace;
}
</style>
<div class="article">
<p>If you want to create tabs on your website, it is good idea and you should do it! But how to create tabs? Good question!</p>
<p>To create tabs you will use HTML elements and some code of JavaScript. Hereafter will show up HTML code.</p>
<pre id="code">
<!-- tabs -->
<ul class="tabs">
<li><a href="#">Tab One</a></li>
<li><a href="#">Tab Two</a></li>
</ul>
<!-- panes -->
<div class="panes">
<div>Pane One</div>
<div>Pane Two</div>
</div>
</pre>
<p>Next you need JavaScript code to bind tabs to panes and enable the tabbing effect. Here is JavaScript code you need to.</p>
<pre id="code">
$(function(){
$("ul.tabs").tabs("div.panes > panes ");
});
</pre>
<p>After HTML code and JavaScript Code, you can use your imagination to coding CSS. I like this snippet because it is minimal, easy and fast to see results.</p>
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-482145767206583584.post-70351497526776821892013-02-05T13:39:00.000+00:002013-02-05T13:39:00.702+00:00Configuring TCP/IP with CentOS<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 14px;
}
.article #code{
background-color: #000;
color: #0F0;
border:2px solid #0F0;
padding:10px 40px;
border-radius:25px;
-moz-border-radius:25px; /* Old Firefox */
font-size: 14px;
font-family: "Courier New","Lucinda Console", monospace;
}
</style>
<div class="article">
<p id="introduction">The configuration of network TCP/IP allows prepare a server Linux to communicate on network IP, trough setting network interfaces, addresses IP and remaining parameters of configuration. On this article, I will analyse how the way can commands to be used on Linux server.</p>
<center><iframe width="420" height="315" src="http://www.youtube.com/embed/9QB1V-WzSqQ" frameborder="0" allowfullscreen></iframe></center>
<p id="conclusion">I had a chance to analyse the main files of network configuration used on Linux CentOS and I saw that a lot of those files appears on most Linux distro. Also it is important to have a knowledge of some commands like <b>ifconfig</b> and <b>route</b>. Why is it important? Because those commands will allow you to analyse and solve problems of network configuration in future.</p>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-88192540363811998282013-01-22T15:59:00.000+00:002013-01-22T15:59:00.249+00:00What is your favorite mobile operating system? - Results<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 14px;
}
</style>
<div class="article">
<p>On December 31<sup>st</sup> 2012, the poll "What is your favorite mobile operating system?" closed! There was 21 votes to indicate the favorite mobile operating system .</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-vMOeU5T1ZgU/UPQvskRe8qI/AAAAAAAAAeg/64Aj0KfagLI/s1600/poll%2Bvotes%2Bwhat%2Bis%2Byour%2Bfavorite%2Bmobile%2Boperating%2Bsystem.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="240" width="400" src="http://3.bp.blogspot.com/-vMOeU5T1ZgU/UPQvskRe8qI/AAAAAAAAAeg/64Aj0KfagLI/s400/poll%2Bvotes%2Bwhat%2Bis%2Byour%2Bfavorite%2Bmobile%2Boperating%2Bsystem.png" /></a></div>
<p>I have to say that I am not surprised for Android's votes but I am very surprised with Windows Phone's votes. Is Windows Phone ahead of Mac iOS? That I was not expected for!!!</p>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-80853702707513750932013-01-04T11:43:00.000+00:002013-01-04T11:43:00.699+00:00How to return a page before current<style>
.article p{
text-align:justify;
text-indent: 25px;
font-family: "Arial","Verdana",sans-serif;
font-size: 16px;
}
.article #php{
font-size: 16px;
color: #00F;
}
.article #code{
background-color: #000;
color: #0F0;
border:2px solid #0F0;
padding:10px 40px;
border-radius:25px;
-moz-border-radius:25px; /* Old Firefox */
font-size: 14px;
font-family: "Courier New","Lucinda Console", monospace;
}
.article #red{
background-color: #F00;
color: #FFF;
text-align: center;
padding:10px 40px;
border-radius:25px;
-moz-border-radius:25px; /* Old Firefox */
}
</style>
<div class="article">
<p>To create a link "Back" that allow come back to previous page before current, I use a variable called <span id="php">$_SERVER['HTTP_REFERER']</span>. Hereafter, you will see a example:</p>
<pre id="code">
...
<body>
...
<a href="<?php echo $_SERVER['HTTP_REFERER']?>">Back</a>
...
</body>
...
</pre>
<p id="red">Be careful when you refresh the page!</p>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-10513913678307450282012-12-31T11:01:00.000+00:002012-12-31T11:01:00.328+00:00Happy New Year<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-I3IhwihrTOA/UDiif0qs7oI/AAAAAAAAAb4/SPT29BjdeLc/s1600/New-Year-Party-icon.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="256" width="256" src="http://2.bp.blogspot.com/-I3IhwihrTOA/UDiif0qs7oI/AAAAAAAAAb4/SPT29BjdeLc/s400/New-Year-Party-icon.png" /></a></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-92144891576320776672012-12-24T11:00:00.000+00:002012-12-24T11:00:04.850+00:00Merry Christmas<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-iwQ5t1Oj41Q/UDiiGwQ_36I/AAAAAAAAAbs/GP2bmEz9t2c/s1600/christmas-tree-icon.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="128" width="128" src="http://1.bp.blogspot.com/-iwQ5t1Oj41Q/UDiiGwQ_36I/AAAAAAAAAbs/GP2bmEz9t2c/s400/christmas-tree-icon.png" /></a></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-85488863253486570992012-11-07T11:43:00.000+00:002012-12-08T12:42:14.696+00:00How to check Ubuntu version using command line<style type="text/css">
p{
text-align:justify;
font-size: 14px;
}
#code{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
background: #DDD;
padding: 5px 5px;
color: #000;
width: 90%;
}
#note{
background: #FFF;
color: #F00;
}
#steps{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
background: #000;
padding: 5px 5px;
color: #0F0;
}
table{
border: 1px solid black;
}
table th{
background-color: orange;
}
#paint{
background-color: #CAE1FF;
}
#green{
color:#0F0;
}
</style>
<p>
I wanted to see what was my Ubuntu version using command line. After I found this <a href="https://help.ubuntu.com/community/CheckingYourUbuntuVersion">website</a>, I could to see my Ubuntu version.
</p>
<div id="steps">
To check your Ubuntu version using command line:
<ol>
<li id="green">Open terminal (CTRL+ALT+T)</li>
<li id="green">Type lsb_release -a and press Enter</li>
<li id="green">The Ubuntu version will displayed on the screen</li>
</ol>
</div>
<p id="note">At the time, my Ubuntu version is Ubuntu 11.10 (oneiric).</p>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-1109127972969416742012-11-05T15:25:00.000+00:002012-11-05T15:34:06.451+00:00Sunset Software OS<style type="text/css">
.sunsetsoftwareos p{
text-align:justify;
text-indent: 50px;
font-style: Arial, Helvetica, sans-serif;
font-size: 14px;
}
.sunsetsoftwareos #note{
color: #FFF;
background-color: #F00;
font-style: Arial, Helvetica, sans-serif;
font-size: 14px;
text-align: center;
}
.sunsetsoftwareos #highlight{
font-style: "Lucida Console", Monaco, monospace;
font-size: 18px;
}
.sunsetsoftwareos #highlight0{
font-style: "Lucida Console", Monaco, monospace;
font-size: 15px;
text-decoration: underline;
}
.sunsetsoftwareos h1{
color: #6495ED;
text-align: center;
}
.sunsetsoftwareos a:link {color:#FF7F50;} /* unvisited link */
.sunsetsoftwareos a:visited {color:#DC143C;} /* visited link */
.sunsetsoftwareos a:hover {color:#006400;} /* mouse over link */
.sunsetsoftwareos a:active {color:#FF7F24;} /* selected link */
</style>
<div class="sunsetsoftwareos">
<p>After of making videos related with Linux, I decided that it is time to create a distro Linux which contains some software used on videos. I found a amazing <a href="http://susestudio.com/" target="_blank">site</a> that allows to create own distro Linux.</p> <div id="note">I will not make tutorial how to create own distro!</div>
<p>The distro Linux created with help from SUSE Studio calls <span id="highlight">Sunset Software OS</span>. This OS is destined for <span id="highlight0">developer software</span>, <span id="highlight0">web developer software</span> and <span id="highlight0">systems administator</span>. You can download a image ISO right <a href="http://susestudio.com/a/JOnYdg/sunset-software-os" target="_blank">here!</a> Language and Keyboard Layout will be ask at first boot.
<ol>There is two users:
<li>root (password: linux)</li>
<li>user (password: peter)</li>
</ol>
</p>
<h1>Enjoy!</h1>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-53888278620987358032012-10-31T10:58:00.000+00:002012-10-31T10:58:00.250+00:00Happy Halloween<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-sz6d_oH8MEw/UDih1VI5bBI/AAAAAAAAAbg/OIF_QD4fmWY/s1600/Laugh-icon.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="256" width="256" src="http://1.bp.blogspot.com/-sz6d_oH8MEw/UDih1VI5bBI/AAAAAAAAAbg/OIF_QD4fmWY/s400/Laugh-icon.png" /></a></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-45847743739718856432012-10-17T12:12:00.000+01:002012-12-08T12:43:34.658+00:00How to change timezone on Apache Webserver<style type="text/css">
p{
text-align:justify;
font-size: 14px;
}
#code{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
background: #DDD;
padding: 5px 5px;
color: #000;
width: 90%;
}
#note{
background: #FFF;
color: #F00;
}
#steps{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
background: #000;
padding: 5px 5px;
color: #0F0;
}
table{
border: 1px solid black;
}
table th{
background-color: orange;
}
#paint{
background-color: #CAE1FF;
}
#green{
color:#0F0;
}
</style>
<p>
My Apache Webserver had not timezone correct. If I wanted timezone correct, I had to do some configuration on Apache Webserver. But how to do this?
</p>
<div id="steps">To change timezone on my Apache Webserver, I followed the next steps:
<ol id="green">
<li>Type sudo nano /etc/php5/apache2/php.ini;</li>
<li>Search for "date.timezone" and modify to "date.timezone="Europe/London" or to your timezone;</li>
<li>Save the file and exit using CTRL+X;</li>
<li>Type sudo /etc/init.d/apache2 restart</li>
</ol>
</div>
<p>To see what is your timezone, check this <a href="www.php.net/manual/en/timezones.php">website</a></p>
<p>
<p id="note">At the moment, my operating system was Ubuntu 11.10 and Apache Webserver was 2.2.20!</p>
<iframe width="560" height="315" src="http://www.youtube.com/embed/zI1kpNd3On8" frameborder="0" allowfullscreen></iframe>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-33871037139820067582012-09-25T14:12:00.000+01:002012-10-03T20:49:31.447+01:00MySQL Tutorial - How to calculate time correctly <style type="text/css">
p{
text-align:justify;
font-size: 14px;
}
#code{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
background: #DDD;
padding: 5px 5px;
color: #000;
width: 90%;
}
#sql{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
background: #DDD;
padding: 5px 5px;
color: #000;
width: 100%;
}
#note{
background: #FFF;
color: #F00;
}
#steps{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
background: #000;
padding: 5px 5px;
color: #0F0;
}
table{
border: 1px solid black;
}
table th{
background-color: orange;
}
ol{
color: blue;
}
#paint{
background-color: #CAE1FF;
}
</style>
<p>A database server has a database called "Cinema" which has a table called "Movies". This table has next fields:
<ul>
<li>ID</li>
<li>Name</li>
<li>Duration</li>
</ul>
<br />
<p>Hereafter, you can see table 'movies':</p>
<table>
<tr>
<th>movies_id</th>
<th>movies_name</th>
<th>movies_duration</th>
</tr>
<tr>
<td>1</td>
<td>Movie I</td>
<td>02:23:34</td>
</tr>
<tr id="paint">
<td>2</td>
<td >Movie II</td>
<td>01:44:56</td>
</tr>
<tr>
<td>3</td>
<td>Movie III</td>
<td>02:56:34</td>
</tr>
</table>
</p>
<p>To calculate duration of all movies, we could write: <p id="sql">SELECT sum(movies_duration) FROM movies;</p>
<span id="note">But it is wrong!</span>
<p>Result:</p>
<table>
<tr>
<th>sum(movies_duration)</th>
</tr>
<tr>
<td>62424</td>
</tr>
</table>
</p>
<p>
To fix this problem, it is necessary convert time to seconds with next SQL statement:
<p id="sql">SELECT time_to_sec(movies_duration) FROM movies;</p>
</p>
<p>Result:</p>
<table>
<tr>
<th>time_to_sec(movies_duration)</th>
</tr>
<tr>
<td>8614</td>
</tr>
<tr>
<td id="paint">6296</td>
</tr>
<tr>
<td>10594</td>
</tr>
</table>
<p>And next, use function SUM() to calculate duration of all movies
<p id="sql">SELECT sum(time_to_sec(movies_duration)) FROM movies;</p>
</p>
<p>Result:</p>
<table>
<tr>
<th>sum(time_to_sec(movies_duration))</th>
</tr>
<tr>
<td>25504</td>
</tr>
</table>
<p>Finally, convert the sum (in seconds) to time using the next statement:
<p id="sql">SELECT sec_to_time(sum(time_to_sec(movies_duration))) FROM movies;</p>
<p>Result:</p>
<table>
<tr>
<th>sec_to_time(sum(time_to_sec(movies_duration)))</th>
</tr>
<tr>
<td>07:05:04</td>
</tr>
</table>
<p>Thus you can calculate time correctly using three MySQL functions:
<ol>
<li>TIME_TO_SEC(...)</li>
<li>SUM(...)</li>
<li>SEC_TO_TIME(...)</li>
</ol>
</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-71504026061610493022012-09-01T15:40:00.000+01:002012-09-01T15:40:00.301+01:00JavaScript Tutorial - How to print a Web Page<style type="text/css">
p{
text-align:justify;
font-size: 14px;
}
#code{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
background: #DDD;
padding: 5px 5px;
color: #000;
width: 50%;
}
#note{
background: #FFF;
color: #F00;
}
#steps{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
background: #000;
padding: 5px 5px;
color: #0F0;
}
</style>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-UhE2SzheUjI/UDeQtLNYqpI/AAAAAAAAAbI/2TCUnMz7lRU/s1600/Printer-icon.png" imageanchor="1" style="clear:right; float:right; margin-left:1em; margin-bottom:1em"><img border="0" height="160" width="160" src="http://2.bp.blogspot.com/-UhE2SzheUjI/UDeQtLNYqpI/AAAAAAAAAbI/2TCUnMz7lRU/s320/Printer-icon.png" /></a></div>
<p>I was working on my project called "Project Manager". And I was needing to create a link to print a web page.
After I was researching on Web, I found a small code written in JavaScript.</p>
<div id="code">
<a href="javascript.window.print()">Print</a>
</div>
<p>Clicking on link, it will show up a box dialog of printer.</p>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-482145767206583584.post-73624297452100304052012-08-21T12:10:00.000+01:002012-08-23T17:38:08.820+01:00Oracle PL/SQL<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-RAbjl7FSZX0/UDZcZiBvXgI/AAAAAAAAAaw/mX_IoCo4tyU/s1600/data-management-icon.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-RAbjl7FSZX0/UDZcZiBvXgI/AAAAAAAAAaw/mX_IoCo4tyU/s1600/data-management-icon.png" /></a></div>
<br />
<span style="font-family: Courier New, Courier, monospace;">For professional reasons, I was forced to study Oracle PL / SQL.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<br />
<div style="text-align: justify;">
<span style="font-family: Courier New, Courier, monospace;">PL/SQL is an imperative 3GL that was specifically designed for the seamless processing of SQL commands. It provides specific syntax for this purpose and supports exactly the same datatypes as SQL. Server-side PL/SQL is compiled and stored in Oracle Database and Oracle runs within the executable. It automatically inherits the robustness, security, and portability of Oracle Database.</span></div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">To study Oracle PL / SQL, I found a great <a href="http://st-curriculum.oracle.com/tutorial/DBXETutorial/index.htm" rel="nofollow" target="_blank">website</a> and I highly recommend.</span>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-482145767206583584.post-9319630131531562342012-08-08T19:45:00.000+01:002012-10-03T20:44:14.548+01:00How to install Samba<style type="text/css">
p{
text-align:justify;
font-size: 14px;
}
#code{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
background: #DDD;
padding: 5px 5px;
color: #000;
width: 50%;
}
#note{
background: #FFF;
color: #F00;
}
#steps{
border: 2px solid;
border-radius: 10px;
-moz-border-radius:25px;
padding-top:5px;
padding-bottom: 5px;
background: #000;
color: #0F0;
}
</style>
<p>
Since 1992, Samba is an open-source software that your main goal is to remove the barriers of interoperability between different operating systems.
</p>
<p>
I need Samba to move files from Windows to Ubuntu and vice-versa for work's issues. Hereafter, you can see the steps how to install Samba:
<ol>
<li>sudo apt-get install samba samba-tools</li>
<li>sudo smbpasswd -a <i>yourusername</i>
<ul>
<li>Type your password</li>
<li>Retype your password</li>
</ul>
</li>
<li>mkdir /srv/samba/share</li>
<li>sudo nano /etc/samba/smb.conf</li>
<li>Press Ctrl+W
<ul>
<li>Search for: <i>#security=user</i></li>
<li>remove '#' (from "#security=user" to "security=user")</li>
</ul>
</li>
<li>On bottom of file write the next statements:</li>
<div id="code">
<pre>
[share]
path = /srv/samba/share
comment = some random files
available = yes
valid users = <i>yourusername</i>
read only = no
</pre>
</div>
<li>sudo restart smbd</li>
<li>testparm /etc/samba/smb.conf</li>
</ol>
</p>
<div id="note">
Note:
After you typed the last command and got errors message, you have to fix it. But I am 100% sure, it will not show up a error message unless you mistyped some statements.
</div>Unknownnoreply@blogger.com0