I get it, a lot of people are confused on how to start typing on VIM. All you have to do is press the A key, the editor will be switched to insert mode.
Press ESC key to switch back to normal mode.
I get it, a lot of people are confused on how to start typing on VIM. All you have to do is press the A key, the editor will be switched to insert mode.
Press ESC key to switch back to normal mode.
One of the most infamous issues that new users of VIM faces when using it for the first time. Press :q to quit VIM
If you've worked on a file and want to save and quit? Just type :wq!.
I hope that solved your quitting issue with VIM.
Want to save your work? Type :w
Type :wq! to save your file and quit VIM at the same time.
I mean, come on, you need to have a reCaptcha in your forms, no matter what.
Here are the steps:
composer require anhskohbo/no-captcha
Open your config/app.php file and add this to your providers array:
<?php
Anhskohbo\NoCaptcha\NoCaptchaServiceProvider::class,
?>
And this to your aliases array:
<?php
'NoCaptcha' => Anhskohbo\NoCaptcha\Facades\NoCaptcha::class,
?>
php artisan vendor:publish --provider="Anhskohbo\NoCaptcha\NoCaptchaServiceProvider"
Open your .env file and add this:
NOCAPTCHA_SITEKEY=yoursitekey
NOCAPTCHA_SECRET=yoursecret
Now, you can use it in your validator using like this:
<?php
$validate = Validator::make(Input::all(),[
'g-recaptcha-response' => 'required|captcha'
]);
?>
Are you new to using Git? Then this is for you.
Go to GitHub and create your account with your email address.
Just create a new project with whatever you wanted. For this, you can just create git-starter-repo or something like that.
Now, go to your project directory and initialize git by doing the following:
git init
Add your files to the repository by doing the following:
git add .
Or if you want add selected files:
git add file_1 file_2
Before you push your changes, you need to write a message about what changes are done:
git commit -m "this is my first commit"
Do the following to link your project to the repo that you've created in step 1:
git remote add origin https://github.com/youraccount/repositoryname.git
You can decide which branch you wanted to push but initially, you'll have one branch, which is called master:
git push -u origin master
Or if you have an existing branch, just replace master with yourbranchname.
Hope that helps you out!
Got a .pem key but don't know how to SSH to your server, just do this:
ssh -i name_of_key user@domain -p 22
Recently, I started working from home and as a programmer, it's pretty common to access the company server for development purposes.
Back in the office, I used to access it using PuTTY but now that I'm using a linux machine, I thought of accessing it via Terminal but there's a catch, I can't use .ppk key to access it.
So, I did a little research and figured that I can easily convert it using puttygen
Open up your terminal and type:
sudo apt install putty-tools
Now, convert your private key to PEM format:
puttygen yourprivate.ppk -O private-openssh -o your_new_key.pem
That's it and you're good to go!
When using Laravel, the public directory is used for files that are publicly accessible. By default, it's stored in local and often stored in this storage/app/public directory. You can make it easily accessible by using the following command:
php artisan storage:link
Once, it has been created, you can use access those files using the public_path or asset methods.
<?php
echo public_path('images/sample_1.jpg');
echo asset('images/sample_2.jpg');
?>
If you're hosting a laravel project via cPanel, chances are that it could be a shared hosting server and that means you can't really use php artisan storage:link for this.
But don't worry, there's another way to this. Just follow the steps below:
In your public_html/public directory, remove the storage folder. Next, create a symlink.php file in your public_html directory and add the following code:
<?php
$targetFolder = $_SERVER['DOCUMENT_ROOT'].'/storage/app/public';
$linkedFolder = $_SERVER['DOCUMENT_ROOT'].'/public/storage';
symlink($targetFolder, $linkedFolder);
echo "done";
?>
Alright, this is kind of a hack but it works extremely fine. Just add the following route in your routes/web.php file:
<?php
Route::get('/storage/anyfolder/{filename}', function($filename){
// Your folder path
$folder_path = storage_path('app/public/anyfolder/'.$filename);
// check if the file exists
if(!File::exists($folder_path)) {
abort(404);
}
$file = File::get($folder_path);
$type = File::mimeType($folder_path);
$response = Response::make($file, 200);
$response->header("Content-Type", $type);
return $response;
})
?>
Now, you can access your images or any other assets easily using:
<?php
asset('storage/anyfolder/'.$filename)
?>
Hope this helps you out!