Skip to content

Instantly share code, notes, and snippets.

@xiaoysh8
xiaoysh8 / format and mount hd
Created September 30, 2017 01:53
format and mount hd
##format and mount HD
###check if there are HD
fdisk -l
###partition
fdisk /dev/vdb
###format
mkfs.ext3 /dev/vdb1
@xiaoysh8
xiaoysh8 / setup vsftpd
Last active September 30, 2017 05:29
setup vsftpd
##setup vsftpd
###install vsftpd
sudo apt update
sudo apt install vsftpd
###add user
useradd ftpuser -p <password> -g ftp -d /var/www -s bin/false
//user home
sudo usermod -d /var/www ftpuser
sudo usermod -G www-data ftpuser //将用户ami8加入到www-data群中
chmod -R ug+rw /home/ftpfolder
@xiaoysh8
xiaoysh8 / composer china mirror
Last active May 28, 2018 03:29
composer china mirror
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
}
@xiaoysh8
xiaoysh8 / npm china mirror
Last active March 11, 2021 12:34
npm china mirror
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
或者你直接通过添加 npm 参数 alias 一个新命令:
alias cnpm="npm --registry=https://registry.npm.taobao.org \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npm.taobao.org/dist \
--userconfig=$HOME/.cnpmrc"
# Or alias it in .bashrc or .zshrc
$ echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://registry.npm.taobao.org \
@xiaoysh8
xiaoysh8 / git remote deployment
Last active August 24, 2018 02:02
git remote deployment
//远程建立空库
mkdir repos
cd repos
git init --bare --shared site.git
cd /var/www/web
//网站如果会在 /var/www/web下
git clone /var/www/web/repos/site.git site
@xiaoysh8
xiaoysh8 / git config
Last active March 17, 2021 06:07
git config
git init
git config --global user.name "Your Name"
git config --global user.email "Your Email Address"
git config --global color.ui auto
git remote add origin https://github.com/LearningLaravel/Laravel.git
git push -u origin master
//提交远程新分支
git push --set-upstream origin dev
//下载无关分支
@xiaoysh8
xiaoysh8 / laravel Create a Facebook Test App
Created June 3, 2018 11:19
laravel Create a Facebook Test App
Create a Facebook Test App
After creating your Facebook app, you can connect it to your Laravel app by simply editing the
config/services.php file. Add this:
1 'facebook' => [
2 'client_id' => 'yourFacebookAppID',
3 'client_secret' => 'yourFacebookAppSecret',
4 'redirect' => 'http://yourLaravelAppURL/login/facebook/callback',
5 ],
Open database/migrations/timestamps_create_users_table.php file and update the up method:
1 public function up()
@xiaoysh8
xiaoysh8 / laravel redirecting user
Created June 3, 2018 11:46
laravel redirecting user
Redirecting Unauthenticated Users
When the auth middleware detects an unauthorized user, it will either return a JSON 401 response, or, if the request was not an AJAX request, redirect the user to the login named route.
You may modify this behavior by defining an unauthenticated function in your app/Exceptions/Handler.php file:
use Illuminate\Auth\AuthenticationException;
protected function unauthenticated($request, AuthenticationException $exception)
{
return $request->expectsJson()
@xiaoysh8
xiaoysh8 / laravel Manually Authenticating Users
Created June 3, 2018 13:31
laravel Manually Authenticating Users
Manually Authenticating Users
Of course, you are not required to use the authentication controllers included with Laravel. If you choose to remove these controllers, you will need to manage user authentication using the Laravel authentication classes directly. Don't worry, it's a cinch!
We will access Laravel's authentication services via the Auth facade, so we'll need to make sure to import the Auth facade at the top of the class. Next, let's check out the attempt method:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
@xiaoysh8
xiaoysh8 / laravel Remembering Users
Created June 3, 2018 13:34
laravel Remembering Users
Remembering Users
If you would like to provide "remember me" functionality in your application, you may pass a boolean value as the second argument to the attempt method, which will keep the user authenticated indefinitely, or until they manually logout. Of course, your users table must include the string remember_token column, which will be used to store the "remember me" token.
if (Auth::attempt(['email' => $email, 'password' => $password], $remember)) {
// The user is being remembered...
}
If you are using the built-in LoginController that is shipped with Laravel, the proper logic to "remember" users is already implemented by the traits used by the controller.
If you are "remembering" users, you may use the viaRemember method to determine if the user was authenticated using the "remember me" cookie: