Skip to content

Instantly share code, notes, and snippets.

@salipro4ever
salipro4ever / laravel55-passport-scope-example.md
Last active May 2, 2018 03:54
Understanding laravel passport scope

Define Scopes

You may define your API's scopes using the Passport::tokensCan method in the boot method of your AuthServiceProvider. Client can not request access_token with scopes if it does not define in tokensCan already.

use Laravel\Passport\Passport;

Passport::tokensCan([
    'place-orders' => 'Place orders',
    'check-status' => 'Check order status',
]);
@salipro4ever
salipro4ever / laravel55-authorization-gates-policies.md
Last active March 21, 2018 07:54
Understanding about authorization laravel 5.5

Concepts

Laravel's authorization is built around 2 main concepts:

  1. A Gate class The gate is the official authority on who has what ability (i.e. who can do what). You use the gate to register a user's abilities, and later check the gate if the user can perform a given action.
  2. Policy classes Policies are responsible for checking abilities on a single model type. For each model class in your system you want to authorize against, you'll have a matching policy class.

Think of gates and policies like routes and controllers. Gates provide a simple, Closure based approach to authorization while policies, like controllers, group their logic around a particular model or resource.

Usage

To start testing for this, we need login method first (just run php artisan make:auth)

@salipro4ever
salipro4ever / blogger-snippets
Last active March 19, 2018 04:48
Blogger Snippets
http://pebblesdog-oddthemes.blogspot.com/
/*<![CDATA[*/
if (typeof firstText == "undefined") firstText = "First";
if (typeof lastText == "undefined") lastText = "Last";
var noPage;
var currentPage;
var currentPageNo;
var postLabel;
pagecurrentg();
@salipro4ever
salipro4ever / blogger-template-empty.xml
Created March 19, 2018 02:46
Empty google template
<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
<head>
<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/>
<b:if cond='data:blog.isMobile'>
<meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/>
<b:else/>
<meta content='width=1100' name='viewport'/>
</b:if>
<b:include data='blog' name='all-head-content'/>
@salipro4ever
salipro4ever / vue-routes-case-1.js
Last active February 23, 2018 07:56
Two ways to define vue-route
//app.js
import VueRouter from 'vue-router';
import routes from './routes';
Vue.use(VueRouter);
const router = new VueRouter({ mode: 'history', routes: routes});
const app = new Vue({
el: '#app',
router //mandatory similar, because in ES6, {router} ~ {router: router}
});
@salipro4ever
salipro4ever / abc-lumen55-jwt-auth
Last active February 7, 2018 04:00
JWT auth for Lumen 5.5 & tymon/jwt-auth
composer.json
...
"require": {
"php": ">=7.0",
"laravel/lumen-framework": "5.5.*",
"vlucas/phpdotenv": "~2.2",
"tymon/jwt-auth": "1.0.0-rc.1"
},
-----------
@salipro4ever
salipro4ever / timezone.json
Created October 31, 2017 03:49
Short timezone
{
"(GMT-11:00) Pago Pago": "Pacific/Pago_Pago",
"(GMT-10:00) Hawaii Time": "Pacific/Honolulu",
"(GMT-08:00) Pacific Time": "America/Los_Angeles",
"(GMT-08:00) Pacific Time - Tijuana": "America/Tijuana",
"(GMT-07:00) Mountain Time": "America/Denver",
"(GMT-07:00) Mountain Time - Arizona": "America/Phoenix",
"(GMT-07:00) Mountain Time - Chihuahua, Mazatlan": "America/Mazatlan",
"(GMT-06:00) Central Time": "America/Chicago",
"(GMT-06:00) Central Time - Mexico City": "America/Mexico_City",
@salipro4ever
salipro4ever / jquery
Created October 19, 2017 08:32
Create jquery plugin (faster)
$.fn.digits = function(){
return this.each(function(){
$(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
})
}
You could then use it like this:
$("span.numbers").digits();
@salipro4ever
salipro4ever / xampp.md
Created August 31, 2017 03:34
Xampp - restore db from other
  1. Install same version (suggest: portable in C:/xampp)
  2. Change same root/password like old
  3. Backup new /mysql/data and paste /data folder to here
  4. Start xampp

----------- ERROR

  1. Table "xxx" doesn't exist -> need copy all /data folder not only database name
@salipro4ever
salipro4ever / sqlsrv_v1.8
Created April 19, 2017 07:59
FUELPHP - bug sqlsrv
SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]'NAMES' is not a recognized SET option.
---------------
'default' => array(
'type' => 'pdo',
'connection' => array(
'dsn' => 'sqlsrv:Server=localhost;Database=HOURGLASS_DEV',
'username' => 'sa',
'password' => '123456'
),