NPM Global As Reference of NPM Local

How to refer NPM Local to NPM Global? If you don’t want to install the packages locally because it’s wasting hardisk space you can use the packages which have globally installed.

For example, you install the sass package globally:

$ sudo npm install -g grunt-contrib-sass

You don’t want to do the same for your project, project, and another project because you think the files are the same but just the locations which make it different.

So, in case we want to install sass package from global to local we can use link directive in your project folder:

$ npm link grunt-contrib-sass

It will automatically create node_modules/grunt-contrib-sass link to grunt-contrib-sass global package. Piece of cake.

Installing Node.js, NPM, Grunt, and Yeoman in Ubuntu 14.04 LTS

Installing Node.js is not as difficult as a year ago. You can simply install it through your Terminal. First get the installer.

$ curl -sL https://deb.nodesource.com/setup | sudo bash -

And then install it with apt-get.

$ sudo apt-get install -y nodejs

Continue reading Installing Node.js, NPM, Grunt, and Yeoman in Ubuntu 14.04 LTS

Change Text Editor Ubuntu 14.04 LTS Without /usr/share/applications/defaults.list

It was suck. I’ve spent hours to find this solution. If you want to change your Ubuntu 14.04 LTS text editor by changing /usr/share/applications/defaults.list and then you may find it doesn’t work, you can try edit the ~/.local/share/applications/mimeapps.list.
Continue reading Change Text Editor Ubuntu 14.04 LTS Without /usr/share/applications/defaults.list

Returning Filename Only in PHP

How to strip file extension in PHP? I want to lose my filepath in my PHP string and then leave the filename without extension for the rest of it. I want to eliminate the darn extension! It’s very easy my friend. It’s basic, but it took me an hour to find the best solution. The solution is simple.
Continue reading Returning Filename Only in PHP

Handling 404 Errors NotFoundHttpException

First off, I want to thank to my grandfather, granma, mother, father, sister, brother, and whoever read this, especially Google who gave me only partial answer to my problem. So, here I create one of my complete solution to handle the 404 Errors on Laravel.

Why my Laravel keeps showing the NotFoundHttpException error? Usually it appears like Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException.

Why NotFoundHttpException

It is because Application Debug Mode in your Laravel/app/config/app.php is set true. You can change it from ‘debug’ => true to ‘debug’ => false.

Creating Handle for 404 Error

First you have to set the Application Debug Mode to false, if it’s already done you can continue. Open your Laravel/app/start/global.php and then find the Application Error Handler section. You must find something like this.

App::error(function(Exception $exception, $code)
{
	Log::error($exception);
});

I know you are lazy. Change the script by copy-pasting the script below. And don’t forget to save.

App::error(function(Exception $exception, $code)
{
	Log::error($exception);
	
	if (Config::get('app.debug')) {
    	return;
    }

    switch ($code)a
    {

        case 404:
        	return Response::view('errors.missing', array(), 404);
        default:
        	return Response::view('errors.missing', array(), $code);
    }
});

Creating Custom Page for 404 Error

Now you create new folder named ‘errors’ in Laravel/app/views/ anad create missing.blade.php. So, the full filepath will look like this Laravel/app/views/errors/missing.blade.php.

You can fill the missing.blade.php with words, statements, and whatever you like. But please do not harass me. If you want to see complete documentation about handling error 404 in Laravel you can visit this Laravel Error Handling documentation, it’s very very very very complete. You must be come back here again after read that bullshit docs. Cheers

Can’t Install Laravel Via Laravel New

I’ve been thinking about why can’t I use laravel new [folder] to create a new Laravel installation. It seemed to be frustrating me like a dragon firing fireball into the castle. Stop that too much. Enough.

So, the reason you landed on this page is because you got error message [GuzzleHttp\Exception\ClientException] Client error response [url] http://192.241.224.13/laravel-craft.zip [status code] 404 [reason phrase] Not Found. I must be right! Why that annoying message tends to be appeared when you try to create new Laravel installation? It’s maybe the laravel-craft.zip is not available anymore. So, what are we gonna do? It’s maybe something has to be updated but the Laravel developers seem not in the mood to talk about it.

Yeah I found the solution

