This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
gzip on; | |
gzip_static on; | |
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
gzip_proxied any; | |
gzip_vary on; | |
gzip_comp_level 6; | |
gzip_buffers 16 8k; | |
gzip_http_version 1.1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readFileData = (file) => { | |
return new Promise(resolve => { | |
if (!file instanceof File) | |
return resolve(file); | |
const reader = new FileReader(); | |
reader.addEventListener('load', function() { | |
resolve(this.result); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Store from '@/store'; // Vuex.store | |
// Check for auth routes: | |
const guardAuthRoutes = (to, from, next) => { | |
const matchedRoutes = to.matched; | |
const isLoggedIn = Store.state.Auth.isLoggedIn; | |
if (matchedRoutes.some(route => route.meta.auth === true) && !isLoggedIn) { | |
return next({ name: 'login' }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Support\Facades\Storage; | |
//... | |
$base64image = '...'; | |
@list($type, $file_data) = explode(';', $base64image); | |
@list(, $file_data) = explode(',', $file_data); | |
$type = explode(";", explode("/", $base64image)[1])[0]; | |
$path = 'images/' . time() . '.' . $type; | |
Storage::disk('local')->put($path, base64_decode($file_data)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- A really fancy home: --> | |
<template> | |
<home-component> | |
<template v-slot:living-room="livingRoomProps"> | |
<flatscreen-tv @view="livingRoomProps.watchTV"></flatscreen-tv> | |
<universal-remote | |
@changeChannelSports="livingRoomProps.changeChannel('SportsHD')" | |
@changeChannelCartoons="livingRoomProps.changeChannel('CartoonsHD')" | |
></universal-remote> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from "@angular/core"; | |
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; | |
class Backend { | |
getData() { return data; } | |
} | |
@Injectable() | |
export class Resolver implements Resolve<any> { | |
constructor (private backend: Backend) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BehaviorSubject } from 'rxjs'; | |
export class SomeServiceClass { | |
constructor() { | |
this.dataObject = new BehaviorSubject('some initial value'); | |
} | |
set setData(newData) { | |
// notify all subscribed listeners to update data: | |
this.dataObject.next(newData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ResourceController | |
{ | |
public function paginate($query, $current_page = 1, $items_per_page = 25) | |
{ | |
$count = $query->count(); | |
$data = $query->skip($items_per_page * ($current_page - 1))->take($items_per_page)->get(); | |
$pages = ceil($count / $items_per_page); | |
return [ | |
'count' => $count, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
props: { | |
id: Number, | |
}, | |
data() { | |
return { | |
avenger: {} // Our avenger object is initially empty | |
}; |