Skip to content

Instantly share code, notes, and snippets.

benhodgson87 / decimalFormat.js
Last active Nov 8, 2020
DecimalFormat Currency Formatting
View decimalFormat.js
Number.prototype.currency = function (format) {
var amt = this, neg;
// If no formatting string supplied
// or amount is not a number, return as is
if (!format || isNaN(amt)) return amt;
// Extract placeholders from format string
var formFig = format.match(/\#(.*)\#/g).pop();
benhodgson87 / Jenkinsfile
Last active Jul 3, 2020
Jenkins step to run Yarn Audit exiting only on critical level vulnerabilities
View Jenkinsfile
// Run yarn audit and only exit 0 on critical vulnerabilities (greater than 8)
// Credit:
stage('Node dependencies') {
steps {
sh script: '/bin/bash -c "yarn audit; [[ $? -ge 8 ]] && exit 1 || exit 0"', label: "Vulnerability audit"
sh script: 'yarn', label: 'Install dependencies'
benhodgson87 / beforeAfter.html
Last active Mar 9, 2020
Before/After PR Template
View beforeAfter.html
<td><img src="BEFORE" width="480" /></td>
<td><img src="AFTER" width="480" /></td>
View countries.json
"AD": {
"currency": {
"primary": "EUR"
"iso": {
"code2": "AD",
"code3": "AND",
"num": "020"
View bottle_status_logic.js
// source
const current_bottle_weight = 1120;
const empty_bottle_weight = 649;
const full_bottle_weight = 1357;
const full_bottle_ml = 700;
const full_bottle_volume = full_bottle_weight - empty_bottle_weight;
benhodgson87 / BasicField.js
Created Feb 21, 2018
Reusable React/Redux-Form Layout using HOC
View BasicField.js
* Basic input field wrapped with FormField HOC
import React from 'react'
import PropTypes from 'prop-types'
import FormFieldWrapper from './FormFieldWrapper'
import './BasicField.css'
benhodgson87 / Crowdsurge .gitignore
Last active Dec 31, 2015
.gitignore Boilerplate for Crowdsurge Repos
View Crowdsurge .gitignore
# .gitignore Boilerplate
# For noise that might accidentally end up in Repos
# And anything that should be in S3
# -------------------------------------------------
# Noise
# -----
benhodgson87 / dateformat.html
Last active Dec 31, 2015
Date formatting function for Example ballot
View dateformat.html
<!DOCTYPE html>
<script src=""></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<div id="date"></div>
benhodgson87 / rgba-fallback.scss
Last active Dec 29, 2015
Sass RGBA Fallback Mixin
View rgba-fallback.scss
* RGBA & Hex Fallback
* Takes a hex code with comma separated alpha value.
* Falls back to just the hex if no alpha is provided.
* Params:
* $prop: The CSS property to apply the color value to
* $color: A hex code, or bracketed Hex + Opacity figure. eg: (#fff, 0.5)
View ryanair.css
[core-date-range] [core-morph-popup] .content-box .footer .btn.close.disabled,
[core-date-range] [core-morph-popup] .content-box .footer,
[core-date-range] [core-morph-popup] .content-box .footer .btn.close.disabled.focus,
[core-date-range] [core-morph-popup] .content-box .footer .btn.close.disabled:active,
[core-date-range] [core-morph-popup] .content-box .footer .btn.close.disabled:focus,
[core-date-range] [core-morph-popup] .content-box .footer .btn.close.disabled:hover,
[core-date-range] [core-morph-popup] .content-box .footer .btn.close[disabled],
[core-date-range] [core-morph-popup] .content-box .footer .btn.close[disabled].active,
[core-date-range] [core-morph-popup] .content-box .footer .btn.close[disabled].focus,
[core-date-range] [core-morph-popup] .content-box .footer .btn.close[disabled]:active,