Skip to content

Instantly share code, notes, and snippets.

martinandersen3d

Block or report user

Report or block martinandersen3d

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View axios-401-response-interceptor.js
// Add a 401 response interceptor
window.axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
if (401 === error.response.status) {
swal({
title: "Session Expired",
text: "Your session has expired. Would you like to be redirected to the login page?",
type: "warning",
showCancelButton: true,
@martinandersen3d
martinandersen3d / axiosget.js
Created Apr 29, 2019 — forked from pastranastevenaz/axiosget.js
Example of an axios get request using arrow functions
View axiosget.js
var albums = [];
axios.get('https://jsonplaceholder.typicode.com/albums')
.then(response =>{
this.albums = response.data
})
.catch(error =>{
console.log(error);
})
@martinandersen3d
martinandersen3d / String.pluralization.js
Created Apr 24, 2019 — forked from alexdemers/String.pluralization.js
Laravel's pluralization logic in JavaScript
View String.pluralization.js
// replace occurences of :vars in the string.
// "This :thing is great!".format
String.prototype.format = function(replacements) {
var str = this;
for (var key in replacements) {
if (replacements.hasOwnProperty(key)) {
str = str.replace(':' + key, replacements[key]);
}
}
@martinandersen3d
martinandersen3d / xdebug
Created Jun 26, 2018 — forked from IngmarBoddington/xdebug
Xdebug ini settings, functions and general use.
View xdebug
Enable tracing example:
zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
xdebug.auto_trace=1
xdebug.trace_output_dir="/tmp/xdebug/"
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.trace_options=1
xdebug.show_local_vars=1
@martinandersen3d
martinandersen3d / usefull_commands.sh
Created Jun 25, 2018 — forked from carbontwelve/usefull_commands.sh
Running xdebug in the console, for debugging Laravel artisan commands. Useful as I keep forgetting this one...
View usefull_commands.sh
# Running xdebug in the console, for debugging Laravel artisan commands. Useful as I keep forgetting this one...
php -dxdebug.remote_autostart artisan
#Running phpcs for 5.3:
phpcs -pv --standards= --runtime-set testVersion 5.3 --ignore=*/public/*,*.js,*.css,*/tests/*,*/views/training/* .
@martinandersen3d
martinandersen3d / debug.php
Created May 31, 2018 — forked from eddieajau/debug.php
Printing a clean debug backtrace in PHP.
View debug.php
// PHP < 5.3.6
foreach (debug_backtrace() as $trace)
{
echo sprintf("\n%s:%s %s::%s", $trace['file'], $trace['line'], $trace['class'], $trace['function']);
}
die;
// PHP >= 5.3.6
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
die;
View git-selective-merge.md

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

On master:

> git co -b temp
View js-observables-binding.md

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5
setN(10);
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Mikhail Davydov <azazel.private@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@martinandersen3d
martinandersen3d / 1) Main.blade.php
Created Apr 26, 2018 — forked from jacurtis/1) Main.blade.php
Laravel 5.4 Components & Slots
View 1) Main.blade.php
<!-- This is the main Blade file that you want your components to show up in -->
<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
You can’t perform that action at this time.