Skip to content

Instantly share code, notes, and snippets.

View renalpha's full-sized avatar

Jason Hoendervanger renalpha

View GitHub Profile
@renalpha
renalpha / .htaccess
Created July 24, 2019 12:36
Laravel - disable apache view caching
#Initialize mod_rewrite
RewriteEngine On
<FilesMatch "\.(html|htm|js|css)$">
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 12 Jan 1980 05:00:00 GMT"
</IfModule>
@renalpha
renalpha / app.js
Created July 16, 2019 18:34
Vuejs with routing
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('../js/loadScripts.js');
import Vue from 'vue';
import VueRouter from 'vue-router';
@renalpha
renalpha / app.js
Created July 15, 2019 08:34
Vuejs with localisation
const _ = require('lodash');
Vue.prototype.trans = string => _.get(window.i18n, string);
const app = new Vue({
el: '#app',
});
@renalpha
renalpha / Array.php
Created June 26, 2019 12:45
Laravel Magicsuggest map ->pluck
<?php
json_encode($products->map(function ($data) {
$result['id'] = $data->id;
$result['name'] = $data->title;
return $result;
}))
@renalpha
renalpha / .htaccess
Created June 25, 2019 06:58
htaccess security headers for Apache
# Set browser headers
<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Xss-Protection "1; mode=block"
Header always set X-Content-Type-Options "nosniff"
Header set Referrer-Policy "no-referrer-when-downgrade"
</IfModule>
@renalpha
renalpha / buttons.js
Created June 12, 2019 15:26
Disable buttons
'onclick' => 'confirmAlert(this)'
function confirmAlert(btn) {
var result = confirm("are you sure?");
if (result === true) {
btn.form.submit();
btn.disabled = true;
btn.value = "Sending…";
}
return result;
@renalpha
renalpha / expression.php
Last active May 28, 2019 15:09
Regex Multiple names validation
<?php
// Expression
$expression = '/^([_\p{Lu}\p{Lt}][_\p{Nd}\p{Ll}\p{Lm}\p{Lo} ',-."]+)+$/u';
$rules = [
'full_name' => 'required|regex:' . $expression,
'first_name' => 'required|regex:' . $expression,
'last_name' => 'required|regex:' . $expression
];
@renalpha
renalpha / .htaccess
Last active May 28, 2019 13:25
Laravel post api | Allow trailing slash post routes
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
# Dont redirect on POST methods....
RewriteCond %{REQUEST_METHOD} !POST
RewriteRule ^ %1 [L,R=301]
@renalpha
renalpha / DecoratorPattern.php
Created May 15, 2019 07:41
Decorator pattern
<?php
namespace App;
class DecoratorPattern
{
// Decorator pattern explained.
}
@renalpha
renalpha / LogoutResponsibility.php
Created May 15, 2019 07:20
Chain of responsibilities
<?php
namespace App;
class LogoutResponsibility
{
// Logout chain of responsibility design pattern.
}