Posts

Showing posts from 2014

Laravel Composer main Command

Laravel Composer main Command These are the main composer command which is necessary when you install first time a Laravel Project. composer self-update - It will self update the composer composer update - It will update the all library or packages for laravel project composer dump-autoload - This will update the autoload, If any file is update or class added composer dumpautoload - This is same function as above

What is best configuration for desktop PC under 80000?

Best configuration for desktop PC under 80000 According to me this should be the best configuration which is under 80000. For Heavy/Personal and Gaming Use this PC give you 100%  Performance. Here are the specification for Desktop PC 17190 - ASUS Z97PRO WIFI (1150) 5,428 - Corsair Vengeance DDR3 8 GB (1 x 8 GB) PC RAM (CMZ8GX3M1A1600C10) 5,000 - Sandisk ultra ssd 120 21490 - Intel Core I7-4790k Processor (8m Cache, Up To 4.40 Ghz) (i-7 4790k) 13000 - 22" moniter DELL 24" LED (ST 2440 L) 1,470 - Logitech MK260 Combo Wireless Keyboard and Mouse Combo 3,990 - CORRSAIR VS-650 SMPS 5,800 - Any Cooler Master Cabinet 4,875 - Corsair H60 Cooler ------------------------------------ 78243 ------------------------------------ All price are in Rupees and price can be UP and DOWN. According to your configuration, you can add Graphic Card too but for now there is not any need to add. When you have extra money to burn then you can have it. Please Note:- Before to buy the

How to use Sass or Scss in a Meteor app?

Use Sass or scss in Meteor app To use Sass or Scss file in Meteor First of all you need to add scss or sass package in Meteor Run this command first: mrt add scss Now create a scss file inside your stylesheet folder or anywhere you want to add Like scss_style.scss You can add a css style code to test like h1{ color:red !important; } Now restart your app. I hope it is working now. But this will not work after 0.8 version of meteor Please comment or share this post to inspire me :)

What is WebSockets in HTML5?

