Checking Out Laravel Dusk

Was trying to figure out why should I use Dusk over PHPunit where Dusk also uses PHPunit for test, so I found out that the different between PHPunit and Dusk is that when your application uses Javascript, those javascript aren’t being tested because isn’t a browser, but with Dusk it will be tested to…

composer require laravel/dusk --dev
// AppServiceProvider
use Laravel\Dusk\DuskServiceProvider;
public function register()
{
if ($this->app->environment('local', 'testing')) {
$this->app->register(DuskServiceProvider::class);
}
}

Then install vendor

php artisan dusk:install

try to run it

php artisan dusk

If it works then start your magic

More info

Backup Laravel and Database

This just helps a lot on backing up database and app, this package is a simple backup was enough even thought you can backup to S3, Rackspace, dropbox and custom ftp.

composer require spatie/laravel-backup

Register Provider

// config/app.php

'providers' => [
    // ...
    Spatie\Backup\BackupServiceProvider::class,
];
php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"

check config/laravel-backup.php for configurations, pretty straight forward.
to check if the backup is running or not try these command

php artisan backup:run

Before adding to Kernel add this to cron

#* * * * * php /var/www/testing/artisan schedule:run >> /dev/null 2>&1
// app/Console/Kernel.php

protected function schedule(Schedule $schedule)
{
   $schedule->command('backup:clean')->daily()->at('01:00');
   $schedule->command('backup:run')->daily()->at('02:00');
}

More Info

Getting started Trello API Rails

Working in this Trello ruby API, had to make card from contact to trello. First get the developer public key  then get the member token. Just to get started this is only for creating trello cards just to get started.

Add to gemfile

gem 'ruby-trello', '1.5.1'


def create_trello_card
Trello.configure do |config|
config.developer_public_key = ENV["trello_developer_public_key"]
config.member_token = ENV["trello_member_token"]
end
list_id = Trello::Board.find(ENV["trello_board"]).lists.first.id

Trello::Card.create(
name: cardName,
desc: cardDesc,
list_id: list_id
)
end

Ruby-trello

Your Host May Have Disabled The mail() Function

Tried forgot password on my wordpress admin site then the error appear

 

your host may have disabled the mail() function

The solution is

sudo apt-get install sendmail
sudo sendmailconfig

Just use the default configuration

sudo reboot

If still doesn’t work

find your hostname

hostname
nano /etc/hosts
127.0.0.1 localhost.localdomain localhost yourhostname

change yourhostname to exact hostname that appear when you type hostname

PHP Error Fixes

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

To install php5-mysql module enter:

sudo apt-get install php5-mysql

Next, restart the Apache2/Nginx web server:
sudo service apache2 restart / sudo service nginx restart

To verify if this worked correctly, create a new PHP file some where on your web server and place this inside of it:

<?php phpinfo(); ?>

 

Digital Ocean

syntax error, unexpected 'use' then how to use

use statements should appear at the top of a PHP file, not half-way through it…


 

Got error 28 from storage engine

check your server storage.. df -h


 

Call to undefined method CI_DB_mysqli_result::next_result()

open system/database/drivers/mysqli/mysqli_driver.php then change the function _execute() to the code below

function _execute($sql) {
    // Free result from previous query
    @mysqli_free_result($this->result_id);

    $sql = $this->_prep_query($sql);

    // get a result code of query (), can be used for test is the query ok
    $retval = @mysqli_multi_query($this->conn_id, $sql);

    // get a first resultset
    $firstResult = @mysqli_store_result($this->conn_id);

    // free other resultsets
    while (@mysqli_next_result($this->conn_id)) {
        $result = @mysqli_store_result($this->conn_id);
        @mysqli_free_result($result);
    }

    // test is the error occur or not 
    if (!$firstResult && [email protected]_errno($this->conn_id)) {
        return true;
    }
    return $firstResult;
}

Call to undefined function curl_init()

Solution

;extension=php_curl.dll
or
sudo apt-get install php5-curl

nginx upstream timed out

Solution

add -> fastcgi_read_timeout 150;

With your php-fpm configuration it should look like this:

location ~* .php$ {
    include         fastcgi_params;
    fastcgi_index   index.php;
    fastcgi_read_timeout 150;
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
}

Malware infection detected webmaster

I’ve been dealing with malware lately, somehow it’s annoying and was about to do a clean install in my wordpress site. The thing is, it’s always in my wordpress but not in my other custom made website frameworks and I installed it from the instant installation in my hosting which is Godaddy. Well next time i’ll try to install using wordpress.org and see will it add another malware.

After researching these are my steps

  • Change new password in wordpress admin and hosting
  • Backup wordpress, update / uninstall plugin if necessary, update theme
  • Then download Wordfence Security
  • Find all infected files usually the one with base64, take it out if it’s not core of wordpress or theme else just edit the files and delete them then save.
  • Webmaster : Request fixed issues
  • add description on how to clean the malware
  • then next day google your site using site://www.domain.com

I’ve tried with another site and it works

Rails / Ruby troubleshoot solutions

ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
Add to the following files in environment
test.rb / development.rb / production.rb

Rails.application.routes.default_url_options[:host] = 'host.com'

undefined method …_index_path Ruby on Rails
Your models should always be singular and controllers should always be plural

EXECJS runtime error
Download nodejs

Uninstalling ruby manually installed from source
lets say that you’ve installed ruby 2.4 from source… then you want to downgrade to 2.3

Go to the folder where you run “sudo make install” command then

sudo make uninstall