Skip to content

Instantly share code, notes, and snippets.

@maarten00
maarten00 / exception.blade.php
Last active August 29, 2015 14:00
Laravel Exception Mailer
<h1>Exception in {{ App::environment() }}-environment!</h1>
<strong>Code</strong>: {{ $exception->getCode() }}<br>
<strong>Exception message</strong>: {{ $exception->getMessage() }}<br>
<strong>Exception file</strong>: {{ $exception->getFile() }}<br>
<strong>Exception line</strong>: {{ $exception->getLine() }}<br>
<hr/>
<strong>INPUT vars:</strong><br>
@maarten00
maarten00 / prettyprice.php
Last active August 29, 2015 14:00
Pretty Price formatter
/**
* Helper function to format price
* Replaces dots with commas, replaces trailing zeroes with ,-
* If there is only 1 trailing zero, adds another
* Adds ,- for rounded prices
* @param $price
* @return mixed|string
*/
public static function prettyPrice($price)
{
@maarten00
maarten00 / gist:ca92bdd99fc78cdf24dc
Created November 5, 2014 15:57
Regex: Find all @if, @else, @elseif or @endif that are not preceded and postceded by a space
(?<!\s)(@if\(.*\)|@elseif\(.*\)|@else|@endif)(?!\s)
@maarten00
maarten00 / functions.php
Last active June 1, 2016 23:29
Gravity forms referrer url fix
function populate_posts($form){
foreach($form['fields'] as &$field){
if($field['defaultValue'] != '{referer}')
continue;
//Check referrer field, if exists and HTTP referrer not set, try to fill it manually
if($field['defaultValue'] == '{referer}' && ! isset($_SERVER['HTTP_REFERER']))
{
@maarten00
maarten00 / prettyprice.js
Last active September 24, 2019 08:01
Prettyprice Javascript
export const prettyPrice = price => {
price = parseFloat(price);
price = formatMoney(price);
price = addDecimalSeperators(price);
price = price.replace(",00", ",-");
return price;
};
const formatMoney = (price, length, decimalDelimiter, sectionDelimiter) => {
let c, d, t, s, i, j;
@maarten00
maarten00 / pmt.js
Created March 19, 2015 09:56
Excel PMT in PHP and JavaScript
/**
* Copy of Excel's PMT function.
* Credit: http://stackoverflow.com/questions/2094967/excel-pmt-function-in-js
*
* @param rate_per_period The interest rate for the loan.
* @param number_of_payments The total number of payments for the loan in months.
* @param present_value The present value, or the total amount that a series of future payments is worth now;
* Also known as the principal.
* @param future_value The future value, or a cash balance you want to attain after the last payment is made.
* If fv is omitted, it is assumed to be 0 (zero), that is, the future value of a loan is 0.