WebSockets in HTML5 Web Sockets is a next-generation communication technology for web applications by which you can send or receive data from server like ajax get post method. You have already used like this type of code in jQuery $.post() Or $.get() or $.ajax() etc What these function do? These function used for send and receive data from server to client or client to server. Same as WebSockets works. Syntax: var Socket = new WebSocket(url, [protocal] ); Example: <script type="text/javascript"> function WebSocketCheck() { if("WebSocket" in window) { alert("WebSocket is supported by your Browser!"); // Lets open a web socket var ws = new WebSocket("www.url.com/para"); ws.onopen = function() { // Web Socket is connected now, send data using send() Method ws.send("Message to send server"); alert("Message is sent now."); }; ws.onmessage = function (evt) { var received_msg = evt.data; alert(&

How to show index for an array in loop in the template of Meteor?

Show indexing in template of Meteor for a list of array in loop You can use something like this: Like you have a template name home.html with home template name Now you can write this code for indexing or index to show listing home.js var tot = 0; Template.home.helpers({   listIndex: function(num){     tot = tot+num;     return tot;   }  }); Template.home.destroyed  = function(){   tot = 0; }; Now you can call this function from your template home.html like this: {{listIndex 1}} Hope this will work for you :)

How to use if else condition in Meteor Template?

You can use if else condition in Meteor HTML Template by other option Here is one option to use it Like: You can use Helpers of meteor to use if else condition which you can use in your HTML file. Here is Example: Project/helpers/Spacebars.js You can write this code in this helper UI.registerHelper('addChangeClass', function(valchange) { if(valchange>1) { return "<span style='color:green;'>Yes</span>"; }else { return valchange; } });  Now you can use this function in your template HTML file <td align="right">{{{addChangeClass -34}}}</td> or <td align="right">{{{addChangeClass number}}}</td> I used {{{ three curly bracket to render HTML in Meteor HTML Template.   

How to Return HTML in Meteor Template?

Render HTML in Meteor Template Use {{{variable}}} instead of {{variable}} to make sure there should not escape. With the three curly brackets you can render HTML in meteor template.

Why video and page loading stops when Mouse cursor or keyboard is not active in Mozilla?

video and page loading stops when Mouse cursor or keyboard is not active in Mozilla Actually i was facing same problem that it stops working when i leave my mouse cursor idle. Actually after 33 version of Mozilla  this have bug which stop these thing while cursor or keyboard is not active. So to solve this problem to page loading and video stop in Mozilla you need to follow the instruction as below; So for this you have to download 30 version of Mozilla and install this version into your computer. This will work fine. Hope this is helpfull. Please leave a comment if this works.

How to use try and catch in Error Handling?

Try and catch in Error Handling It is possible for a script to use multiple exceptions to check for multiple conditions. It is possible to use several if..else blocks, a switch, or nest multiple exceptions. These exceptions can use different exception classes and return different error messages: <?php class myException extends Exception {   public function errorMessage() {     $errMsg= 'Error on line '.$this->getLine().' in '.$this->getFile()     .': <b>'.$this->getMessage().'</b> is not a valid EMail address';     return $errMsg;   } } $email = "sagar@domain...com"; try {   //check if   if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) {     //throw exception if email is not valid     throw new myException($email);   }   //check for "example" in mail address   if(strpos($email, "example") !== FALSE) {     throw new Exception("$email is an example e-mail");  

What is function Overloading and Overriding in PHP?

Overloading  :-  Function overloading means you want more work or login from a function or  you can use different login in a function. You can not use same function in a class so for use this login you can use __call magic function where you can pass method name and parameter and can add login according to their parameter. Take a look on code:- class test { public function __construct() { //Your logic for constructor } public function __call($method_name , $parameter) { if($method_name == "overlodedFunction")  //Function overloading logic for function name overlodedFunction { $count = count($parameter); switch($count) { case "1": //Business log in case of overlodedFunction function has 1 argument echo "You are passing 1 argument"; break; case "2": //Incase of 2 parameter echo "You are passing 2 parameter"; break; case "3": //Incase of 2 parameter echo "You a

What is fixtures in Meteor?

Fixtures in Meteor Basically in short fixtures is js file where you can set default data which will insert automatically when the app runs. Like when you created a app and you want that when you will reset your database or delete all record from database then by default some record became inserted in collection of mongodb. like you can add some data in fixtures if (user.find().count() === 0) {   user.insert({     "name": "Industria de Diseno Textil SA",     "country": "ES",     active:false   });   userinsert({     "name": "Under Armour Inc.",     "country": "US",     active:false   });   user.insert({     "name": "Nike Inc.",     "country": "US",     active:false   }); }  So as you set code in fixures that will check if user collection does not have any record then by default it will insert three record when app

How to write MongoDB query in Meteor?

How to write MongoDB find query in Meteor? Or  How to write MongoDB update query in Meteor? First of all find query  Select symbol.yahoo from user where active='true' user.find({active:true},{fields:{'symbol.yahoo':1}}); Update query in MongoDB Meteor update user set open_at=9pm and trade_date ='2012-12-20' where symbol.yahoo='meteor'  var updata = {             open_at : '9pm',             trade_date : '20122-12-30' } user.update({'symbol.yahoo':'meteor'}, {$set:updata});

How to start Meteor APP?

Image
First of all you need a platform where you can start a Meteor APP You can use Linux or any other platform. If you will use Windows that you can face lots of technical issue of installation issue. So there is very basic tutorial from where you can easily learn Meteor. Step1: www.nitrous.io open this link and register here and login This site provide already set up meteor environment After login create a box and choose Node.js environment. Now you have box somthing like this. Click on IDE step2: You will see somthing like this On the left hand sidebar you will see the directory related to your app. In the bottom you can run linux command 3. Now you need to run in the console a command which install all remaing parts of meteor app parts install meteor Now you can follow this link for more info www.discovermeteor.com/blog/meteor-nitrous/

gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error is not recoverable: exiting now Installation failed.

While Installing Meteor i am getting this Error on my linux server or ubuntu I tried to figure out to get rid of this problem but unable to success so finally i found a solution. I think you can be stuck in this problem. Mostly this problem occurs when you try to install the  Meteor on your ubuntu or linux server. When you run this command  curl https://install.meteor.com | sh It shows some process and showed you that given error below gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error is not recoverable: exiting now Installation failed. Now here is the answer that how can you solve this problem Open your terminal where you running this command Before run this command curl https://install.meteor.com | sh You need to run this command before above command echo tlsv1 > $HOME/.curlrc Now you can run this command to install Meteor   curl https://install.meteor.com | sh Hope problem is sloved.     If this works for you then please submit a

app/storage/meta/services.json: failed to open stream: Permission denied - Laravel 4

If you are getting this error on your laravel 4 installation so put the steps as i mention below Error is like this in laravel 4 ErrorException file_put_contents(/var/www/vhosts/folder/app/storage/meta/services.json): failed to open stream: Permission denied  That means permission is not granted to write for meta folder so you need to run these command on your server from your root folder Step 1: Come to your root folder var/www/vhosts/yousite_folder/ Step 2: Run this command first find app/storage -type d -exec chmod 777 {} \; Step 3: Run this command now find app/storage -type f -exec chmod 777 {} \; These command will chmod all directories and files in app/storage to 777.  Done!! Now you can refresh your page and working fine. If this post help you please submit a comment in post to inspire me :)

chown: invalid user: `www:www'" - Error in CentOS

chown: invalid user: `www:www'"  - Error in CentOS When i grant ownership of the directory to the user, instead of just keeping it on the root system i got this error chown: invalid user: `www:www'" How to solve this. When you use this command "sudo chown -R www:www /var/www/example.com/public_html". ? You got an error here are the solution that how can you handle this Just replace the www:www to apache:apache Example: sudo chown -R apache:apache /var/www/example.com/public_html

wget: command not found

Error can like like this wget: command not found Or -bash: wget: command not found This error occurs if wget  is not installed on your server. Might be you have a VPS server. That means  you don't have wget installed Try this command yum install wget Now try wget command to download the package from server. Hope this will work now. If this post help you so do not forget to comment for this post

How to login MySql in CentOS Or Linux?

How to login MySql in CentOS Or Linux? Here i will show you that how can you use MySql on CentOS or Linux Os Open Your terminal and login with your root login now run this command to login in mysql mysql -u root -p It will ask you for password Enter password: Enter your password here which you have set for mysql It will show show you a successfull message OR insert mysql as selected tab mysql> Two points you must keep in your mind: 1) All MySQL commands end with a semicolon; if does not end with a semicolon, the command will not execute. 2) MySQL commands are usually written in uppercase and databases, tables, usernames, or text are in lowercase to make them easier to distinguish. MySQL command line is not case sensitive. To show all database: SHOW DATABASES; Use exit command to come out from the mysql> promt mysql> exit it will show msg bye

How to write MySql Query in laravel?

I will show a simple query in laravel where you can easily understand that how query works in laravel 4. $limit = 5; $value= Bank::where('isactive','=','yes')->where('money','>',0)->whereNotNull('account')->whereNull('credit')->take($limit)->orderBy('id', 'DESC')->get(); This query act like as query below select * from Bank where money>0 amd account!=null and credit='' order by id desc limit 0,5. This is the representation that how laravel query works i added here where condition with 3 different ways and limti and order by for this query This query will work for both Database MYSQL MongoDB

How to get XML response output in laravel?

How to get XML response output in laravel? or How to create XML response output in laravel? or Most of developers use header function to create xml file but this does not work header('Content-type: application/xml'); $output  = "<?xml version='1.0' encoding='UTF-8'?>"; here i will tell you that how can you show or save XML response output in laravel you have an array where you have data Here is an example that how can you create xml file response in laravel suppose you have an array which have twitter data //Preapre our output for xml data $output  = "<?xml version='1.0' encoding='UTF-8'?>"; $output .= "\n<twitterfeed>\n"; $j=0; foreach($twitterinfo as $row){ $j++; $output .= "<feed>\n"; $output .= "<id>" . $j . "</id>\n"; $output .= "<twitter_id>" . $row['twitter_id'] . "</twitter_id>\n"

How to rename a field from a collection in mongoDB?

How to rename a field from a collection in mongoDB? By this query you can rename a field from whole collection in mongoDB db.colleciton.update(     //  where query like: where active="yes"     {         "active" : "yes"     },       // will remove Name field from current collection     {         $rename: {"Name":"Username"}     },       // options     {         "multi" : true  // update all document     } ); or you can copy and paste this code above code is with comment that how mongoDB query works db.colleciton.update(     {         "active" : "yes"     },     {         $rename: {"Name":"Username"}     },     {         "multi" : true     } );

How to remove a field from a collection in mongoDB?

How to remove a field from a collection in mongoDB? By this query you can remove a field from whole collection in mongoDB db.colleciton.update(     //  where query like: where active="yes"     {         "active" : "yes"     },         // will remove Name field from current collection     {         $unset: {"Name":""}     },         // options     {         "multi" : true  // update all document     } ); or you can copy and paste this code above code is with comment that how mongoDB query works db.colleciton.update(     {         "active" : "yes"     },     {         $unset: {"Name":""}     },     {         "multi" : true     } );

EntityRef: expecting ';' error while creating the xml file?

This page contains the following errors: error on line 68 at column 18: EntityRef: expecting ';' Below is a rendering of the page up to the first error. Generally  this error occured when any value have & in the value between tag example:  <Name>PHP & C</Name> So & break the xml and due to this it shows the error just replace   & with  &amp   in your value field example:  $output .= "<Name>" . str_replace('&', '&amp;', $row['name']) . "</Name>"; I hope this will help you. If helped then dont forget to comment to inspire me :)

No hint path defined for [folder] in laravel?

No hint path defined for [folder] in laravel. There could be several reasone for this error in laravel. But most of time it works like a charm to solve this probelm - No hint path defined for If you will check your view file which you have include in your controller or routes. then  you will find that on view file you have some code like this in your view/file.php @extends('Folder::layouts.default') Or @include('Folder::includes.header') to pass the view in templates so where folder is mention you can change the folder  path where your file is located.

How to remove blank array from an array?

How to remove blank array  from an array? like: you have an array where a key is blank and you want to remove the array from the tree of array then you can use this function like: function unsetblankarray($array)     {         foreach($array as $key=>$value)         {             if(!@$array[$key]['field'])             {                 unset($array[$key]);             }         }         return $array; }

How to get the input value after validation failed in laravel 4?

You can get the particular input field after validation failed in laravel 4. simple use the old method with Input class to get the last inserted value of input box. $getvalue = Input::old("fieldName");

How to create a table via Artisan in laravel?

Create a table in database via Artisan in laravel Step1: First you need to go on your root directory Step2: php artisan migrate:make create_users_table paste this code into your command interface Step3: Check the file named 2014_mm_dd_114554_create_users_table.php in your Root\app\database\migrations folder Step4: There will be two method Up and Down paste this Schema in this method  public function up()     {         //         Schema::create('users', function($table)         {             $table->increments('id');             $table->string('email')->unique();             $table->string('name');             $table->timestamps();         });     }     /**      * Reverse the migrations.      *      * @return void      */     public function down()     {         //         Schema::drop('users');     } Step5: Run this command on your root directory php artisan migrate You  can check the database there will a

How to set flash message in laravel?

Set flash message in laravel You need to add this code in your controller Session::flash('loginerror', "Your Email-id or Password does not match."); return Redirect::to('login'); Now you need to add this code in your view section @if (Session::has('loginerror'))    <h2>{{ Session::get('loginerror') }}</h2> @endif

How to check php version in Linux?

How to check php version in Linux or centos simple copy and paste this command to check the php version in your linux window php -i | grep 'PHP Version' Output: PHP Version => 5.5.10

How to set a cron?

Set a cronjob file Please check the details Below  which represent that how can you set a cron job on time basis    .---------------- minute (0 - 59) | .------------- hour (0 - 23) | | .---------- day of month (1 - 31) | | | .------- month (1 - 12) OR jan,feb,mar,apr ... | | | | .---- day of week (0 - 6) (Sunday=0 or 7) | | | | | * * * * * command to be executed     Example 1: Set cron job run per minute * * * * * /usr/bin/php /var/www/vhosts/site/cron/mycron.php Example 2: Set cron job to run on a specific time every day 5:50am 50 5 * * * /usr/bin/php /var/www/vhosts/site/cron/mycron.php Example 3: Set cron job to run on a specific time every day 10:50pm 50 22 * * * /usr/bin/php /var/www/vhosts/site/cron/mycron.php Example 4: Set cron job to run on every sunday 1am 00 1 * * 0 /usr/bin/php /var/www/vhosts/site/cron/mycron.php   Example 5: Set cron job to run on every sunday 1am   00 1 * * Sun /usr/bin/php /var/www/vhosts/site/cron

How to print date in linux?

How to print date in linux Simply copy and paste this command in your linux console to print the date -  date '+%A %W %Y %X' Press enter output: Thursday 20 2014 12:29:38 PM You can check more command by write this command on your console date --help

How To install MongoDB in ubuntu?

How To install MongoDB in ubuntu   step1: Open the terminal login with root and copy the given code past in terminal apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo "deb http://downloads-distro. mongodb.org/repo/ubuntu- upstart dist 10gen" | tee -a /etc/apt/sources.list.d/10gen. list apt-get -y update apt-get -y install mongodb-10gen step2: $ sudo service mongodb start ******************** setup with php *************** step 1: sudo apt-get install php5-dev php5-cli php-pear step2 : sudo pecl install mongo step3: open php.ini "/etc/php5/apache2/php.ini" and set "extension=mongo.so" step4: service apache2 restart Now php with mongodb is ready for work.

How to pass parameter in routes using controller in laravel?

You can just pass the parameter like this in your routes.php file Route::get('company/{name}', array('as' => 'companydetails', 'uses' => 'PublicareaController@companydetails')); And you need to add your controller this code like this: public function companydetails($name)     {         echo $name;         die; }

How to add new field to all documents in mongoDB?

As you know that mongoDB have a update function which have four parameter to pass. You can use this like below: db.coll.update({}, $set:{name:"value"}, false, true);   You can set condition too: db.coll.update({_id:12}, $set:{name:"value"}, false, true);

How to create an Auto-Incrementing field in MongoDB?

Create an Auto-Incrementing  I checked so many article related to this but all are confusing for me because i was new in MongoDB and i want to create a field which should be auto increment like MySql. So i got an article on docs.mongodb.org and find that this article is great Here are some steps that how you can create an auto-increament id in your MongoDB Open your MongoDB screen where you write command line query Run this command and check database Step 1. show dbs - This command will show all database from your MongoDB Step 2. use databasename -  choose your database where you want to create a collection and auto increment field Now create new collection Step 3. db.createCollection("user"); Step 4. db.counters.insert(    {       _id: "userid",       seq: 0    } ) Now you need to create a function for auto increment the _id in mongoDB so create a function in your mongodb You need to write this function on your mongoDB scree

Responsive Charts with D3 with json parsing

Image
I was using chart of D3 but the chart were not responsive and also with csv. I found a article on eyeseast.github.io and i modified the article according to my need to make D3 chart responsive and work with JSON value. I passed JSON value into the Code and made some easy change. I really want to thanks eyeseast.github.io to great article of Responsive Charts with D3 but the article was not fulfilling my requirement for JSON parsing. That article use a csv file for data and some 4 column data to represent the Graph which was so difficult to understand and edit. I decided to make it more easy for  D3 chart with json parsing. Here is an example: Just copy and paste this code into a html file and run.  <style type="text/css">  /* Start css for D3 Graph for twitter Index */ div#chart{   max-width: 800px;   width: auto; } .bar rect {     stroke: #fff;     shape-rendering: crispEdges; } .bar rect.background {     fill: #E7E7E7; } .bar rect.percent {    

How to use GLYPHICONS Icon - bootstrap icon font hex value?

Here i shown hex value of the each icon, i don't see any page about it so i make this article here from bootstrap website and GLYPHICONS website,so here i will show you that how to embed that into project and use it. We can find these by looking at Bootstrap's stylesheet, Bootstrap.css. Each \{number} represents a hexadecimal value, so \2a is equal to 0x2a or &#x2a;.   You can check which icon you want to use from here: http://getbootstrap.com/components/#glyphicons and you can make css like this to use the icon:  <style> .tableheaderth{     content: "\e155";     font-family:"Glyphicons Halflings";      line-height:1;       margin:5px;       float: left; } </style> . glyphicon-asterisk : before { content : "\2a" ; } . glyphicon-plus : before { content : "\2b" ; } . glyphicon-euro : before { content : "\20ac" ; } . glyphicon-minus : before { content : "\2212" ; }