Thursday, September 5, 2019

Append text to a file in Laravel

In Laravel some time you want to add error logging or some other text information related to your code running status in a file. I'm going to show how you can achieve that

First you need to use the inbuilt File class inside your controller, for that include the below line on the controller above your class definition (Refer the below picture)
use File;

Once you include the above line now you can call the function from the File class, the function we need for appending the text to a file is append() function.

This function will append any text you are providing to the end of the already created file, or if the file is not available it will create a file in the name you provide and append the text to it.

Next thing is we need to pass two parameters to this function, first parameter is storage location with file name and the second one is the text you want to append (Refer the belo picture)

In the above picture I'm using a function in the place of storage location and file name, which is storage_path() this function will get the storage directory in the root path of your laravel application. and if the file is available on that location it will append the text to the particular file or else it will create a file inside the storage directory and append the text to it

In the above picture once this function run first time it will create a file called error.log inside logs directoy which is there inside the storage directory and append the text "Error 1" to it without the quotes.
* The append function will not create the folder if it is not available already, so it will pass an error. In the above case, If there is no logs directory you need to create logs directory inside storage directory to successfully test the code

Tuesday, April 5, 2016

CakePHP for newbies Part 1

Hi Guys,

I have learnt some thing today about CakePHP and I'm using it for my new web based application, I would like to share some thing with you,

I would like to give some of basic practicality issue without diving into theory because you can find the theory in the below official link.

Before installing CakePHP framework we need to install local servers if we are using our own PC in the development,
I would like to install WAMP server as my local server
Before installing WAMP server in windows machine first install the Visual C++ Redistributable for Visual Studio from the below link

After that you can download and install WAMP server from the below link.

Once the installation finishes you can run the WAMP server but in windows 10 it will conflict with the locally running windows www service therefor the icon of the WAMP server looks like the below

If the WAMP server icon looks like the above, you should stop the www service from your machine, to stop the WWW service please follow the below,

    1. Type the word "services" in the search box at task bar

   2. Click on the Services Desktop app
   3. In the services window scroll down to look the WWW services, look at the below image

   4. Right click on the World Wide Publishing service and select stop in the context menu like the              below image

After stopping the WWW service, now restart the WAMP server by right clicking the WAMP server icon in the task bar and check the color, it has to change into green.

Now you can just type localhost in the browser address bar and it will looks like the below

Saturday, April 27, 2013

Exercise - 01 Microsoft Office (Edickson Lanka (Pvt) Ltd.)

Create Sample Data

  1. Type =rand().
  2. Press Enter. Three paragraphs appear in your document.

Select with the Shift and Arrow Keys

  1. Place your cursor before the word "On" in the first paragraph.
  2. Press and hold down the Shift key, which serves as an "anchor" showing where text you wish to select begins or ends.
  3. Press the right arrow key until the first line of text is highlighted.
  4. Press the down arrow key until the first paragraph is highlighted.
  5. Click anywhere outside the highlighted area to remove the highlighting.

Select with the Mouse

  1. Place your cursor before the word "You" in the second paragraph.
  2. Press and hold down the left mouse button.
  3. Drag the mouse until you have highlighted the second paragraph.
  4. Click anywhere outside the highlighted area to remove the highlighting.

Place the Cursor

During the lessons, you will often be asked to place the cursor at a specific location (the insertion point) on the screen. You place the cursor by moving the cursor to the specified location and pressing the left mouse button or by using the arrow keys to move to the specified location.


The Arrow Keys

  1. Use the down arrow key to move down your document.
  2. Use the right arrow key to move to the right.
  3. Use the up arrow key to move up.
  4. Use the left arrow key to move to the left.
  1. Move around you document by using you mouse and clicking in a variety of location.
  2. Click in a location and type. Note what happens.

Execute Commands with Keyboard Shortcuts

There are many methods you can use to accomplish tasks when using Word. Generally, you choose an option by clicking the option on the Ribbon. However, you can also use shortcut keys. A key name followed by a plus and a letter means to hold down the key while pressing the letter. For example, Ctrl+b means you should hold down the Ctrl key while pressing "b." A shorthand notation of the above would read as follows:
Press Ctrl+b
Typists who are slowed down by using a mouse usually prefer using keys.

Start a New Paragraph

When you type in Microsoft Word, you do not need to press a key to move to a new line. To start a new paragraph, press the Enter key. 

Exit Word

You have completed Lesson One. Typically, you save your work before exiting.


Close and Save—Windows Vista

Exit Word 1
  1. Click the Microsoft Office button. A menu appears.
  2. Click Exit Word, which you can find in the bottom-right corner.
Exit Word 2
  1. You are prompted: "Do you want to save changes to Document1?" To save your changes, click Yes. Otherwise, click No. If you click Yes, the Save As dialog box appears.
