Skip to content

Instantly share code, notes, and snippets.

@martinandersen3d
martinandersen3d / settings.json
Created December 14, 2019 00:13 — forked from lighthouse-dev/settings.json
vs-code settings.json inspiration fra anden bruger
{
// "workbench.iconTheme": "material-icon-theme",
"window.zoomLevel": 0,
// "materialTheme.fixIconsRunning": false,
// "[javascript]": {
// "editor.tabSize": 2
// },
// "[html]": {
// "editor.tabSize": 2
@martinandersen3d
martinandersen3d / CheckType.js
Last active January 29, 2020 14:25
javascript type checking mini library
/*
Check Type, is used in the beginning of a method.
Here we will check that the Method Parameters is of the correct type.
*/
class Check {
constructor(obj, errorCode) {
this.obj = obj;
@martinandersen3d
martinandersen3d / backupToolExportInstalledprograms.sh
Created October 21, 2019 23:21
Linux mint install, Backup Tool - Backup / export list
#!/bin/bash
# Please comment if there is a oneliner.. I looked around on google without succes :-/
backupToolOutputDir='/home/m/Documents/Backups'
targetOutputDir='/media/m/Data/Dropbox/Linux/Backups/BackupTool'
sleep 0.5
# Notification in top-right corner
// 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 April 29, 2019 20:57 — forked from pastranastevenaz/axiosget.js
Example of an axios get request using arrow functions
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 April 24, 2019 00:04 — forked from alexdemers/String.pluralization.js
Laravel's pluralization logic in JavaScript
// 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 June 26, 2018 22:52 — forked from IngmarBoddington/xdebug
Xdebug ini settings, functions and general use.
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 June 25, 2018 14:09 — forked from carbontwelve/usefull_commands.sh
Running xdebug in the console, for debugging Laravel artisan commands. Useful as I keep forgetting this one...
# 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 00:29 — forked from eddieajau/debug.php
Printing a clean debug backtrace in 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;

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