I just remind you that it was very frustrating to install Composer and Laravel for the first time. To fix this situation you have to locate the installation directory for Composer. If you forgot, please recall your memory. Nope, this is my installation path.

C:\ProgramData\ComposerSetup\bin

Updating the Composer

Okay first, get into your composer installation path. Then, try to update by running php composer.phar update in your command line application, in this case I used the default Windows Command Prompt. If you get message like Warning: This development build of composer is over 30 days old. It is recommended to update it by running “composer.phar self-update” to get the latest version, you should run php composer.phar self-update instead the first one.

If it worked you’ll get a message like Updating to version 31eadc6920cd1866xxxxxx. Downloading: 100% Use composer self-update –rollback to return to version 1e27ffe22813df20xxxx

Updating the Laravel Installer

Still in that Composer installation path. Now run.

composer global require “laravel/installer=~1.1”

If you’re doing it correctly this message will fulfill your happy day.

Changed current directory to C:/Users/xxxxxxx/AppData/Roaming/Composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing laravel/installer (v1.1.2)
  - Installing laravel/installer (v1.1.3)
    Downloading: 100%

Writing lock file
Generating autoload files

Installing Laravel

NOW it’s time to kill the dragon. Execute this command my lovely soldier.

laravel new test

A folder with Laravel installation will be created in “test” folder if you did it right. I assume that you have added Composer installation path in your PATH environment. If you don’t know how to work it out you can read How to set the path and environment variables in Windows.

Creating Array in Java

Creating Array in Java for the first time seems frustrating there are Map, HashMap, List, and ArrayList. Those are making us wonder which one to use. So, for the easy one I chose List as an object to create array. You have to create a java file named MyList.java first to make it works. Here is a simple script to make the array in Java.
Continue reading Creating Array in Java

Enabling WordPress Localhost Permalink to Prevent 404 Not Found

If you have trouble to make permalink works on your localhost’s WordPress you can use these steps to make it works. But, you have to make sure that you are using Windows and Apache2.2 as your local server.

The Indication

When you point your browser to the address of your page or post that has custom permalink in it, say http://www.test.com/about/, it shows page Not Found “The requested URL /about/ was not found on this server” like this one. You may try the solution as follow.

Continue reading Enabling WordPress Localhost Permalink to Prevent 404 Not Found

How to Fix Error 1324 Adobe Acrobat X Pro

The error 1324 that says: The path my documents or the volume is invalid. please enter the path and try again or Error 1324: The path -N or the volume is invalid. Please enter the path and try again are very frustrating. It looks like you’ve installed Adobe Acrobat X Pro first and then install Adobe Creative Suite 5 (CS5).

This kind of error can be fixed by using Microsoft FixIt. But, before you install the Microsoft FixIt you have to install Microsoft .NET Framework 4 first. To install Microsoft FixIt you might need internet connection.

If you got an error while installing the Framework 4 probably you have install the Framework 2 and 3 first.

After you’ve done with the FixIt don’t close the window before you try to install the Adobe or programs you need to install.

 

United States of America States and Cities List in Array PHP

We’ve created USA (United States of America) states and cities list in array for your programming purpose.

  • The scripts are written in PHP.
  • There are 46 states and 275 cities.
  • You’ll get both newline and without newline arrays.
  • The File is in zip format
  • Total file size is 28.3Kb

This is the sample of USA states and cities in array with newline.

$statecity = array('Alabama' => array('Birmingham',
  'Montgomery',
  'Mobile',
  'Huntsville'),
  'Alaska' => array('Anchorage'),
  'Arizona' => array('Mesa',
  'Phoenix',
  'Tucson',
  'Gilbert',
  'Scottsdale',
  'Chandler',
  'Tempe',
  'Surprise')

This is the sample of USA states and cities in array without newline.

$statecity = array('Alabama' => array('Birmingham', 'Montgomery', 'Mobile', 'Huntsville'), 'Alaska' => array('Anchorage'), 'Arizona' => array('Mesa', 'Phoenix', 'Tucson', 'Gilbert', 'Scottsdale', 'Chandler', 'Tempe', 'Surprise')

The price is $5. It’s relatively cheap to save your time! Including BONUS: United States of America states and cities in Microsoft Excel format (.xlsx and .xls).