Exit Word 3
  1. Move to the correct folder.
  2. Name your file by typing Lesson One.doc in the File Name field.
  3. Click Save. Word saves your file.

Close and Save—Windows XP

  1. Click the Microsoft Office button. A menu appears.
  2. Click Exit Word, which is in the bottom-right corner.
  3. You will be prompted: "Do you want to save changes to Document1?" To save your changes, click Yes. Otherwise, click No. If you click Yes, the Save As dialog box appears.
  4. Specify the correct folder in the Save In box.
  5. Name your file by typing Lesson One.doc in the File Name field.
  6. Click Save. Word saves your file.

Tuesday, June 12, 2012

Simple Java 1

Hi Guys,
I’m going to talk about Java Programming Language briefly from the basic.

If you guys interested on Java you may refer this articles and you may ask questions regarding this article to improve my knowledge on Java.

Java is a high-level Object Oriented programming language originally developed by Sun Microsystems and released in 1995.

Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. 

Because Java is platform independent programming language.

What is platform independence?

Java solves the problem of platform-independence by using byte code. 

The Java compiler does not produce native executable code for a particular machine like a C compiler would. 

Instead it produces a special format called byte code. Java byte code written in hexadecimal, byte by byte, looks like the below:

CA FE BA BE 00 03 00 2D 00 3E 08 00 3B 08 00 01 08 00 20 08

This looks a lot like machine language, but unlike machine language Java byte code is exactly the same on every platform. 

So the same byte code from all OS makes Java as platform independence

You can Compile and Execute all the Java Examples provide on this article by Installing Java on your PC form this link or you can compile and execute online by using this link

Thursday, March 29, 2012

What is the Answer for 6÷2(1+2) , Is it 9 or 1

Hi guys,

It is a mathematical problem, How can we solve this If we use BODMAS/ PEMDAS the answer can be 1 or 9.
Lets try this


  =3*3 because 6÷2 is 3

In BODMAS order Bracket, Order, Division, Multiplication, Addition, Subtraction
In PEMDAS order  Parenthesis, Exponentiation, Multiplication,  Division , Addition, Subtraction

So the above two operation orders are contradict each other by changing the position of Multiplication and Division but mathematically the both Operators have same procedural.

So, If Multiplication and Division come next to each other We can solve the problem by applying left to right order. That is the left operator should solve first and after that the second left operator.

If we apply above theory to the problem

=6÷2 = 3
=3*3 = 9

But that is not the way, The way of doing this is,

if the answer is 9
1. plug an unknown value for any digit so that the equation should looks like the below
       6÷Y(1+2) = 9
2. Now solve the equation for finding out the value for Y
       6÷1Y+2Y = 9
       6÷3Y = 9
       6 = 9*3Y
       6÷9 = 3Y
       0.667 = 3Y
       Y = 0.667 ÷ 3
       Y = 0.222
We know in our equation we replace 2 by  Y so, Y should come as 2 So,

if the answer is 1

1. plug an unknown value for any digit so that the equation should looks like the below
       6÷Y(1+2) = 1
2. Now solve the equation for finding out the value for Y
       6÷1Y+2Y = 1
       6÷3Y = 1
       6 = 1*3Y
       6÷1 = 3Y
       6 = 3Y
       Y = 6 ÷ 3
       Y = 2                Yes that's it we have got Y=2 if the answer is 1 So, the answer for 6÷2(1+2) = 1


Wednesday, March 28, 2012

Money For You If it is true?

Hi Guys,

I was at busy moment on the internet and had a chance to read something about wazzub and I have search about it on google. The yahoo answer give me some good information about wazzub You also can read that on the link
and if you pretty confident please visit the link below and register with wazzub



Ok guys see you later...

Thursday, February 2, 2012

Connecting Visual Basic 2010 with MySql database Cont...

Today We are going to learn that, How to write code in VB 2010 for connect to MySql Database

1. Open up new Visual Studio Project and create a form

2. Right Click on the form you create, and choose view code option

3. In the window you have shown, Type the code below

Imports MySql.Data.MySqlClient

the above line should be appear in the very top of the window that is, The above line should be type above public class formname

After that type the below code after the class declaration, That is after the line
public class formname

Dim ServerString As String = "Server=localhost;User Id=root;Password=pass;Database=dtbname"
Dim SQLConnection As MySqlConnection = New MySqlConnection

The above code line I use my server as localhost and user id as root password for the root is pass and the database is dtbname. You can use your own database details instead of the above

The second line of above code should be typed like what I have entered but you can change only the variable name SQLConnection to your own variable name

After that type the code below

SQLConnection.ConnectionString = ServerString

            If SQLConnection.State = ConnectionState.Closed Then
                MsgBox("Connection is closed")
            End If
        Catch ex As Exception
        End Try

Thats it you have connected to MySql database from Visual Basic 2010

Tomorrow we will show how to retrieve data from MySql table....